You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2020/02/21 15:20:19 UTC

[cassandra] branch cassandra-3.0 updated: Run evictFromMembership in GossipStage

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

brandonwilliams pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new 95197ce  Run evictFromMembership in GossipStage
95197ce is described below

commit 95197cef7871d1211f97da740dbdb236b81b9862
Author: Marcus Olsson <ma...@ericsson.com>
AuthorDate: Wed Feb 5 16:53:58 2020 +0100

    Run evictFromMembership in GossipStage
    
    patch by Marcus Olsson; reviewed by brandonwilliams for CASSANDRA-15592
---
 CHANGES.txt                                        |  2 +-
 src/java/org/apache/cassandra/gms/Gossiper.java    |  5 +-
 .../apache/cassandra/gms/ExpireEndpointTest.java   | 57 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 2f20e66..e2614ec 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,5 @@
 3.0.21
- * 
+ * Run evictFromMembership in GossipStage (CASSANDRA-15592)
 
 3.0.20
  * Run in-jvm upgrade dtests in circleci (CASSANDRA-15506)
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index e9e0648..7984dd4 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -808,7 +808,8 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
         return !unsafeStatuses.contains(status);
     }
 
-    private void doStatusCheck()
+    @VisibleForTesting
+    void doStatusCheck()
     {
         if (logger.isTraceEnabled())
             logger.trace("Performing status check ...");
@@ -862,7 +863,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
                     {
                         logger.debug("time is expiring for endpoint : {} ({})", endpoint, expireTime);
                     }
-                    evictFromMembership(endpoint);
+                    runInGossipStageBlocking(() -> evictFromMembership(endpoint));
                 }
             }
         }
diff --git a/test/unit/org/apache/cassandra/gms/ExpireEndpointTest.java b/test/unit/org/apache/cassandra/gms/ExpireEndpointTest.java
new file mode 100644
index 0000000..e7a1a64
--- /dev/null
+++ b/test/unit/org/apache/cassandra/gms/ExpireEndpointTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.gms;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.UUID;
+
+import org.junit.Test;
+
+import org.apache.cassandra.service.StorageService;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class ExpireEndpointTest
+{
+    @Test
+    public void testExpireEndpoint() throws UnknownHostException
+    {
+        InetAddress hostAddress = InetAddress.getByName("127.0.0.2");
+        UUID hostId = UUID.randomUUID();
+        long expireTime = System.currentTimeMillis() - 1;
+
+        Gossiper.instance.initializeNodeUnsafe(hostAddress, hostId, 1);
+
+        EndpointState endpointState = Gossiper.instance.getEndpointStateForEndpoint(hostAddress);
+        Gossiper.runInGossipStageBlocking(() -> Gossiper.instance.markDead(hostAddress, endpointState));
+        endpointState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.removedNonlocal(hostId, expireTime));
+        Gossiper.instance.addExpireTimeForEndpoint(hostAddress, expireTime);
+
+        assertTrue("Expiring endpoint not unreachable before status check", Gossiper.instance.getUnreachableMembers().contains(hostAddress));
+
+        Gossiper.instance.doStatusCheck();
+
+        assertFalse("Expired endpoint still part of live members", Gossiper.instance.getLiveMembers().contains(hostAddress));
+        assertFalse("Expired endpoint still part of unreachable members", Gossiper.instance.getUnreachableMembers().contains(hostAddress));
+        assertNull("Expired endpoint still contain endpoint state", Gossiper.instance.getEndpointStateForEndpoint(hostAddress));
+    }
+}


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