cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] aweisberg commented on a change in pull request #283: CASSANDRA-14459: DynamicEndpointSnitch should never prefer latent replicas
Date Fri, 22 Mar 2019 23:29:59 GMT
aweisberg commented on a change in pull request #283: CASSANDRA-14459: DynamicEndpointSnitch
should never prefer latent replicas
URL: https://github.com/apache/cassandra/pull/283#discussion_r268366732
 
 

 ##########
 File path: src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
 ##########
 @@ -214,30 +659,22 @@ public String getDatacenter(InetAddressAndPort endpoint)
         {
             if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + dynamicBadnessThreshold)))
             {
-                return sortedByProximityWithScore(address, replicas);
+                return sortedByProximityWithScore(address, replicas, aliasedScores);
             }
         }
 
         return replicas;
     }
 
     // Compare endpoints given an immutable snapshot of the scores
-    private int compareEndpoints(InetAddressAndPort target, Replica a1, Replica a2, Map<InetAddressAndPort,
Double> scores)
+    private int compareEndpoints(InetAddressAndPort target, Replica a1, Replica a2, Map<InetAddressAndPort,
Double> aliasedScores)
     {
-        Double scored1 = scores.get(a1.endpoint());
-        Double scored2 = scores.get(a2.endpoint());
-        
-        if (scored1 == null)
-        {
-            scored1 = 0.0;
-        }
-
-        if (scored2 == null)
-        {
-            scored2 = 0.0;
-        }
+        Double scored1 = aliasedScores.get(a1.endpoint());
+        Double scored2 = aliasedScores.get(a2.endpoint());
 
-        if (scored1.equals(scored2))
+        // If we don't have latency information about one or more of the replicas, trust
the subsnitch until we have
+        // latency information.
+        if (scored1 == null || scored2 == null || scored1.equals(scored2))
             return subsnitch.compareEndpoints(target, a1, a2);
 
 Review comment:
   I am wondering if there are cases where this breaks. Like if the subsnitch returns a different
answer depending on the order of the arguments. Guess we can deal with that if it happens.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message