cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1035656 - in /cassandra/branches/cassandra-0.6: ./ src/java/org/apache/cassandra/dht/ src/java/org/apache/cassandra/service/ test/unit/org/apache/cassandra/service/
Date Tue, 16 Nov 2010 15:15:17 GMT
Author: jbellis
Date: Tue Nov 16 15:15:17 2010
New Revision: 1035656

URL: http://svn.apache.org/viewvc?rev=1035656&view=rev
Log:
backport CASSANDRA-1700

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/AbstractBounds.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/Range.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageProxy.java
    cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/service/StorageProxyTest.java

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=1035656&r1=1035655&r2=1035656&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Tue Nov 16 15:15:17 2010
@@ -2,6 +2,7 @@
  * add clustertool, config-converter, sstablekeys, and schematool 
    Windows .bat files (CASSANDRA-1723)
  * reject range queries received during bootstrap (CASSANDRA-1739)
+ * fix wrapping-range queries on non-minimum token (CASSANDRA-1700)
 
 
 0.6.8

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/AbstractBounds.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/AbstractBounds.java?rev=1035656&r1=1035655&r2=1035656&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/AbstractBounds.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/AbstractBounds.java
Tue Nov 16 15:15:17 2010
@@ -61,13 +61,15 @@ public abstract class AbstractBounds imp
      * Given token T and AbstractBounds ?L,R], returns Pair(?L,T], ?T,R])
      * (where ? means that the same type of Bounds is returned -- Range or Bounds -- as the
original.)
      * The original AbstractBounds must contain the token T.
-     * If R==T, null is returned as the right element of the Pair.
+     * If the split would cause one of the left or right side to be empty, it will be null
in the result pair.
      */
     public Pair<AbstractBounds,AbstractBounds> split(Token token)
     {
         assert contains(token);
-        Range remainder = token.equals(right) ? null : new Range(token, right);
-        return new Pair<AbstractBounds,AbstractBounds>(createFrom(token), remainder);
+        AbstractBounds lb = createFrom(token);
+        // we contain this token, so only one of the left or right can be empty
+        AbstractBounds rb = lb != null && token.equals(right) ? null : new Range(token,
right);
+        return new Pair<AbstractBounds,AbstractBounds>(lb, rb);                   
               
     }
 
     @Override
@@ -81,7 +83,7 @@ public abstract class AbstractBounds imp
 
     public abstract boolean contains(Token start);
 
-    /** @return A clone of this AbstractBounds with a new right Token. */
+    /** @return A clone of this AbstractBounds with a new right Token, or null if an identical
range would be created. */
     public abstract AbstractBounds createFrom(Token right);
 
     private static class AbstractBoundsSerializer implements ICompactSerializer2<AbstractBounds>

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/Range.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/Range.java?rev=1035656&r1=1035655&r2=1035656&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/Range.java (original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/dht/Range.java Tue Nov
16 15:15:17 2010
@@ -189,6 +189,8 @@ public class Range extends AbstractBound
 
     public AbstractBounds createFrom(Token token)
     {
+        if (token.equals(left))
+            return null;
         return new Range(left, token);
     }
 

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1035656&r1=1035655&r2=1035656&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageProxy.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/service/StorageProxy.java
Tue Nov 16 15:15:17 2010
@@ -623,7 +623,8 @@ public class StorageProxy implements Sto
                 // no more splits
                 break;
             Pair<AbstractBounds,AbstractBounds> splits = remainder.split(token);
-            ranges.add(splits.left);
+            if (splits.left != null)
+                ranges.add(splits.left);
             remainder = splits.right;
         }
         if (remainder != null)

Modified: cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/service/StorageProxyTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/service/StorageProxyTest.java?rev=1035656&r1=1035655&r2=1035656&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/service/StorageProxyTest.java
(original)
+++ cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/service/StorageProxyTest.java
Tue Nov 16 15:15:17 2010
@@ -95,6 +95,8 @@ public class StorageProxyTest extends Cl
         // full wraps
         testGRR(range("0", "0"), range("0", "1"), range("1", "6"), range("6", ""), range("",
"0"));
         testGRR(range("", ""), range("", "1"), range("1", "6"), range("6", ""));
+        // wrap on member token
+        testGRR(range("6", "6"), range("6", ""), range("", "1"), range("1", "6"));
         // end wrapped
         testGRR(range("5", ""), range("5", "6"), range("6", ""));
     }



Mime
View raw message