You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/02/06 23:47:14 UTC

[3/7] cassandra git commit: Fix IllegalArgumentException in dynamic snitch

Fix IllegalArgumentException in dynamic snitch

Patch by brandonwilliams, viewed by Benedict for CASSANDRA-8448


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

Branch: refs/heads/trunk
Commit: cf73de2dc99d4857cc4bac734cf48cf9a21aa9be
Parents: 1467b9f
Author: Brandon Williams <br...@apache.org>
Authored: Fri Feb 6 13:23:05 2015 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Fri Feb 6 13:23:05 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                                    | 1 +
 .../org/apache/cassandra/locator/DynamicEndpointSnitch.java    | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cf73de2d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f4c96dc..fa9c77d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.13:
+ * Fix IllegalArgumentException in dynamic snitch (CASSANDRA-8448)
  * Add support for UPDATE ... IF EXISTS (CASSANDRA-8610)
  * Fix reversal of list prepends (CASSANDRA-8733)
  * Prevent non-zero default_time_to_live on tables with counters

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cf73de2d/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 49442c8..3469847 100644
--- a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
+++ b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
@@ -53,7 +53,7 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
     private String mbeanName;
     private boolean registered = false;
 
-    private final ConcurrentHashMap<InetAddress, Double> scores = new ConcurrentHashMap<InetAddress, Double>();
+    private volatile HashMap<InetAddress, Double> scores = new HashMap<InetAddress, Double>();
     private final ConcurrentHashMap<InetAddress, ExponentiallyDecayingSample> samples = new ConcurrentHashMap<InetAddress, ExponentiallyDecayingSample>();
 
     public final IEndpointSnitch subsnitch;
@@ -243,6 +243,7 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
         double maxLatency = 1;
         // We're going to weight the latency for each host against the worst one we see, to
         // arrive at sort of a 'badness percentage' for them. First, find the worst for each:
+        HashMap<InetAddress, Double> newScores = new HashMap<>();
         for (Map.Entry<InetAddress, ExponentiallyDecayingSample> entry : samples.entrySet())
         {
             double mean = entry.getValue().getSnapshot().getMedian();
@@ -257,8 +258,9 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements ILa
             // "Severity" is basically a measure of compaction activity (CASSANDRA-3722).
             score += StorageService.instance.getSeverity(entry.getKey());
             // lowest score (least amount of badness) wins.
-            scores.put(entry.getKey(), score);            
+            newScores.put(entry.getKey(), score);
         }
+        scores = newScores;
     }