You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jw...@apache.org on 2020/05/08 16:55:24 UTC

[cassandra] branch trunk updated: Only calculate dynamicBadnessThreshold once per loop in DynamicEndpointSnitch

This is an automated email from the ASF dual-hosted git repository.

jwest pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 66eae58  Only calculate dynamicBadnessThreshold once per loop in DynamicEndpointSnitch
66eae58 is described below

commit 66eae58cd4f53c03ca5ab6b520aa490f7f61a59c
Author: Jordan West <jw...@apache.org>
AuthorDate: Thu May 7 18:06:26 2020 -0700

    Only calculate dynamicBadnessThreshold once per loop in DynamicEndpointSnitch
    
    Patch by Jordan West; Reviewed by David Capwell for CASSANDRA-15798
---
 CHANGES.txt                                                      | 1 +
 src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index e6868e9..3e7343c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-alpha5
+ * Only calculate dynamicBadnessThreshold once per loop in DynamicEndpointSnitch (CASSANDRA-15798)
  * Cleanup redundant nodetool commands added in 4.0 (CASSANDRA-15256)
  * Update to Python driver 3.23 for cqlsh (CASSANDRA-15793)
  * Add tunable initial size and growth factor to RangeTombstoneList (CASSANDRA-15763)
diff --git a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
index 0b241ce..218bdd6 100644
--- a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
+++ b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
@@ -210,10 +210,12 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements Lat
         ArrayList<Double> sortedScores = new ArrayList<>(subsnitchOrderedScores);
         Collections.sort(sortedScores);
 
+        // only calculate this once b/c its volatile and shouldn't be modified during the loop either
+        double badnessThreshold = 1.0 + dynamicBadnessThreshold;
         Iterator<Double> sortedScoreIterator = sortedScores.iterator();
         for (Double subsnitchScore : subsnitchOrderedScores)
         {
-            if (subsnitchScore > (sortedScoreIterator.next() * (1.0 + dynamicBadnessThreshold)))
+            if (subsnitchScore > (sortedScoreIterator.next() * badnessThreshold))
             {
                 return sortedByProximityWithScore(address, replicas);
             }


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