You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2016/01/14 18:14:06 UTC

[04/10] cassandra git commit: (cqlsh) fix cqlsh_copy_tests when vnodes are disabled

(cqlsh) fix cqlsh_copy_tests when vnodes are disabled

patch by Stefania Alborghetti; reviewed by Paulo Motta for CASSANDRA-10997


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

Branch: refs/heads/cassandra-3.3
Commit: c42716f2a91ff4e0e8b1ed50eb01edb46978a562
Parents: 26dc07b
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Tue Jan 12 12:12:34 2016 +0000
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Thu Jan 14 17:09:40 2016 +0000

----------------------------------------------------------------------
 CHANGES.txt                |  1 +
 pylib/cqlshlib/copyutil.py | 47 ++++++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c42716f2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9c73adf..74fd45b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.13
+ * (cqlsh) fix cqlsh_copy_tests when vnodes are disabled (CASSANDRA-10997)
  * (cqlsh) fix formatting bytearray values (CASSANDRA-10839)
  * (cqlsh) Add request timeout option to cqlsh (CASSANDRA-10686)
  * Avoid AssertionError while submitting hint with LWT (CASSANDRA-10477)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c42716f2/pylib/cqlshlib/copyutil.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index 381701e..b015a77 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -492,30 +492,33 @@ class ExportTask(CopyTask):
         ring = shell.get_ring(self.ks).items()
         ring.sort()
 
-        #  If the ring is empty we get the entire ring from the host we are currently connected to
         if not ring:
+            #  If the ring is empty we get the entire ring from the host we are currently connected to
             ranges[(begin_token, end_token)] = make_range_data()
-            return ranges
-
-        first_range_data = None
-        previous = None
-        for token, replicas in ring:
-            if previous is None and token.value == min_token:
-                continue  # avoids looping entire ring
-
-            if previous is None:  # we use it at the end when wrapping around
-                first_range_data = make_range_data(replicas)
-
-            current_range = make_range(previous, token.value)
-            if not current_range:
-                continue
-
-            ranges[current_range] = make_range_data(replicas)
-            previous = token.value
-
-        #  For the last ring interval we query the same replicas that hold the first token in the ring
-        if previous is not None and (not end_token or previous < end_token):
-            ranges[(previous, end_token)] = first_range_data
+        elif len(ring) == 1:
+            #  If there is only one token we get the entire ring from the replicas for that token
+            ranges[(begin_token, end_token)] = make_range_data(ring[0][1])
+        else:
+            # else we loop on the ring
+            first_range_data = None
+            previous = None
+            for token, replicas in ring:
+                if not first_range_data:
+                    first_range_data = make_range_data(replicas)  # we use it at the end when wrapping around
+
+                if token.value == min_token:
+                    continue  # avoids looping entire ring
+
+                current_range = make_range(previous, token.value)
+                if not current_range:
+                    continue
+
+                ranges[current_range] = make_range_data(replicas)
+                previous = token.value
+
+            #  For the last ring interval we query the same replicas that hold the first token in the ring
+            if previous is not None and (not end_token or previous < end_token):
+                ranges[(previous, end_token)] = first_range_data
 
         if not ranges:
             shell.printerr('Found no ranges to query, check begin and end tokens: %s - %s' % (begin_token, end_token))