cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [8/15] git commit: Fallback to old describe_splits if d_s_ex is not available patch by Piotr Kołaczkowski; reviewed by jbellis for CASSANDRA-4803
Date Tue, 27 Nov 2012 15:04:44 GMT
Fallback to old describe_splits if d_s_ex is not available
patch by Piotr Kołaczkowski; reviewed by jbellis for CASSANDRA-4803


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/37067495
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/37067495
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/37067495

Branch: refs/heads/cassandra-1.2
Commit: 37067495cfa818b9adeea0c6a08898dbec088c80
Parents: 2f4b6d8
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Nov 28 00:01:32 2012 +0900
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Nov 28 00:01:32 2012 +0900

----------------------------------------------------------------------
 CHANGES.txt                                        |    4 ++
 .../cassandra/hadoop/ColumnFamilyInputFormat.java  |   27 ++++++++++++++-
 .../apache/cassandra/thrift/CassandraServer.java   |    1 -
 3 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/37067495/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6401cd0..066065d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+1.1.8
+ * Fall back to old describe_splits if d_s_ex is not available (CASSANDRA-4803)
+
+
 1.1.7
  * cqlsh: improve COPY FROM performance (CASSANDRA-4921)
  * add basic authentication support for Pig CassandraStorage (CASSANDRA-3042)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37067495/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java
index 4de6984..eda9898 100644
--- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java
+++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java
@@ -35,7 +35,9 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import org.apache.commons.lang.StringUtils;
+import org.apache.thrift.TApplicationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -253,7 +255,21 @@ public class ColumnFamilyInputFormat extends InputFormat<ByteBuffer,
SortedMap<B
             {
                 Cassandra.Client client = ConfigHelper.createConnection(conf, host, ConfigHelper.getInputRpcPort(conf));
                 client.set_keyspace(keyspace);
-                return client.describe_splits_ex(cfName, range.start_token, range.end_token,
splitsize);
+
+                try
+                {
+                    return client.describe_splits_ex(cfName, range.start_token, range.end_token,
splitsize);
+                }
+                catch (TApplicationException e)
+                {
+                    // fallback to guessing split size if talking to a server without describe_splits_ex
method
+                    if (e.getType() == TApplicationException.UNKNOWN_METHOD)
+                    {
+                        List<String> splitPoints = client.describe_splits(cfName, range.start_token,
range.end_token, splitsize);
+                        return tokenListToSplits(splitPoints, splitsize);
+                    }
+                    throw e;
+                }
             }
             catch (IOException e)
             {
@@ -272,6 +288,15 @@ public class ColumnFamilyInputFormat extends InputFormat<ByteBuffer,
SortedMap<B
     }
 
 
+    private List<CfSplit> tokenListToSplits(List<String> splitTokens, int splitsize)
+    {
+        List<CfSplit> splits = Lists.newArrayListWithExpectedSize(splitTokens.size()
- 1);
+        for (int j = 0; j < splitTokens.size() - 1; j++)
+            splits.add(new CfSplit(splitTokens.get(j), splitTokens.get(j + 1), splitsize));
+        return splits;
+    }
+
+
     private List<TokenRange> getRangeMap(Configuration conf) throws IOException
     {
         Cassandra.Client client = ConfigHelper.getClientFromInputAddressList(conf);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/37067495/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index b196b2f..6c0a295 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -905,7 +905,6 @@ public class CassandraServer implements Cassandra.Iface
         return result;
     }
 
-    @Override
     public List<CfSplit> describe_splits_ex(String cfName, String start_token, String
end_token, int keys_per_split)
     throws InvalidRequestException, TException
     {


Mime
View raw message