cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1030472 - in /cassandra/branches/cassandra-0.7: src/java/org/apache/cassandra/dht/ src/java/org/apache/cassandra/service/ test/unit/org/apache/cassandra/service/
Date Wed, 03 Nov 2010 14:07:54 GMT
Author: jbellis
Date: Wed Nov  3 14:07:54 2010
New Revision: 1030472

URL: http://svn.apache.org/viewvc?rev=1030472&view=rev
Log:
fix split of wrapping range centered on a member token
patch by Stu Hood; reviewed by jbellis for CASSANDRA-1700

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

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/AbstractBounds.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/AbstractBounds.java?rev=1030472&r1=1030471&r2=1030472&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/AbstractBounds.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/AbstractBounds.java
Wed Nov  3 14:07:54 2010
@@ -62,14 +62,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
@@ -83,7 +84,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);
 
     public abstract List<AbstractBounds> unwrap();

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/Range.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/Range.java?rev=1030472&r1=1030471&r2=1030472&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/Range.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/dht/Range.java Wed Nov
 3 14:07:54 2010
@@ -195,6 +195,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.7/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1030472&r1=1030471&r2=1030472&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
Wed Nov  3 14:07:54 2010
@@ -583,7 +583,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.7/test/unit/org/apache/cassandra/service/StorageProxyTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/StorageProxyTest.java?rev=1030472&r1=1030471&r2=1030472&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/StorageProxyTest.java
(original)
+++ cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/StorageProxyTest.java
Wed Nov  3 14:07:54 2010
@@ -96,6 +96,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