Remove node from seeds list when it permanently leaves the cluster
patch by jasobrown; freviewed by driftx for CASSANDRA-5459.


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

Branch: refs/heads/trunk
Commit: d7066f460aba7765c91ccc96582a447252b78a7b
Parents: ef5390b 8d6ed07
Author: Jason Brown <[email protected]>
Authored: Fri Apr 12 13:14:43 2013 -0700
Committer: Jason Brown <[email protected]>
Committed: Fri Apr 12 13:14:43 2013 -0700

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/Gossiper.java |   27 ++++++++++++------
 1 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7066f46/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/gms/Gossiper.java
index f333a57,6302cc6..79a64fb
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@@ -1009,25 -1065,13 +1016,17 @@@ public class Gossiper implements IFailu
          }
      }
  
 +    public void start(int generationNumber)
 +    {
 +        start(generationNumber, new HashMap<ApplicationState, 
VersionedValue>());
 +    }
 +
      /**
 -     * Start the gossiper with the generation # retrieved from the System
 -     * table
 +     * Start the gossiper with the generation number, preloading the map of 
application states before starting
       */
 -    public void start(int generationNbr)
 +    public void start(int generationNbr, Map<ApplicationState, 
VersionedValue> preloadLocalStates)
      {
-         /* 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());
@@@ -1045,13 -1087,27 +1044,23 @@@
                                                                
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.
 +    // initialize local HB state if needed, i.e., if gossiper has never been 
started before.
      public void maybeInitializeLocalState(int generationNbr)
      {
 -        EndpointState localState = 
endpointStateMap.get(FBUtilities.getBroadcastAddress());
 -        if ( localState == null )
 -        {
 -            HeartBeatState hbState = new HeartBeatState(generationNbr);
 -            localState = new EndpointState(hbState);
 -            localState.markAlive();
 -            endpointStateMap.put(FBUtilities.getBroadcastAddress(), 
localState);
 -        }
 +        HeartBeatState hbState = new HeartBeatState(generationNbr);
 +        EndpointState localState = new EndpointState(hbState);
 +        localState.markAlive();
 +        endpointStateMap.putIfAbsent(FBUtilities.getBroadcastAddress(), 
localState);
      }
  
  

Reply via email to