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.
This commit is contained in:
Jason Brown 2013-04-12 09:36:19 -07:00
parent d2eadba2a6
commit 8d6ed07b5b
1 changed files with 18 additions and 9 deletions

View File

@ -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<InetAddress> 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)
{