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 Mon, 01 Apr 2019 15:22:51 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_r270921364
 
 

 ##########
 File path: src/java/org/apache/cassandra/locator/dynamicsnitch/DynamicEndpointSnitchLegacyHistogram.java
 ##########
 @@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.locator.dynamicsnitch;
+
+import java.util.Map;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import org.apache.cassandra.locator.IEndpointSnitch;
+import org.apache.cassandra.locator.InetAddressAndPort;
+import org.apache.cassandra.net.MessagingService;
+
+/**
+ * The legacy dynamic snitching implementation (prior to 4.0) that uses Exponentially Decaying
Histograms to
+ * prefer or de-prefer hosts. Instead of relying on latency probes this implementation just
resets
+ * reservoirs for hosts we haven't talked to.
+ *
+ * This is left only for users that explicitly want the old behavior.
+ */
+public class DynamicEndpointSnitchLegacyHistogram extends DynamicEndpointSnitchHistogram
+{
+    // Called via reflection
+    public DynamicEndpointSnitchLegacyHistogram(IEndpointSnitch snitch)
+    {
+        this(snitch, "legacy");
+    }
+
+    public DynamicEndpointSnitchLegacyHistogram(IEndpointSnitch snitch, String instance)
+    {
+        super(snitch, instance);
+    }
+
+    @VisibleForTesting
+    protected Map<InetAddressAndPort, AnnotatedMeasurement> getMeasurementsWithPort()
+    {
+        return samples;
+    }
+
+    /**
+     * Overrides the top level updateSamples method to emulate the old DES reset behavior
with the minor change
+     * that we only clear the samples if at least one of the ranked hosts exceeded 10 minutes
of no measurements
+     */
+    @Override
+    protected void updateSamples()
+    {
+        for (Map.Entry<InetAddressAndPort, AnnotatedMeasurement> entry: samples.entrySet())
+        {
+            AnnotatedMeasurement measurement = entry.getValue();
+            long millisSinceLastMeasure = measurement.millisSinceLastMeasure.getAndAdd(dynamicSampleUpdateInterval);
+            if (millisSinceLastMeasure >= MAX_PROBE_INTERVAL_MS)
+            {
+                samples.clear();
 
 Review comment:
   Sure but I thought this was the part we wanted to drop by adding probing. We don't need
to clear the samples the probes should cause it to age correct over time?
   
   

----------------------------------------------------------------
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