From 8d6ed07b5bb97c6b82fd8962061f7c38439fb3aa Mon Sep 17 00:00:00 2001 From: Jason Brown Date: Fri, 12 Apr 2013 09:36:19 -0700 Subject: [PATCH] CASSANDRA-5459: remove node from seeds when it completely leaves the cluster. This version slightly refactors Gossiper by pulling th seeds list building code out of start() and into a shared method that removeEndpoint() will call. Also, reload the seeds list, then remove the dead node. --- .../org/apache/cassandra/gms/Gossiper.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java index 997ff71ca0..6302cc685f 100644 --- a/src/java/org/apache/cassandra/gms/Gossiper.java +++ b/src/java/org/apache/cassandra/gms/Gossiper.java @@ -310,6 +310,13 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onRemove(endpoint); + if(seeds.contains(endpoint)) + { + buildSeedsList(); + seeds.remove(endpoint); + logger.info("removed {} from seeds, updated seeds list = {}", endpoint, seeds); + } + liveEndpoints.remove(endpoint); unreachableEndpoints.remove(endpoint); // do not remove endpointState until the quarantine expires @@ -1064,15 +1071,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean */ public void start(int generationNbr) { - /* Get the seeds from the config and initialize them. */ - Set seedHosts = DatabaseDescriptor.getSeeds(); - for (InetAddress seed : seedHosts) - { - if (seed.equals(FBUtilities.getBroadcastAddress())) - continue; - seeds.add(seed); - } - + buildSeedsList(); /* initialize the heartbeat state for this localEndpoint */ maybeInitializeLocalState(generationNbr); EndpointState localState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); @@ -1088,6 +1087,16 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean TimeUnit.MILLISECONDS); } + private void buildSeedsList() + { + for (InetAddress seed : DatabaseDescriptor.getSeeds()) + { + if (seed.equals(FBUtilities.getBroadcastAddress())) + continue; + seeds.add(seed); + } + } + // initialize local HB state if needed. public void maybeInitializeLocalState(int generationNbr) {