cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [2/3] cassandra git commit: Fix RandomReplicationAwareTokenAllocatorTest.testExistingCluster
Date Fri, 21 Oct 2016 01:27:19 GMT
Fix RandomReplicationAwareTokenAllocatorTest.testExistingCluster

Patch by Stefania Alborghetti; reviewed by Branimir Lambov for CASSANDRA-12812


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

Branch: refs/heads/trunk
Commit: e6d22da9186bdf61facbb8c426ea5bf1e59d947d
Parents: 26ee16b
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Thu Oct 20 10:51:23 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Fri Oct 21 09:18:12 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                                              | 1 +
 src/java/org/apache/cassandra/dht/RandomPartitioner.java | 2 +-
 src/java/org/apache/cassandra/utils/GuidGenerator.java   | 9 ++++-----
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e6d22da9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 26bc68b..8a0e169 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.10
+ * Fix RandomReplicationAwareTokenAllocatorTest.testExistingCluster (CASSANDRA-12812)
  * Upgrade commons-codec to 1.9 (CASSANDRA-12790)
  * Make the fanout size for LeveledCompactionStrategy to be configurable (CASSANDRA-11550)
  * Add duration data type (CASSANDRA-11873)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e6d22da9/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 ee3b862..f6090e0 100644
--- a/src/java/org/apache/cassandra/dht/RandomPartitioner.java
+++ b/src/java/org/apache/cassandra/dht/RandomPartitioner.java
@@ -93,7 +93,7 @@ public class RandomPartitioner implements IPartitioner
 
     public BigIntegerToken getRandomToken(Random random)
     {
-        BigInteger token = FBUtilities.hashToBigInteger(GuidGenerator.guidAsBytes(random,
0));
+        BigInteger token = FBUtilities.hashToBigInteger(GuidGenerator.guidAsBytes(random,
"host/127.0.0.1", 0));
         if ( token.signum() == -1 )
             token = token.multiply(BigInteger.valueOf(-1L));
         return new BigIntegerToken(token);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e6d22da9/src/java/org/apache/cassandra/utils/GuidGenerator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/GuidGenerator.java b/src/java/org/apache/cassandra/utils/GuidGenerator.java
index c5ed7a7..2209f6a 100644
--- a/src/java/org/apache/cassandra/utils/GuidGenerator.java
+++ b/src/java/org/apache/cassandra/utils/GuidGenerator.java
@@ -76,12 +76,11 @@ public class GuidGenerator
         return convertToStandardFormat( sb.toString() );
     }
 
-    public static ByteBuffer guidAsBytes(Random random, long time)
+    public static ByteBuffer guidAsBytes(Random random, String hostId, long time)
     {
         StringBuilder sbValueBeforeMD5 = new StringBuilder();
-        long rand = 0;
-        rand = random.nextLong();
-        sbValueBeforeMD5.append(s_id)
+        long rand = random.nextLong();
+        sbValueBeforeMD5.append(hostId)
                         .append(":")
                         .append(Long.toString(time))
                         .append(":")
@@ -93,7 +92,7 @@ public class GuidGenerator
 
     public static ByteBuffer guidAsBytes()
     {
-        return guidAsBytes(myRand, System.currentTimeMillis());
+        return guidAsBytes(myRand, s_id, System.currentTimeMillis());
     }
 
     /*


Mime
View raw message