cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [01/15] cassandra git commit: Don't return early from DynamicEndpointSnitch when null scores are encountered
Date Tue, 03 Jan 2017 18:05:46 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 f4fd0928e -> e4f732536
  refs/heads/cassandra-3.0 b0f85b96d -> 617bd23e8
  refs/heads/cassandra-3.11 84b1725fb -> 68f7ce440
  refs/heads/cassandra-3.X 4aa09eb7a -> 917d13f00
  refs/heads/trunk c607d7641 -> 87b1bb87a


Don't return early from DynamicEndpointSnitch when null scores are encountered

Patch by Joel Knighton; reviewed by tjake for CASSANDRA-13074


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

Branch: refs/heads/cassandra-2.2
Commit: e4f732536af9d81dd012d7d498b884cd7c8c0b48
Parents: f4fd092
Author: Joel Knighton <joel.knighton@datastax.com>
Authored: Wed Dec 21 15:15:40 2016 -0600
Committer: T Jake Luciani <jake@apache.org>
Committed: Tue Jan 3 12:50:18 2017 -0500

----------------------------------------------------------------------
 CHANGES.txt                                                 | 1 +
 .../org/apache/cassandra/locator/DynamicEndpointSnitch.java | 4 +---
 .../apache/cassandra/locator/DynamicEndpointSnitchTest.java | 9 ++++++++-
 3 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4f73253/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8a7ae42..d31ffc8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.9
+ * Fix DynamicEndpointSnitch noop in multi-datacenter situations (CASSANDRA-13074)
  * cqlsh copy-from: encode column names to avoid primary key parsing errors (CASSANDRA-12909)
  * Temporarily fix bug that creates commit log when running offline tools (CASSANDRA-8616)
  * Reduce granuality of OpOrder.Group during index build (CASSANDRA-12796)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4f73253/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
index 6280dc2..9c0c57e 100644
--- a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
+++ b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
@@ -185,7 +185,7 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements
ILa
         {
             Double score = scores.get(inet);
             if (score == null)
-                return;
+                continue;
             subsnitchOrderedScores.add(score);
         }
 
@@ -215,13 +215,11 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements
ILa
         if (scored1 == null)
         {
             scored1 = 0.0;
-            receiveTiming(a1, 0);
         }
 
         if (scored2 == null)
         {
             scored2 = 0.0;
-            receiveTiming(a2, 0);
         }
 
         if (scored1.equals(scored2))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e4f73253/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
index 100cd25..d27edbf 100644
--- a/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
+++ b/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
@@ -33,7 +33,6 @@ import static org.junit.Assert.assertEquals;
 
 public class DynamicEndpointSnitchTest
 {
-
     private static void setScores(DynamicEndpointSnitch dsnitch,  int rounds, List<InetAddress>
hosts, Integer... scores) throws InterruptedException
     {
         for (int round = 0; round < rounds; round++)
@@ -55,6 +54,7 @@ public class DynamicEndpointSnitchTest
         InetAddress host1 = InetAddress.getByName("127.0.0.2");
         InetAddress host2 = InetAddress.getByName("127.0.0.3");
         InetAddress host3 = InetAddress.getByName("127.0.0.4");
+        InetAddress host4 = InetAddress.getByName("127.0.0.5");
         List<InetAddress> hosts = Arrays.asList(host1, host2, host3);
 
         // first, make all hosts equal
@@ -88,5 +88,12 @@ public class DynamicEndpointSnitchTest
         setScores(dsnitch, 20, hosts, 10, 70, 20);
         order = Arrays.asList(host1, host3, host2);
         assertEquals(order, dsnitch.getSortedListByProximity(self, Arrays.asList(host1, host2,
host3)));
+
+        order = Arrays.asList(host4, host1, host3, host2);
+        assertEquals(order, dsnitch.getSortedListByProximity(self, Arrays.asList(host1, host2,
host3, host4)));
+
+        setScores(dsnitch, 20, hosts, 10, 10, 10);
+        order = Arrays.asList(host1, host2, host3, host4);
+        assertEquals(order, dsnitch.getSortedListByProximity(self, Arrays.asList(host1, host2,
host3, host4)));
     }
 }


Mime
View raw message