cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [1/3] git commit: add dsnitch comments
Date Tue, 05 Feb 2013 19:51:01 GMT
add dsnitch comments


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

Branch: refs/heads/cassandra-1.2
Commit: acc3c8de29b4d8826e45fc5dd956a67205a0b369
Parents: 295d6af
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Feb 5 13:50:59 2013 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue Feb 5 13:50:59 2013 -0600

----------------------------------------------------------------------
 .../cassandra/locator/DynamicEndpointSnitch.java   |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/acc3c8de/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 40aad20..214208e 100644
--- a/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
+++ b/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
@@ -230,6 +230,8 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements
ILa
         double maxLatency = 1;
         long maxPenalty = 1;
         HashMap<InetAddress, Long> penalties = new HashMap<InetAddress, Long>();
+        // We're going to weight the latency and time since last reply for each host against
the worst one we see, to arrive at sort of a 'badness percentage' for both of them.
+        // first, find the worst for each.
         for (Map.Entry<InetAddress, ExponentiallyDecayingSample> entry : samples.entrySet())
         {
             double mean = entry.getValue().getSnapshot().getMedian();
@@ -238,18 +240,23 @@ public class DynamicEndpointSnitch extends AbstractEndpointSnitch implements
ILa
             long timePenalty = lastReceived.containsKey(entry.getKey()) ? lastReceived.get(entry.getKey())
: System.currentTimeMillis();
             timePenalty = System.currentTimeMillis() - timePenalty;
             timePenalty = timePenalty > UPDATE_INTERVAL_IN_MS ? UPDATE_INTERVAL_IN_MS
: timePenalty;
+            // a convenient place to remember this since we've already calculated it and
need it later
             penalties.put(entry.getKey(), timePenalty);
             if (timePenalty > maxPenalty)
                 maxPenalty = timePenalty;
         }
+        // now make another pass to do the weighting based on the maximums we found before
         for (Map.Entry<InetAddress, ExponentiallyDecayingSample> entry: samples.entrySet())
         {
             double score = entry.getValue().getSnapshot().getMedian() / maxLatency;
             if (penalties.containsKey(entry.getKey()))
                 score += penalties.get(entry.getKey()) / ((double) maxPenalty);
             else
+                // there's a chance a host was added to the samples after our previous loop
to get the time penalties.  Add 1.0 to it, or '100% bad' for the time penalty.
                 score += 1; // maxPenalty / maxPenalty
+            // finally, add the severity without any weighting, since hosts scale this relative
to their own load and the size of the task causing the severity
             score += StorageService.instance.getSeverity(entry.getKey());
+            // lowest score (least amount of badness) wins.
             scores.put(entry.getKey(), score);            
         }
     }


Mime
View raw message