cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject [2/2] git commit: Clean up generics in dht package
Date Mon, 03 Nov 2014 19:09:51 GMT
Clean up generics in dht package

Patch by blambov, reviewed by jmckenzie for CASSANDRA-8171


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

Branch: refs/heads/cassandra-2.1
Commit: ad84e4d7ee02f2ae5f45d5d5d2cb50c6b10f3836
Parents: 623aa6f
Author: Branimir Lambov <branimir.lambov@datastax.com>
Authored: Mon Nov 3 13:04:37 2014 -0600
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Mon Nov 3 13:04:37 2014 -0600

----------------------------------------------------------------------
 .../org/apache/cassandra/client/RingCache.java  |   8 +-
 .../cassandra/config/DatabaseDescriptor.java    |   6 +-
 .../apache/cassandra/cql/QueryProcessor.java    |   2 +-
 .../cql3/statements/SelectStatement.java        |   4 +-
 .../apache/cassandra/db/BatchlogManager.java    |   2 +-
 .../cassandra/db/HintedHandOffManager.java      |   2 +-
 .../db/marshal/LocalByPartionerType.java        |   7 +-
 .../apache/cassandra/dht/AbstractBounds.java    |   4 +-
 .../dht/AbstractByteOrderedPartitioner.java     |  20 +-
 .../cassandra/dht/AbstractPartitioner.java      |   5 +-
 .../org/apache/cassandra/dht/AbstractToken.java |  53 +++++
 .../apache/cassandra/dht/BigIntegerToken.java   |   6 +-
 src/java/org/apache/cassandra/dht/Bounds.java   |   6 +-
 .../cassandra/dht/ByteOrderedPartitioner.java   |   4 +-
 .../org/apache/cassandra/dht/BytesToken.java    |   5 +-
 .../apache/cassandra/dht/ExcludingBounds.java   |   4 +-
 .../org/apache/cassandra/dht/IPartitioner.java  |  12 +-
 .../cassandra/dht/IncludingExcludingBounds.java |   6 +-
 .../apache/cassandra/dht/LocalPartitioner.java  |   6 +-
 .../org/apache/cassandra/dht/LocalToken.java    |   6 +-
 .../org/apache/cassandra/dht/LongToken.java     |   6 +-
 .../cassandra/dht/Murmur3Partitioner.java       |  25 ++-
 .../dht/OrderPreservingPartitioner.java         |  20 +-
 .../apache/cassandra/dht/RandomPartitioner.java |  18 +-
 src/java/org/apache/cassandra/dht/Range.java    |  39 ++--
 .../org/apache/cassandra/dht/RangeStreamer.java |   2 +-
 .../org/apache/cassandra/dht/RingPosition.java  |   2 +-
 .../org/apache/cassandra/dht/StringToken.java   |   6 +-
 src/java/org/apache/cassandra/dht/Token.java    |  52 +----
 .../apache/cassandra/gms/TokenSerializer.java   |   2 +-
 .../cassandra/io/sstable/SSTableWriter.java     |   2 +-
 .../apache/cassandra/service/StorageProxy.java  |   2 +-
 .../cassandra/thrift/CassandraServer.java       |   4 +-
 .../apache/cassandra/tools/SSTableExport.java   |   2 +-
 .../apache/cassandra/tools/SSTableImport.java   |   6 +-
 .../cassandra/db/ColumnFamilyStoreTest.java     |   2 +-
 .../apache/cassandra/db/KeyCollisionTest.java   | 217 -------------------
 .../apache/cassandra/dht/BootStrapperTest.java  |   2 +-
 .../dht/ByteOrderedPartitionerTest.java         |   2 +-
 .../apache/cassandra/dht/KeyCollisionTest.java  | 217 +++++++++++++++++++
 .../cassandra/dht/Murmur3PartitionerTest.java   |   4 +-
 .../dht/OrderPreservingPartitionerTest.java     |   2 +-
 .../cassandra/dht/PartitionerTestCase.java      |  12 +-
 .../cassandra/dht/RandomPartitionerTest.java    |   2 +-
 .../org/apache/cassandra/dht/RangeTest.java     |   4 +-
 45 files changed, 430 insertions(+), 390 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/client/RingCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/client/RingCache.java b/src/java/org/apache/cassandra/client/RingCache.java
index c3dbda5..d58d5d9 100644
--- a/src/java/org/apache/cassandra/client/RingCache.java
+++ b/src/java/org/apache/cassandra/client/RingCache.java
@@ -47,7 +47,7 @@ public class RingCache
 {
     final private static Logger logger = LoggerFactory.getLogger(RingCache.class);
 
-    private final IPartitioner<?> partitioner;
+    private final IPartitioner partitioner;
     private final Configuration conf;
 
     private Multimap<Range<Token>, InetAddress> rangeMap;
@@ -73,8 +73,8 @@ public class RingCache
 
             for (TokenRange range : ring)
             {
-                Token<?> left = partitioner.getTokenFactory().fromString(range.start_token);
-                Token<?> right = partitioner.getTokenFactory().fromString(range.end_token);
+                Token left = partitioner.getTokenFactory().fromString(range.start_token);
+                Token right = partitioner.getTokenFactory().fromString(range.end_token);
                 Range<Token> r = new Range<Token>(left, right, partitioner);
                 for (String host : range.endpoints)
                 {
@@ -112,7 +112,7 @@ public class RingCache
     public Range<Token> getRange(ByteBuffer key)
     {
         // TODO: naive linear search of the token map
-        Token<?> t = partitioner.getToken(key);
+        Token t = partitioner.getToken(key);
         for (Range<Token> range : rangeMap.keySet())
             if (range.contains(t))
                 return range;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index ba84610..2ec0172 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -93,7 +93,7 @@ public class DatabaseDescriptor
     private static IInternodeAuthenticator internodeAuthenticator;
 
     /* Hashing strategy Random or OPHF */
-    private static IPartitioner<?> partitioner;
+    private static IPartitioner partitioner;
     private static String paritionerName;
 
     private static Config.DiskAccessMode indexAccessMode;
@@ -739,7 +739,7 @@ public class DatabaseDescriptor
         }
     }
 
-    public static IPartitioner<?> getPartitioner()
+    public static IPartitioner getPartitioner()
     {
         return partitioner;
     }
@@ -750,7 +750,7 @@ public class DatabaseDescriptor
     }
 
     /* For tests ONLY, don't use otherwise or all hell will break loose */
-    public static void setPartitioner(IPartitioner<?> newPartitioner)
+    public static void setPartitioner(IPartitioner newPartitioner)
     {
         partitioner = newPartitioner;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/cql/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/QueryProcessor.java b/src/java/org/apache/cassandra/cql/QueryProcessor.java
index 3c1d555..0b9ba2e 100644
--- a/src/java/org/apache/cassandra/cql/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql/QueryProcessor.java
@@ -159,7 +159,7 @@ public class QueryProcessor
     private static List<org.apache.cassandra.db.Row> multiRangeSlice(CFMetaData metadata, SelectStatement select, List<ByteBuffer> variables, long now)
     throws ReadTimeoutException, UnavailableException, InvalidRequestException
     {
-        IPartitioner<?> p = StorageService.getPartitioner();
+        IPartitioner p = StorageService.getPartitioner();
 
         AbstractType<?> keyType = Schema.instance.getCFMetaData(metadata.ksName, select.getColumnFamily()).getKeyValidator();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 233f3db..3d57f4c 100644
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@ -374,7 +374,7 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
 
     private AbstractBounds<RowPosition> getKeyBounds(QueryOptions options) throws InvalidRequestException
     {
-        IPartitioner<?> p = StorageService.getPartitioner();
+        IPartitioner p = StorageService.getPartitioner();
 
         if (onToken)
         {
@@ -632,7 +632,7 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
         return buildBound(b, cfm.partitionKeyColumns(), keyRestrictions, false, cfm.getKeyValidatorAsCType(), options).get(0).toByteBuffer();
     }
 
-    private Token getTokenBound(Bound b, QueryOptions options, IPartitioner<?> p) throws InvalidRequestException
+    private Token getTokenBound(Bound b, QueryOptions options, IPartitioner p) throws InvalidRequestException
     {
         assert onToken;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/db/BatchlogManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/BatchlogManager.java b/src/java/org/apache/cassandra/db/BatchlogManager.java
index 18d9a17..279f876 100644
--- a/src/java/org/apache/cassandra/db/BatchlogManager.java
+++ b/src/java/org/apache/cassandra/db/BatchlogManager.java
@@ -378,7 +378,7 @@ public class BatchlogManager implements BatchlogManagerMBean
         {
             Set<InetAddress> liveEndpoints = new HashSet<>();
             String ks = mutation.getKeyspaceName();
-            Token<?> tk = StorageService.getPartitioner().getToken(mutation.key());
+            Token tk = StorageService.getPartitioner().getToken(mutation.key());
 
             for (InetAddress endpoint : Iterables.concat(StorageService.instance.getNaturalEndpoints(ks, tk),
                                                          StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, ks)))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index 593bebc..a1920ae 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -591,7 +591,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
                                                           columnCount);
 
         // From keys "" to ""...
-        IPartitioner<?> partitioner = StorageService.getPartitioner();
+        IPartitioner partitioner = StorageService.getPartitioner();
         RowPosition minPos = partitioner.getMinimumToken().minKeyBound();
         Range<RowPosition> range = new Range<RowPosition>(minPos, minPos);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java b/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
index 60bce9d..d1aaac0 100644
--- a/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
+++ b/src/java/org/apache/cassandra/db/marshal/LocalByPartionerType.java
@@ -24,16 +24,15 @@ import org.apache.cassandra.serializers.MarshalException;
 
 import org.apache.cassandra.db.RowPosition;
 import org.apache.cassandra.dht.IPartitioner;
-import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
 /** for sorting columns representing row keys in the row ordering as determined by a partitioner.
  * Not intended for user-defined CFs, and will in fact error out if used with such. */
-public class LocalByPartionerType<T extends Token> extends AbstractType<ByteBuffer>
+public class LocalByPartionerType extends AbstractType<ByteBuffer>
 {
-    private final IPartitioner<T> partitioner;
+    private final IPartitioner partitioner;
 
-    public LocalByPartionerType(IPartitioner<T> partitioner)
+    public LocalByPartionerType(IPartitioner partitioner)
     {
         this.partitioner = partitioner;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/AbstractBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractBounds.java b/src/java/org/apache/cassandra/dht/AbstractBounds.java
index b69f5ee..90eb6b5 100644
--- a/src/java/org/apache/cassandra/dht/AbstractBounds.java
+++ b/src/java/org/apache/cassandra/dht/AbstractBounds.java
@@ -30,7 +30,7 @@ import org.apache.cassandra.io.IVersionedSerializer;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.utils.Pair;
 
-public abstract class AbstractBounds<T extends RingPosition> implements Serializable
+public abstract class AbstractBounds<T extends RingPosition<T>> implements Serializable
 {
     private static final long serialVersionUID = 1L;
     public static final AbstractBoundsSerializer serializer = new AbstractBoundsSerializer();
@@ -160,7 +160,7 @@ public abstract class AbstractBounds<T extends RingPosition> implements Serializ
             if (!isToken)
                 kind = -(kind+1);
 
-            RingPosition left, right;
+            RingPosition<?> left, right;
             if (isToken)
             {
                 left = Token.serializer.deserialize(in);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java b/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
index 94be94d..88326a8 100644
--- a/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/AbstractByteOrderedPartitioner.java
@@ -35,7 +35,7 @@ import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Hex;
 import org.apache.cassandra.utils.Pair;
 
-public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner<BytesToken>
+public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
 {
     public static final BytesToken MINIMUM = new BytesToken(ArrayUtils.EMPTY_BYTE_ARRAY);
 
@@ -46,8 +46,10 @@ public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
         return new BufferDecoratedKey(getToken(key), key);
     }
 
-    public BytesToken midpoint(Token ltoken, Token rtoken)
+    public BytesToken midpoint(Token lt, Token rt)
     {
+        AbstractToken<?> ltoken = (AbstractToken<?>) lt;
+        AbstractToken<?> rtoken = (AbstractToken<?>) rt;
         int ll,rl;
         ByteBuffer lb,rb;
 
@@ -127,19 +129,21 @@ public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
         return new BytesToken(buffer);
     }
 
-    private final Token.TokenFactory<byte[]> tokenFactory = new Token.TokenFactory<byte[]>() {
-        public ByteBuffer toByteArray(Token<byte[]> bytesToken)
+    private final Token.TokenFactory tokenFactory = new Token.TokenFactory() {
+        public ByteBuffer toByteArray(Token token)
         {
+            BytesToken bytesToken = (BytesToken) token;
             return ByteBuffer.wrap(bytesToken.token);
         }
 
-        public Token<byte[]> fromByteArray(ByteBuffer bytes)
+        public Token fromByteArray(ByteBuffer bytes)
         {
             return new BytesToken(bytes);
         }
 
-        public String toString(Token<byte[]> bytesToken)
+        public String toString(Token token)
         {
+            BytesToken bytesToken = (BytesToken) token;
             return Hex.bytesToHex(bytesToken.token);
         }
 
@@ -157,7 +161,7 @@ public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
             }
         }
 
-        public Token<byte[]> fromString(String string)
+        public Token fromString(String string)
         {
             if (string.length() % 2 == 1)
                 string = "0" + string;
@@ -165,7 +169,7 @@ public abstract class AbstractByteOrderedPartitioner extends AbstractPartitioner
         }
     };
 
-    public Token.TokenFactory<byte[]> getTokenFactory()
+    public Token.TokenFactory getTokenFactory()
     {
         return tokenFactory;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/AbstractPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractPartitioner.java b/src/java/org/apache/cassandra/dht/AbstractPartitioner.java
index 1ad4ff8..ed077c9 100644
--- a/src/java/org/apache/cassandra/dht/AbstractPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/AbstractPartitioner.java
@@ -17,9 +17,10 @@
  */
 package org.apache.cassandra.dht;
 
-public abstract class AbstractPartitioner<T extends Token> implements IPartitioner<T>
+abstract class AbstractPartitioner implements IPartitioner
 {
-    public <R extends RingPosition> R minValue(Class<R> klass)
+    @SuppressWarnings("unchecked")
+    public <R extends RingPosition<R>> R minValue(Class<R> klass)
     {
         Token minToken = getMinimumToken();
         if (minToken.getClass().equals(klass))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/AbstractToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/AbstractToken.java b/src/java/org/apache/cassandra/dht/AbstractToken.java
new file mode 100644
index 0000000..9622d38
--- /dev/null
+++ b/src/java/org/apache/cassandra/dht/AbstractToken.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.dht;
+
+abstract class AbstractToken<C> extends Token
+{
+    private static final long serialVersionUID = 1L;
+
+    final C token;   // Package-private to allow access from subtypes, which should all reside in the dht package.
+
+    protected AbstractToken(C token)
+    {
+        this.token = token;
+    }
+
+    @Override
+    public String toString()
+    {
+        return token.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (this == obj)
+            return true;
+        if (obj == null || this.getClass() != obj.getClass())
+            return false;
+
+        return token.equals(((AbstractToken<?>)obj).token);
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return token.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/BigIntegerToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/BigIntegerToken.java b/src/java/org/apache/cassandra/dht/BigIntegerToken.java
index 6884c4f..0c685db 100644
--- a/src/java/org/apache/cassandra/dht/BigIntegerToken.java
+++ b/src/java/org/apache/cassandra/dht/BigIntegerToken.java
@@ -19,7 +19,7 @@ package org.apache.cassandra.dht;
 
 import java.math.BigInteger;
 
-public class BigIntegerToken extends Token<BigInteger>
+public class BigIntegerToken extends AbstractToken<BigInteger>
 {
     static final long serialVersionUID = -5833589141319293006L;
 
@@ -33,8 +33,8 @@ public class BigIntegerToken extends Token<BigInteger>
         this(new BigInteger(token));
     }
 
-    public int compareTo(Token<BigInteger> o)
+    public int compareTo(Token o)
     {
-        return token.compareTo(o.token);
+        return token.compareTo(((BigIntegerToken) o).token);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/Bounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Bounds.java b/src/java/org/apache/cassandra/dht/Bounds.java
index a27f6b1..396fc30 100644
--- a/src/java/org/apache/cassandra/dht/Bounds.java
+++ b/src/java/org/apache/cassandra/dht/Bounds.java
@@ -27,7 +27,7 @@ import org.apache.cassandra.utils.Pair;
 /**
  * AbstractBounds containing both its endpoints: [left, right].  Used by "classic" by-key range scans.
  */
-public class Bounds<T extends RingPosition> extends AbstractBounds<T>
+public class Bounds<T extends RingPosition<T>> extends AbstractBounds<T>
 {
     public Bounds(T left, T right)
     {
@@ -78,7 +78,7 @@ public class Bounds<T extends RingPosition> extends AbstractBounds<T>
     {
         if (!(o instanceof Bounds))
             return false;
-        Bounds<T> rhs = (Bounds<T>)o;
+        Bounds<?> rhs = (Bounds<?>)o;
         return left.equals(rhs.left) && right.equals(rhs.right);
     }
 
@@ -106,11 +106,13 @@ public class Bounds<T extends RingPosition> extends AbstractBounds<T>
         return new Bounds<RowPosition>(left.minKeyBound(partitioner), right.maxKeyBound(partitioner), partitioner);
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<RowPosition> toRowBounds()
     {
         return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right, partitioner) : (Bounds<RowPosition>)this;
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<Token> toTokenBounds()
     {
         return (left instanceof RowPosition) ? new Bounds<Token>(((RowPosition)left).getToken(), ((RowPosition)right).getToken(), partitioner) : (Bounds<Token>)this;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java b/src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java
index f46026f..888ef35 100644
--- a/src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java
@@ -33,8 +33,8 @@ public class ByteOrderedPartitioner extends AbstractByteOrderedPartitioner
     }
 
     @Override
-    public long getHeapSizeOf(BytesToken token)
+    public long getHeapSizeOf(Token token)
     {
-        return EMPTY_SIZE + ObjectSizes.sizeOfArray(token.token);
+        return EMPTY_SIZE + ObjectSizes.sizeOfArray(((BytesToken) token).token);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/BytesToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/BytesToken.java b/src/java/org/apache/cassandra/dht/BytesToken.java
index f2f9eab..f29af39 100644
--- a/src/java/org/apache/cassandra/dht/BytesToken.java
+++ b/src/java/org/apache/cassandra/dht/BytesToken.java
@@ -24,7 +24,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Hex;
 
-public class BytesToken extends Token<byte[]>
+public class BytesToken extends AbstractToken<byte[]>
 {
     static final long serialVersionUID = -2630749093733680626L;
 
@@ -44,8 +44,9 @@ public class BytesToken extends Token<byte[]>
         return Hex.bytesToHex(token);
     }
 
-    public int compareTo(Token<byte[]> o)
+    public int compareTo(Token other)
     {
+        BytesToken o = (BytesToken) other;
         return FBUtilities.compareUnsigned(token, o.token, 0, 0, token.length, o.token.length);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/ExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/ExcludingBounds.java b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
index 5f46015..33e48b6 100644
--- a/src/java/org/apache/cassandra/dht/ExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
@@ -27,7 +27,7 @@ import org.apache.cassandra.utils.Pair;
 /**
  * AbstractBounds containing neither of its endpoints: (left, right).  Used by CQL key > X AND key < Y range scans.
  */
-public class ExcludingBounds<T extends RingPosition> extends AbstractBounds<T>
+public class ExcludingBounds<T extends RingPosition<T>> extends AbstractBounds<T>
 {
     public ExcludingBounds(T left, T right)
     {
@@ -95,11 +95,13 @@ public class ExcludingBounds<T extends RingPosition> extends AbstractBounds<T>
         return new ExcludingBounds<RowPosition>(left.maxKeyBound(partitioner), right.minKeyBound(partitioner), partitioner);
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<RowPosition> toRowBounds()
     {
         return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right, partitioner) : (ExcludingBounds<RowPosition>)this;
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<Token> toTokenBounds()
     {
         return (left instanceof RowPosition) ? new ExcludingBounds<Token>(((RowPosition)left).getToken(), ((RowPosition)right).getToken(), partitioner) : (ExcludingBounds<Token>)this;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/IPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/IPartitioner.java b/src/java/org/apache/cassandra/dht/IPartitioner.java
index 0ef242f..6451535 100644
--- a/src/java/org/apache/cassandra/dht/IPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/IPartitioner.java
@@ -24,7 +24,7 @@ import java.util.Map;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.marshal.AbstractType;
 
-public interface IPartitioner<T extends Token>
+public interface IPartitioner
 {
     /**
      * Transform key to object representation of the on-disk format.
@@ -46,26 +46,26 @@ public interface IPartitioner<T extends Token>
      * @return A Token smaller than all others in the range that is being partitioned.
      * Not legal to assign to a node or key.  (But legal to use in range scans.)
      */
-    public T getMinimumToken();
+    public Token getMinimumToken();
 
     /**
      * @return a Token that can be used to route a given key
      * (This is NOT a method to create a Token from its string representation;
      * for that, use TokenFactory.fromString.)
      */
-    public T getToken(ByteBuffer key);
+    public Token getToken(ByteBuffer key);
 
     /**
      *
      * @param token
      * @return the on-heap memory used by the provided token
      */
-    public long getHeapSizeOf(T token);
+    public long getHeapSizeOf(Token token);
 
     /**
      * @return a randomly generated token
      */
-    public T getRandomToken();
+    public Token getRandomToken();
 
     public Token.TokenFactory getTokenFactory();
 
@@ -86,5 +86,5 @@ public interface IPartitioner<T extends Token>
 
     public AbstractType<?> getTokenValidator();
 
-    public <R extends RingPosition> R minValue(Class<R> klass);
+    public <R extends RingPosition<R>> R minValue(Class<R> klass);
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
index 561555b..e8e9c74 100644
--- a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
@@ -27,7 +27,7 @@ import org.apache.cassandra.utils.Pair;
 /**
  * AbstractBounds containing only its left endpoint: [left, right).  Used by CQL key >= X AND key < Y range scans.
  */
-public class IncludingExcludingBounds<T extends RingPosition> extends AbstractBounds<T>
+public class IncludingExcludingBounds<T extends RingPosition<T>> extends AbstractBounds<T>
 {
     public IncludingExcludingBounds(T left, T right)
     {
@@ -66,7 +66,7 @@ public class IncludingExcludingBounds<T extends RingPosition> extends AbstractBo
     {
         if (!(o instanceof IncludingExcludingBounds))
             return false;
-        IncludingExcludingBounds<T> rhs = (IncludingExcludingBounds<T>)o;
+        IncludingExcludingBounds<?> rhs = (IncludingExcludingBounds<?>)o;
         return left.equals(rhs.left) && right.equals(rhs.right);
     }
 
@@ -94,11 +94,13 @@ public class IncludingExcludingBounds<T extends RingPosition> extends AbstractBo
         return new IncludingExcludingBounds<RowPosition>(left.maxKeyBound(partitioner), right.minKeyBound(partitioner), partitioner);
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<RowPosition> toRowBounds()
     {
         return (left instanceof Token) ? makeRowBounds((Token)left, (Token)right, partitioner) : (IncludingExcludingBounds<RowPosition>)this;
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<Token> toTokenBounds()
     {
         return (left instanceof RowPosition) ? new IncludingExcludingBounds<Token>(((RowPosition)left).getToken(), ((RowPosition)right).getToken(), partitioner) : (IncludingExcludingBounds<Token>)this;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/LocalPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/LocalPartitioner.java b/src/java/org/apache/cassandra/dht/LocalPartitioner.java
index c32e792..1cbeba4 100644
--- a/src/java/org/apache/cassandra/dht/LocalPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/LocalPartitioner.java
@@ -28,7 +28,7 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.ObjectSizes;
 
-public class LocalPartitioner extends AbstractPartitioner<LocalToken>
+public class LocalPartitioner extends AbstractPartitioner
 {
     private static final long EMPTY_SIZE = ObjectSizes.measure(new LocalToken(null, null));
 
@@ -59,9 +59,9 @@ public class LocalPartitioner extends AbstractPartitioner<LocalToken>
         return new LocalToken(comparator, key);
     }
 
-    public long getHeapSizeOf(LocalToken token)
+    public long getHeapSizeOf(Token token)
     {
-        return EMPTY_SIZE + ObjectSizes.sizeOnHeapOf(token.token);
+        return EMPTY_SIZE + ObjectSizes.sizeOnHeapOf(((LocalToken) token).token);
     }
 
     public LocalToken getRandomToken()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/LocalToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/LocalToken.java b/src/java/org/apache/cassandra/dht/LocalToken.java
index 1453a14..6a0db2e 100644
--- a/src/java/org/apache/cassandra/dht/LocalToken.java
+++ b/src/java/org/apache/cassandra/dht/LocalToken.java
@@ -21,7 +21,7 @@ import java.nio.ByteBuffer;
 
 import org.apache.cassandra.db.marshal.AbstractType;
 
-public class LocalToken extends Token<ByteBuffer>
+public class LocalToken extends AbstractToken<ByteBuffer>
 {
     static final long serialVersionUID = 8437543776403014875L;
 
@@ -39,9 +39,9 @@ public class LocalToken extends Token<ByteBuffer>
         return comparator.getString(token);
     }
 
-    public int compareTo(Token<ByteBuffer> o)
+    public int compareTo(Token o)
     {
-        return comparator.compare(token, o.token);
+        return comparator.compare(token, ((LocalToken) o).token);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/LongToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/LongToken.java b/src/java/org/apache/cassandra/dht/LongToken.java
index 56799b6..8d4f721 100644
--- a/src/java/org/apache/cassandra/dht/LongToken.java
+++ b/src/java/org/apache/cassandra/dht/LongToken.java
@@ -17,7 +17,7 @@
  */
 package org.apache.cassandra.dht;
 
-public class LongToken extends Token<Long>
+public class LongToken extends AbstractToken<Long>
 {
     static final long serialVersionUID = -5833580143318243006L;
 
@@ -26,8 +26,8 @@ public class LongToken extends Token<Long>
         super(token);
     }
 
-    public int compareTo(Token<Long> o)
+    public int compareTo(Token o)
     {
-        return token.compareTo(o.token);
+        return token.compareTo(((LongToken) o).token);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java b/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java
index 2bb0423..995a434 100644
--- a/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java
+++ b/src/java/org/apache/cassandra/dht/Murmur3Partitioner.java
@@ -32,14 +32,13 @@ import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.LongType;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.MurmurHash;
 import org.apache.cassandra.utils.ObjectSizes;
 
 /**
  * This class generates a BigIntegerToken using a Murmur3 hash.
  */
-public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
+public class Murmur3Partitioner extends AbstractPartitioner
 {
     public static final LongToken MINIMUM = new LongToken(Long.MIN_VALUE);
     public static final long MAXIMUM = Long.MAX_VALUE;
@@ -99,7 +98,7 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
         return new LongToken(normalize(hash[0]));
     }
 
-    public long getHeapSizeOf(LongToken token)
+    public long getHeapSizeOf(Token token)
     {
         return HEAP_SIZE;
     }
@@ -123,7 +122,7 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
     public Map<Token, Float> describeOwnership(List<Token> sortedTokens)
     {
         Map<Token, Float> ownerships = new HashMap<Token, Float>();
-        Iterator i = sortedTokens.iterator();
+        Iterator<Token> i = sortedTokens.iterator();
 
         // 0-case
         if (!i.hasNext())
@@ -136,7 +135,7 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
         {
             final BigInteger ri = BigInteger.valueOf(MAXIMUM).subtract(BigInteger.valueOf(MINIMUM.token + 1));  //  (used for addition later)
             final BigDecimal r  = new BigDecimal(ri);
-            Token start = (Token) i.next();BigInteger ti = BigInteger.valueOf(((LongToken)start).token);  // The first token and its value
+            Token start = i.next();BigInteger ti = BigInteger.valueOf(((LongToken)start).token);  // The first token and its value
             Token t; BigInteger tim1 = ti;                                                                // The last token and its value (after loop)
 
             while (i.hasNext())
@@ -155,25 +154,27 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
         return ownerships;
     }
 
-    public Token.TokenFactory<Long> getTokenFactory()
+    public Token.TokenFactory getTokenFactory()
     {
         return tokenFactory;
     }
 
-    private final Token.TokenFactory<Long> tokenFactory = new Token.TokenFactory<Long>()
+    private final Token.TokenFactory tokenFactory = new Token.TokenFactory()
     {
-        public ByteBuffer toByteArray(Token<Long> longToken)
+        public ByteBuffer toByteArray(Token token)
         {
+            LongToken longToken = (LongToken) token;
             return ByteBufferUtil.bytes(longToken.token);
         }
 
-        public Token<Long> fromByteArray(ByteBuffer bytes)
+        public Token fromByteArray(ByteBuffer bytes)
         {
             return new LongToken(ByteBufferUtil.toLong(bytes));
         }
 
-        public String toString(Token<Long> longToken)
+        public String toString(Token token)
         {
+            LongToken longToken = (LongToken) token;
             return longToken.token.toString();
         }
 
@@ -181,7 +182,7 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
         {
             try
             {
-                Long i = Long.valueOf(token);
+                Long.valueOf(token);
             }
             catch (NumberFormatException e)
             {
@@ -189,7 +190,7 @@ public class Murmur3Partitioner extends AbstractPartitioner<LongToken>
             }
         }
 
-        public Token<Long> fromString(String string)
+        public Token fromString(String string)
         {
             try
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java b/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
index ad1ffaa..44d98e0 100644
--- a/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
@@ -35,7 +35,7 @@ import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.ObjectSizes;
 import org.apache.cassandra.utils.Pair;
 
-public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
+public class OrderPreservingPartitioner extends AbstractPartitioner
 {
     public static final StringToken MINIMUM = new StringToken("");
 
@@ -113,14 +113,15 @@ public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
         return new StringToken(buffer.toString());
     }
 
-    private final Token.TokenFactory<String> tokenFactory = new Token.TokenFactory<String>()
+    private final Token.TokenFactory tokenFactory = new Token.TokenFactory()
     {
-        public ByteBuffer toByteArray(Token<String> stringToken)
+        public ByteBuffer toByteArray(Token token)
         {
+            StringToken stringToken = (StringToken) token;
             return ByteBufferUtil.bytes(stringToken.token);
         }
 
-        public Token<String> fromByteArray(ByteBuffer bytes)
+        public Token fromByteArray(ByteBuffer bytes)
         {
             try
             {
@@ -132,8 +133,9 @@ public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
             }
         }
 
-        public String toString(Token<String> stringToken)
+        public String toString(Token token)
         {
+            StringToken stringToken = (StringToken) token;
             return stringToken.token;
         }
 
@@ -143,13 +145,13 @@ public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
                 throw new ConfigurationException("Tokens may not contain the character " + VersionedValue.DELIMITER_STR);
         }
 
-        public Token<String> fromString(String string)
+        public Token fromString(String string)
         {
             return new StringToken(string);
         }
     };
 
-    public Token.TokenFactory<String> getTokenFactory()
+    public Token.TokenFactory getTokenFactory()
     {
         return tokenFactory;
     }
@@ -173,9 +175,9 @@ public class OrderPreservingPartitioner extends AbstractPartitioner<StringToken>
         return new StringToken(skey);
     }
 
-    public long getHeapSizeOf(StringToken token)
+    public long getHeapSizeOf(Token token)
     {
-        return EMPTY_SIZE + ObjectSizes.sizeOf(token.token);
+        return EMPTY_SIZE + ObjectSizes.sizeOf(((StringToken) token).token);
     }
 
     public Map<Token, Float> describeOwnership(List<Token> sortedTokens)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/RandomPartitioner.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/RandomPartitioner.java b/src/java/org/apache/cassandra/dht/RandomPartitioner.java
index 3ccd086..fa44f47 100644
--- a/src/java/org/apache/cassandra/dht/RandomPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/RandomPartitioner.java
@@ -36,7 +36,7 @@ import org.apache.cassandra.utils.Pair;
 /**
  * This class generates a BigIntegerToken using MD5 hash.
  */
-public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken>
+public class RandomPartitioner extends AbstractPartitioner
 {
     public static final BigInteger ZERO = new BigInteger("0");
     public static final BigIntegerToken MINIMUM = new BigIntegerToken("-1");
@@ -72,19 +72,21 @@ public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken>
         return new BigIntegerToken(token);
     }
 
-    private final Token.TokenFactory<BigInteger> tokenFactory = new Token.TokenFactory<BigInteger>() {
-        public ByteBuffer toByteArray(Token<BigInteger> bigIntegerToken)
+    private final Token.TokenFactory tokenFactory = new Token.TokenFactory() {
+        public ByteBuffer toByteArray(Token token)
         {
+            BigIntegerToken bigIntegerToken = (BigIntegerToken) token;
             return ByteBuffer.wrap(bigIntegerToken.token.toByteArray());
         }
 
-        public Token<BigInteger> fromByteArray(ByteBuffer bytes)
+        public Token fromByteArray(ByteBuffer bytes)
         {
             return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes)));
         }
 
-        public String toString(Token<BigInteger> bigIntegerToken)
+        public String toString(Token token)
         {
+            BigIntegerToken bigIntegerToken = (BigIntegerToken) token;
             return bigIntegerToken.token.toString();
         }
 
@@ -104,13 +106,13 @@ public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken>
             }
         }
 
-        public Token<BigInteger> fromString(String string)
+        public Token fromString(String string)
         {
             return new BigIntegerToken(new BigInteger(string));
         }
     };
 
-    public Token.TokenFactory<BigInteger> getTokenFactory()
+    public Token.TokenFactory getTokenFactory()
     {
         return tokenFactory;
     }
@@ -127,7 +129,7 @@ public class RandomPartitioner extends AbstractPartitioner<BigIntegerToken>
         return new BigIntegerToken(FBUtilities.hashToBigInteger(key));
     }
 
-    public long getHeapSizeOf(BigIntegerToken token)
+    public long getHeapSizeOf(Token token)
     {
         return EMPTY_SIZE;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/Range.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Range.java b/src/java/org/apache/cassandra/dht/Range.java
index 5f4251b..44b76d5 100644
--- a/src/java/org/apache/cassandra/dht/Range.java
+++ b/src/java/org/apache/cassandra/dht/Range.java
@@ -21,7 +21,6 @@ import java.io.Serializable;
 import java.util.*;
 
 import org.apache.commons.lang3.ObjectUtils;
-
 import org.apache.cassandra.db.RowPosition;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.Pair;
@@ -33,7 +32,7 @@ import org.apache.cassandra.utils.Pair;
  *
  * Used by the partitioner and by map/reduce by-token range scans.
  */
-public class Range<T extends RingPosition> extends AbstractBounds<T> implements Comparable<Range<T>>, Serializable
+public class Range<T extends RingPosition<T>> extends AbstractBounds<T> implements Comparable<Range<T>>, Serializable
 {
     public static final long serialVersionUID = 1L;
 
@@ -47,7 +46,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         super(left, right, partitioner);
     }
 
-    public static <T extends RingPosition> boolean contains(T left, T right, T point)
+    public static <T extends RingPosition<T>> boolean contains(T left, T right, T point)
     {
         if (isWrapAround(left, right))
         {
@@ -124,9 +123,9 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
     {
         // implemented for cleanup compaction membership test, so only Range + Bounds are supported for now
         if (that instanceof Range)
-            return intersects((Range) that);
+            return intersects((Range<T>) that);
         if (that instanceof Bounds)
-            return intersects((Bounds) that);
+            return intersects((Bounds<T>) that);
         throw new UnsupportedOperationException("Intersection is only supported for Bounds and Range objects; found " + that.getClass());
     }
 
@@ -142,12 +141,13 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         return contains(that.left) || (!that.left.equals(that.right) && intersects(new Range<T>(that.left, that.right)));
     }
 
-    public static <T extends RingPosition> Set<Range<T>> rangeSet(Range<T> ... ranges)
+    @SafeVarargs
+    public static <T extends RingPosition<T>> Set<Range<T>> rangeSet(Range<T> ... ranges)
     {
         return Collections.unmodifiableSet(new HashSet<Range<T>>(Arrays.asList(ranges)));
     }
 
-    public static <T extends RingPosition> Set<Range<T>> rangeSet(Range<T> range)
+    public static <T extends RingPosition<T>> Set<Range<T>> rangeSet(Range<T> range)
     {
         return Collections.singleton(range);
     }
@@ -172,8 +172,8 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
             // neither wraps.  the straightforward case.
             if (!(left.compareTo(that.right) < 0 && that.left.compareTo(right) < 0))
                 return Collections.emptySet();
-            return rangeSet(new Range<T>((T)ObjectUtils.max(this.left, that.left),
-                                         (T)ObjectUtils.min(this.right, that.right),
+            return rangeSet(new Range<T>(ObjectUtils.max(this.left, that.left),
+                                         ObjectUtils.min(this.right, that.right),
                                          partitioner));
         }
         if (thiswraps && thatwraps)
@@ -198,7 +198,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         return intersectionOneWrapping(that, this);
     }
 
-    private static <T extends RingPosition> Set<Range<T>> intersectionBothWrapping(Range<T> first, Range<T> that)
+    private static <T extends RingPosition<T>> Set<Range<T>> intersectionBothWrapping(Range<T> first, Range<T> that)
     {
         Set<Range<T>> intersection = new HashSet<Range<T>>(2);
         if (that.right.compareTo(first.left) > 0)
@@ -207,7 +207,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         return Collections.unmodifiableSet(intersection);
     }
 
-    private static <T extends RingPosition> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other)
+    private static <T extends RingPosition<T>> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other)
     {
         Set<Range<T>> intersection = new HashSet<Range<T>>(2);
         if (other.contains(wrapping.right))
@@ -232,6 +232,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
 
     public List<Range<T>> unwrap()
     {
+        @SuppressWarnings("unchecked")
         T minValue = (T) partitioner.minValue(right.getClass());
         if (!isWrapAround() || right.equals(minValue))
             return Arrays.asList(this);
@@ -244,7 +245,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
     /**
      * Tells if the given range is a wrap around.
      */
-    public static <T extends RingPosition> boolean isWrapAround(T left, T right)
+    public static <T extends RingPosition<T>> boolean isWrapAround(T left, T right)
     {
        return left.compareTo(right) >= 0;
     }
@@ -307,7 +308,8 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         }
         else
         {
-            Range[] intersections = new Range[intersectionSet.size()];
+            @SuppressWarnings("unchecked")
+            Range<T>[] intersections = (Range<T>[]) new Range[intersectionSet.size()];
             intersectionSet.toArray(intersections);
             if (intersections.length == 1)
             {
@@ -329,7 +331,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         return result;
     }
 
-    public static <T extends RingPosition> boolean isInRanges(T token, Iterable<Range<T>> ranges)
+    public static <T extends RingPosition<T>> boolean isInRanges(T token, Iterable<Range<T>> ranges)
     {
         assert ranges != null;
 
@@ -348,7 +350,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
     {
         if (!(o instanceof Range))
             return false;
-        Range<T> rhs = (Range<T>)o;
+        Range<?> rhs = (Range<?>)o;
         return left.equals(rhs.left) && right.equals(rhs.right);
     }
 
@@ -384,7 +386,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
     /**
      * @return A copy of the given list of with all ranges unwrapped, sorted by left bound and with overlapping bounds merged.
      */
-    public static <T extends RingPosition> List<Range<T>> normalize(Collection<Range<T>> ranges)
+    public static <T extends RingPosition<T>> List<Range<T>> normalize(Collection<Range<T>> ranges)
     {
         // unwrap all
         List<Range<T>> output = new ArrayList<Range<T>>(ranges.size());
@@ -408,7 +410,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
      * Given a list of unwrapped ranges sorted by left position, return an
      * equivalent list of ranges but with no overlapping ranges.
      */
-    private static <T extends RingPosition> List<Range<T>> deoverlap(List<Range<T>> ranges)
+    private static <T extends RingPosition<T>> List<Range<T>> deoverlap(List<Range<T>> ranges)
     {
         if (ranges.isEmpty())
             return ranges;
@@ -418,6 +420,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         Iterator<Range<T>> iter = ranges.iterator();
         Range<T> current = iter.next();
 
+        @SuppressWarnings("unchecked")
         T min = (T) current.partitioner.minValue(current.left.getClass());
         while (iter.hasNext())
         {
@@ -462,11 +465,13 @@ public class Range<T extends RingPosition> extends AbstractBounds<T> implements
         return new Range<RowPosition>(left.maxKeyBound(partitioner), right.maxKeyBound(partitioner), partitioner);
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<RowPosition> toRowBounds()
     {
         return (left instanceof Token) ? makeRowRange((Token)left, (Token)right, partitioner) : (Range<RowPosition>)this;
     }
 
+    @SuppressWarnings("unchecked")
     public AbstractBounds<Token> toTokenBounds()
     {
         return (left instanceof RowPosition) ? new Range<Token>(((RowPosition)left).getToken(), ((RowPosition)right).getToken(), partitioner) : (Range<Token>)this;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/RangeStreamer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/RangeStreamer.java b/src/java/org/apache/cassandra/dht/RangeStreamer.java
index 11d82d6..63c8a6a 100644
--- a/src/java/org/apache/cassandra/dht/RangeStreamer.java
+++ b/src/java/org/apache/cassandra/dht/RangeStreamer.java
@@ -142,7 +142,7 @@ public class RangeStreamer
         {
             if (logger.isDebugEnabled())
             {
-                for (Range r : entry.getValue())
+                for (Range<Token> r : entry.getValue())
                     logger.debug(String.format("%s: range %s from source %s for keyspace %s", description, r, entry.getKey(), keyspaceName));
             }
             toFetch.put(keyspaceName, entry);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/RingPosition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/RingPosition.java b/src/java/org/apache/cassandra/dht/RingPosition.java
index 8481b2c..fefc3b3 100644
--- a/src/java/org/apache/cassandra/dht/RingPosition.java
+++ b/src/java/org/apache/cassandra/dht/RingPosition.java
@@ -22,7 +22,7 @@ package org.apache.cassandra.dht;
  * Both Token and DecoratedKey represent a position in the ring, a token being
  * less precise than a DecoratedKey (a token is really a range of keys).
  */
-public interface RingPosition<T> extends Comparable<T>
+public interface RingPosition<C extends RingPosition<C>> extends Comparable<C>
 {
     public Token getToken();
     public boolean isMinimum(IPartitioner partitioner);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/StringToken.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/StringToken.java b/src/java/org/apache/cassandra/dht/StringToken.java
index 85b2f54..4615181 100644
--- a/src/java/org/apache/cassandra/dht/StringToken.java
+++ b/src/java/org/apache/cassandra/dht/StringToken.java
@@ -18,7 +18,7 @@
 package org.apache.cassandra.dht;
 
 
-public class StringToken extends Token<String>
+public class StringToken extends AbstractToken<String>
 {
     static final long serialVersionUID = 5464084395277974963L;
 
@@ -27,8 +27,8 @@ public class StringToken extends Token<String>
         super(token);
     }
 
-    public int compareTo(Token<String> o)
+    public int compareTo(Token o)
     {
-        return token.compareTo(o.token);
+        return token.compareTo(((StringToken) o).token);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/dht/Token.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Token.java b/src/java/org/apache/cassandra/dht/Token.java
index 09b73b7..dbeee96 100644
--- a/src/java/org/apache/cassandra/dht/Token.java
+++ b/src/java/org/apache/cassandra/dht/Token.java
@@ -30,53 +30,18 @@ import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-public abstract class Token<T> implements RingPosition<Token<T>>, Serializable
+public abstract class Token implements RingPosition<Token>, Serializable
 {
     private static final long serialVersionUID = 1L;
 
     public static final TokenSerializer serializer = new TokenSerializer();
 
-    public final T token;
-
-    protected Token(T token)
-    {
-        this.token = token;
-    }
-
-    /**
-     * This determines the comparison for node destination purposes.
-     */
-    abstract public int compareTo(Token<T> o);
-
-    @Override
-    public String toString()
-    {
-        return token.toString();
-    }
-
-    @Override
-    public boolean equals(Object obj)
-    {
-        if (this == obj)
-            return true;
-        if (obj == null || this.getClass() != obj.getClass())
-            return false;
-
-        return token.equals(((Token<T>)obj).token);
-    }
-
-    @Override
-    public int hashCode()
-    {
-        return token.hashCode();
-    }
-
-    public static abstract class TokenFactory<T>
+    public static abstract class TokenFactory
     {
-        public abstract ByteBuffer toByteArray(Token<T> token);
-        public abstract Token<T> fromByteArray(ByteBuffer bytes);
-        public abstract String toString(Token<T> token); // serialize as string, not necessarily human-readable
-        public abstract Token<T> fromString(String string); // deserialize
+        public abstract ByteBuffer toByteArray(Token token);
+        public abstract Token fromByteArray(ByteBuffer bytes);
+        public abstract String toString(Token token); // serialize as string, not necessarily human-readable
+        public abstract Token fromString(String string); // deserialize
 
         public abstract void validate(String token) throws ConfigurationException;
     }
@@ -107,7 +72,7 @@ public abstract class Token<T> implements RingPosition<Token<T>>, Serializable
         }
     }
 
-    public Token<T> getToken()
+    public Token getToken()
     {
         return this;
     }
@@ -165,7 +130,8 @@ public abstract class Token<T> implements RingPosition<Token<T>>, Serializable
         return maxKeyBound(StorageService.getPartitioner());
     }
 
-    public <R extends RingPosition> R upperBound(Class<R> klass)
+    @SuppressWarnings("unchecked")
+    public <R extends RingPosition<R>> R upperBound(Class<R> klass)
     {
         if (klass.equals(getClass()))
             return (R)this;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/gms/TokenSerializer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/TokenSerializer.java b/src/java/org/apache/cassandra/gms/TokenSerializer.java
index bc5bf4b..1404258 100644
--- a/src/java/org/apache/cassandra/gms/TokenSerializer.java
+++ b/src/java/org/apache/cassandra/gms/TokenSerializer.java
@@ -35,7 +35,7 @@ public class TokenSerializer
 
     public static void serialize(IPartitioner partitioner, Collection<Token> tokens, DataOutput out) throws IOException
     {
-        for (Token<?> token : tokens)
+        for (Token token : tokens)
         {
             byte[] bintoken = partitioner.getTokenFactory().toByteArray(token).array();
             out.writeInt(bintoken.length);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
index 50c2ca3..0f95a9b 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
@@ -123,7 +123,7 @@ public class SSTableWriter extends SSTable
                          long keyCount,
                          long repairedAt,
                          CFMetaData metadata,
-                         IPartitioner<?> partitioner,
+                         IPartitioner partitioner,
                          MetadataCollector sstableMetadataCollector)
     {
         super(Descriptor.fromFilename(filename),

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index f30862b..72f9e15 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1816,7 +1816,7 @@ public class StorageProxy implements StorageProxyMBean
      * Compute all ranges we're going to query, in sorted order. Nodes can be replica destinations for many ranges,
      * so we need to restrict each scan to the specific range we want, or else we'd get duplicate results.
      */
-    static <T extends RingPosition> List<AbstractBounds<T>> getRestrictedRanges(final AbstractBounds<T> queryRange)
+    static <T extends RingPosition<T>> List<AbstractBounds<T>> getRestrictedRanges(final AbstractBounds<T> queryRange)
     {
         // special case for bounds containing exactly 1 (non-minimum) token
         if (queryRange instanceof Bounds && queryRange.left.equals(queryRange.right) && !queryRange.left.isMinimum(StorageService.getPartitioner()))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/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 2e76ee4..e7708df 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -1161,11 +1161,11 @@ public class CassandraServer implements Cassandra.Iface
 
             List<Row> rows = null;
 
-            IPartitioner<?> p = StorageService.getPartitioner();
+            IPartitioner p = StorageService.getPartitioner();
             AbstractBounds<RowPosition> bounds;
             if (range.start_key == null)
             {
-                Token.TokenFactory<?> tokenFactory = p.getTokenFactory();
+                Token.TokenFactory tokenFactory = p.getTokenFactory();
                 Token left = tokenFactory.fromString(range.start_token);
                 Token right = tokenFactory.fromString(range.end_token);
                 bounds = Range.makeRowRange(left, right, p);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/tools/SSTableExport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableExport.java b/src/java/org/apache/cassandra/tools/SSTableExport.java
index cc725a4..e178145 100644
--- a/src/java/org/apache/cassandra/tools/SSTableExport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableExport.java
@@ -264,7 +264,7 @@ public class SSTableExport
         RandomAccessReader dfile = sstable.openDataReader();
         try
         {
-            IPartitioner<?> partitioner = sstable.partitioner;
+            IPartitioner partitioner = sstable.partitioner;
 
             if (excludes != null)
                 toExport.removeAll(Arrays.asList(excludes));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/src/java/org/apache/cassandra/tools/SSTableImport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableImport.java b/src/java/org/apache/cassandra/tools/SSTableImport.java
index edad02a..bdbebc1 100644
--- a/src/java/org/apache/cassandra/tools/SSTableImport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableImport.java
@@ -282,7 +282,7 @@ public class SSTableImport
     public int importJson(String jsonFile, String keyspace, String cf, String ssTablePath) throws IOException
     {
         ColumnFamily columnFamily = ArrayBackedSortedColumns.factory.create(keyspace, cf);
-        IPartitioner<?> partitioner = DatabaseDescriptor.getPartitioner();
+        IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
 
         int importedKeys = (isSorted) ? importSorted(jsonFile, columnFamily, ssTablePath, partitioner)
                                       : importUnsorted(jsonFile, columnFamily, ssTablePath, partitioner);
@@ -293,7 +293,7 @@ public class SSTableImport
         return importedKeys;
     }
 
-    private int importUnsorted(String jsonFile, ColumnFamily columnFamily, String ssTablePath, IPartitioner<?> partitioner) throws IOException
+    private int importUnsorted(String jsonFile, ColumnFamily columnFamily, String ssTablePath, IPartitioner partitioner) throws IOException
     {
         int importedKeys = 0;
         long start = System.nanoTime();
@@ -350,7 +350,7 @@ public class SSTableImport
     }
 
     private int importSorted(String jsonFile, ColumnFamily columnFamily, String ssTablePath,
-            IPartitioner<?> partitioner) throws IOException
+            IPartitioner partitioner) throws IOException
     {
         int importedKeys = 0; // already imported keys count
         long start = System.nanoTime();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index dda9b65..0aa33a6 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -197,7 +197,7 @@ public class ColumnFamilyStoreTest extends SchemaLoader
     {
         ColumnFamilyStore cfs = insertKey1Key2();
 
-        IPartitioner<?> p = StorageService.getPartitioner();
+        IPartitioner p = StorageService.getPartitioner();
         List<Row> result = cfs.getRangeSlice(Util.range(p, "key1", "key2"),
                                              null,
                                              Util.namesFilter(cfs, "asdf"),

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/KeyCollisionTest.java b/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
deleted file mode 100644
index 1869872..0000000
--- a/test/unit/org/apache/cassandra/db/KeyCollisionTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cassandra.db;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.junit.Test;
-
-import org.apache.cassandra.SchemaLoader;
-import org.apache.cassandra.Util;
-import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
-import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.db.marshal.IntegerType;
-import org.apache.cassandra.dht.*;
-import org.apache.cassandra.config.*;
-import org.apache.cassandra.service.StorageService;
-import org.apache.cassandra.utils.*;
-import static org.apache.cassandra.Util.dk;
-
-
-/**
- * Test cases where multiple keys collides, ie have the same token.
- * Order preserving partitioner have no possible collision and creating
- * collision for the RandomPartitioner is ... difficult, so we create a dumb
- * length partitioner that takes the length of the key as token, making
- * collision easy and predictable.
- */
-public class KeyCollisionTest extends SchemaLoader
-{
-    IPartitioner oldPartitioner;
-    private static final String KEYSPACE = "Keyspace1";
-    private static final String CF = "Standard1";
-
-    protected void setUp()
-    {
-        oldPartitioner = DatabaseDescriptor.getPartitioner();
-        DatabaseDescriptor.setPartitioner(new LengthPartitioner());
-    }
-
-    protected void tearDown()
-    {
-        DatabaseDescriptor.setPartitioner(oldPartitioner);
-    }
-
-    @Test
-    public void testGetSliceWithCollision() throws Exception
-    {
-        Keyspace keyspace = Keyspace.open(KEYSPACE);
-        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
-        cfs.clearUnsafe();
-
-        insert("k1", "k2", "k3");       // token = 2
-        insert("key1", "key2", "key3"); // token = 4
-        insert("longKey1", "longKey2"); // token = 8
-
-        List<Row> rows = cfs.getRangeSlice(new Bounds<RowPosition>(dk("k2"), dk("key2")), null, new IdentityQueryFilter(), 10000);
-        assert rows.size() == 4 : "Expecting 4 keys, got " + rows.size();
-        assert rows.get(0).key.getKey().equals(ByteBufferUtil.bytes("k2"));
-        assert rows.get(1).key.getKey().equals(ByteBufferUtil.bytes("k3"));
-        assert rows.get(2).key.getKey().equals(ByteBufferUtil.bytes("key1"));
-        assert rows.get(3).key.getKey().equals(ByteBufferUtil.bytes("key2"));
-    }
-
-    private void insert(String... keys)
-    {
-        for (String key : keys)
-            insert(key);
-    }
-
-    private void insert(String key)
-    {
-        Mutation rm;
-        rm = new Mutation(KEYSPACE, ByteBufferUtil.bytes(key));
-        rm.add(CF, Util.cellname("column"), ByteBufferUtil.bytes("asdf"), 0);
-        rm.apply();
-    }
-
-    public static class LengthPartitioner extends AbstractPartitioner<BigIntegerToken>
-    {
-        public static final BigInteger ZERO = new BigInteger("0");
-        public static final BigIntegerToken MINIMUM = new BigIntegerToken("-1");
-
-        private static final byte DELIMITER_BYTE = ":".getBytes()[0];
-
-        public DecoratedKey decorateKey(ByteBuffer key)
-        {
-            return new BufferDecoratedKey(getToken(key), key);
-        }
-
-        public Token midpoint(Token ltoken, Token rtoken)
-        {
-            // the symbolic MINIMUM token should act as ZERO: the empty bit array
-            BigInteger left = ltoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)ltoken).token;
-            BigInteger right = rtoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)rtoken).token;
-            Pair<BigInteger,Boolean> midpair = FBUtilities.midpoint(left, right, 127);
-            // discard the remainder
-            return new BigIntegerToken(midpair.left);
-        }
-
-        public BigIntegerToken getMinimumToken()
-        {
-            return MINIMUM;
-        }
-
-        public BigIntegerToken getRandomToken()
-        {
-            return new BigIntegerToken(BigInteger.valueOf(new Random().nextInt(15)));
-        }
-
-        private final Token.TokenFactory<BigInteger> tokenFactory = new Token.TokenFactory<BigInteger>() {
-            public ByteBuffer toByteArray(Token<BigInteger> bigIntegerToken)
-            {
-                return ByteBuffer.wrap(bigIntegerToken.token.toByteArray());
-            }
-
-            public Token<BigInteger> fromByteArray(ByteBuffer bytes)
-            {
-                return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes)));
-            }
-
-            public String toString(Token<BigInteger> bigIntegerToken)
-            {
-                return bigIntegerToken.token.toString();
-            }
-
-            public Token<BigInteger> fromString(String string)
-            {
-                return new BigIntegerToken(new BigInteger(string));
-            }
-
-            public void validate(String token) {}
-        };
-
-        public Token.TokenFactory<BigInteger> getTokenFactory()
-        {
-            return tokenFactory;
-        }
-
-        public boolean preservesOrder()
-        {
-            return false;
-        }
-
-        public BigIntegerToken getToken(ByteBuffer key)
-        {
-            if (key.remaining() == 0)
-                return MINIMUM;
-            return new BigIntegerToken(BigInteger.valueOf(key.remaining()));
-        }
-
-        @Override
-        public long getHeapSizeOf(BigIntegerToken token)
-        {
-            return 0;
-        }
-
-        public Map<Token, Float> describeOwnership(List<Token> sortedTokens)
-        {
-            // allTokens will contain the count and be returned, sorted_ranges is shorthand for token<->token math.
-            Map<Token, Float> allTokens = new HashMap<Token, Float>();
-            List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>();
-
-            // this initializes the counts to 0 and calcs the ranges in order.
-            Token lastToken = sortedTokens.get(sortedTokens.size() - 1);
-            for (Token node : sortedTokens)
-            {
-                allTokens.put(node, new Float(0.0));
-                sortedRanges.add(new Range<Token>(lastToken, node));
-                lastToken = node;
-            }
-
-            for (String ks : Schema.instance.getKeyspaces())
-            {
-                for (CFMetaData cfmd : Schema.instance.getKSMetaData(ks).cfMetaData().values())
-                {
-                    for (Range<Token> r : sortedRanges)
-                    {
-                        // Looping over every KS:CF:Range, get the splits size and add it to the count
-                        allTokens.put(r.right, allTokens.get(r.right) + StorageService.instance.getSplits(ks, cfmd.cfName, r, 1).size());
-                    }
-                }
-            }
-
-            // Sum every count up and divide count/total for the fractional ownership.
-            Float total = new Float(0.0);
-            for (Float f : allTokens.values())
-                total += f;
-            for (Map.Entry<Token, Float> row : allTokens.entrySet())
-                allTokens.put(row.getKey(), row.getValue() / total);
-
-            return allTokens;
-        }
-
-        public AbstractType<?> getTokenValidator()
-        {
-            return IntegerType.instance;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/BootStrapperTest.java b/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
index ffad335..471bc4b 100644
--- a/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
+++ b/test/unit/org/apache/cassandra/dht/BootStrapperTest.java
@@ -103,7 +103,7 @@ public class BootStrapperTest extends SchemaLoader
     {
         TokenMetadata tmd = StorageService.instance.getTokenMetadata();
         tmd.clearUnsafe();
-        IPartitioner<?> p = StorageService.getPartitioner();
+        IPartitioner p = StorageService.getPartitioner();
 
         for (int i = 1; i <= numOldNodes; i++)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java b/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
index 31a1af3..cfe5f52 100644
--- a/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/ByteOrderedPartitionerTest.java
@@ -18,7 +18,7 @@
 */
 package org.apache.cassandra.dht;
 
-public class ByteOrderedPartitionerTest extends PartitionerTestCase<BytesToken>
+public class ByteOrderedPartitionerTest extends PartitionerTestCase
 {
     public void initPartitioner()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/KeyCollisionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/KeyCollisionTest.java b/test/unit/org/apache/cassandra/dht/KeyCollisionTest.java
new file mode 100644
index 0000000..e143f30
--- /dev/null
+++ b/test/unit/org/apache/cassandra/dht/KeyCollisionTest.java
@@ -0,0 +1,217 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cassandra.dht;
+
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.util.*;
+
+import org.junit.Test;
+import org.apache.cassandra.SchemaLoader;
+import org.apache.cassandra.Util;
+import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
+import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.db.marshal.IntegerType;
+import org.apache.cassandra.config.*;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.*;
+
+import static org.apache.cassandra.Util.dk;
+
+
+/**
+ * Test cases where multiple keys collides, ie have the same token.
+ * Order preserving partitioner have no possible collision and creating
+ * collision for the RandomPartitioner is ... difficult, so we create a dumb
+ * length partitioner that takes the length of the key as token, making
+ * collision easy and predictable.
+ */
+public class KeyCollisionTest extends SchemaLoader
+{
+    IPartitioner oldPartitioner;
+    private static final String KEYSPACE = "Keyspace1";
+    private static final String CF = "Standard1";
+
+    protected void setUp()
+    {
+        oldPartitioner = DatabaseDescriptor.getPartitioner();
+        DatabaseDescriptor.setPartitioner(new LengthPartitioner());
+    }
+
+    protected void tearDown()
+    {
+        DatabaseDescriptor.setPartitioner(oldPartitioner);
+    }
+
+    @Test
+    public void testGetSliceWithCollision() throws Exception
+    {
+        Keyspace keyspace = Keyspace.open(KEYSPACE);
+        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
+        cfs.clearUnsafe();
+
+        insert("k1", "k2", "k3");       // token = 2
+        insert("key1", "key2", "key3"); // token = 4
+        insert("longKey1", "longKey2"); // token = 8
+
+        List<Row> rows = cfs.getRangeSlice(new Bounds<RowPosition>(dk("k2"), dk("key2")), null, new IdentityQueryFilter(), 10000);
+        assert rows.size() == 4 : "Expecting 4 keys, got " + rows.size();
+        assert rows.get(0).key.getKey().equals(ByteBufferUtil.bytes("k2"));
+        assert rows.get(1).key.getKey().equals(ByteBufferUtil.bytes("k3"));
+        assert rows.get(2).key.getKey().equals(ByteBufferUtil.bytes("key1"));
+        assert rows.get(3).key.getKey().equals(ByteBufferUtil.bytes("key2"));
+    }
+
+    private void insert(String... keys)
+    {
+        for (String key : keys)
+            insert(key);
+    }
+
+    private void insert(String key)
+    {
+        Mutation rm;
+        rm = new Mutation(KEYSPACE, ByteBufferUtil.bytes(key));
+        rm.add(CF, Util.cellname("column"), ByteBufferUtil.bytes("asdf"), 0);
+        rm.apply();
+    }
+
+    public static class LengthPartitioner extends AbstractPartitioner
+    {
+        public static final BigInteger ZERO = new BigInteger("0");
+        public static final BigIntegerToken MINIMUM = new BigIntegerToken("-1");
+
+        public DecoratedKey decorateKey(ByteBuffer key)
+        {
+            return new BufferDecoratedKey(getToken(key), key);
+        }
+
+        public BigIntegerToken midpoint(Token ltoken, Token rtoken)
+        {
+            // the symbolic MINIMUM token should act as ZERO: the empty bit array
+            BigInteger left = ltoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)ltoken).token;
+            BigInteger right = rtoken.equals(MINIMUM) ? ZERO : ((BigIntegerToken)rtoken).token;
+            Pair<BigInteger,Boolean> midpair = FBUtilities.midpoint(left, right, 127);
+            // discard the remainder
+            return new BigIntegerToken(midpair.left);
+        }
+
+        public BigIntegerToken getMinimumToken()
+        {
+            return MINIMUM;
+        }
+
+        public BigIntegerToken getRandomToken()
+        {
+            return new BigIntegerToken(BigInteger.valueOf(new Random().nextInt(15)));
+        }
+
+        private final Token.TokenFactory tokenFactory = new Token.TokenFactory() {
+            public ByteBuffer toByteArray(Token token)
+            {
+                BigIntegerToken bigIntegerToken = (BigIntegerToken) token;
+                return ByteBuffer.wrap(bigIntegerToken.token.toByteArray());
+            }
+
+            public Token fromByteArray(ByteBuffer bytes)
+            {
+                return new BigIntegerToken(new BigInteger(ByteBufferUtil.getArray(bytes)));
+            }
+
+            public String toString(Token token)
+            {
+                BigIntegerToken bigIntegerToken = (BigIntegerToken) token;
+                return bigIntegerToken.token.toString();
+            }
+
+            public Token fromString(String string)
+            {
+                return new BigIntegerToken(new BigInteger(string));
+            }
+
+            public void validate(String token) {}
+        };
+
+        public Token.TokenFactory getTokenFactory()
+        {
+            return tokenFactory;
+        }
+
+        public boolean preservesOrder()
+        {
+            return false;
+        }
+
+        public BigIntegerToken getToken(ByteBuffer key)
+        {
+            if (key.remaining() == 0)
+                return MINIMUM;
+            return new BigIntegerToken(BigInteger.valueOf(key.remaining()));
+        }
+
+        @Override
+        public long getHeapSizeOf(Token token)
+        {
+            return 0;
+        }
+
+        public Map<Token, Float> describeOwnership(List<Token> sortedTokens)
+        {
+            // allTokens will contain the count and be returned, sorted_ranges is shorthand for token<->token math.
+            Map<Token, Float> allTokens = new HashMap<Token, Float>();
+            List<Range<Token>> sortedRanges = new ArrayList<Range<Token>>();
+
+            // this initializes the counts to 0 and calcs the ranges in order.
+            Token lastToken = sortedTokens.get(sortedTokens.size() - 1);
+            for (Token node : sortedTokens)
+            {
+                allTokens.put(node, new Float(0.0));
+                sortedRanges.add(new Range<Token>(lastToken, node));
+                lastToken = node;
+            }
+
+            for (String ks : Schema.instance.getKeyspaces())
+            {
+                for (CFMetaData cfmd : Schema.instance.getKSMetaData(ks).cfMetaData().values())
+                {
+                    for (Range<Token> r : sortedRanges)
+                    {
+                        // Looping over every KS:CF:Range, get the splits size and add it to the count
+                        allTokens.put(r.right, allTokens.get(r.right) + StorageService.instance.getSplits(ks, cfmd.cfName, r, 1).size());
+                    }
+                }
+            }
+
+            // Sum every count up and divide count/total for the fractional ownership.
+            Float total = new Float(0.0);
+            for (Float f : allTokens.values())
+                total += f;
+            for (Map.Entry<Token, Float> row : allTokens.entrySet())
+                allTokens.put(row.getKey(), row.getValue() / total);
+
+            return allTokens;
+        }
+
+        public AbstractType<?> getTokenValidator()
+        {
+            return IntegerType.instance;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java b/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
index 7db91c1..71c7e89 100644
--- a/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/Murmur3PartitionerTest.java
@@ -20,7 +20,7 @@
  */
 package org.apache.cassandra.dht;
 
-public class Murmur3PartitionerTest extends PartitionerTestCase<LongToken>
+public class Murmur3PartitionerTest extends PartitionerTestCase
 {
     public void initPartitioner()
     {
@@ -30,7 +30,7 @@ public class Murmur3PartitionerTest extends PartitionerTestCase<LongToken>
     @Override
     protected void midpointMinimumTestCase()
     {
-        LongToken mintoken = partitioner.getMinimumToken();
+        Token mintoken = partitioner.getMinimumToken();
         assert mintoken.compareTo(partitioner.midpoint(mintoken, mintoken)) != 0;
         assertMidpoint(mintoken, tok("a"), 16);
         assertMidpoint(mintoken, tok("aaa"), 16);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java b/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
index e14dec8..aa43265 100644
--- a/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
+++ b/test/unit/org/apache/cassandra/dht/OrderPreservingPartitionerTest.java
@@ -23,7 +23,7 @@ import org.junit.Test;
 
 import org.apache.cassandra.SchemaLoader;
 
-public class OrderPreservingPartitionerTest extends PartitionerTestCase<StringToken>
+public class OrderPreservingPartitionerTest extends PartitionerTestCase
 {
     @BeforeClass
     public static void cleanStatesFromPreviousTest()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad84e4d7/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java b/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
index 5d5e65c..db0349d 100644
--- a/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
+++ b/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
@@ -27,9 +27,9 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-public abstract class PartitionerTestCase<T extends Token>
+public abstract class PartitionerTestCase
 {
-    protected IPartitioner<T> partitioner;
+    protected IPartitioner partitioner;
 
     public abstract void initPartitioner();
 
@@ -39,12 +39,12 @@ public abstract class PartitionerTestCase<T extends Token>
         initPartitioner();
     }
 
-    public T tok(byte[] key)
+    public Token tok(byte[] key)
     {
         return partitioner.getToken(ByteBuffer.wrap(key));
     }
 
-    public T tok(String key)
+    public Token tok(String key)
     {
         return tok(key.getBytes());
     }
@@ -52,7 +52,7 @@ public abstract class PartitionerTestCase<T extends Token>
     /**
      * Recurses randomly to the given depth a few times.
      */
-    public void assertMidpoint(T left, T right, int depth)
+    public void assertMidpoint(Token left, Token right, int depth)
     {
         Random rand = new Random();
         for (int i = 0; i < 1000; i++)
@@ -90,7 +90,7 @@ public abstract class PartitionerTestCase<T extends Token>
 
     protected void midpointMinimumTestCase()
     {
-        T mintoken = partitioner.getMinimumToken();
+        Token mintoken = partitioner.getMinimumToken();
         assert mintoken.compareTo(partitioner.midpoint(mintoken, mintoken)) != 0;
         assertMidpoint(mintoken, tok("a"), 16);
         assertMidpoint(mintoken, tok("aaa"), 16);


Mime
View raw message