org.apache.cassandra.gms
Class Gossiper

java.lang.Object
  extended by org.apache.cassandra.gms.Gossiper
All Implemented Interfaces:
GossiperMBean, IFailureDetectionEventListener

public class Gossiper
extends java.lang.Object
implements IFailureDetectionEventListener, GossiperMBean

This module is responsible for Gossiping information for the local endpoint. This abstraction maintains the list of live and dead endpoints. Periodically i.e. every 1 second this module chooses a random node and initiates a round of Gossip with it. A round of Gossip involves 3 rounds of messaging. For instance if node A wants to initiate a round of Gossip with node B it starts off by sending node B a GossipDigestSynMessage. Node B on receipt of this message sends node A a GossipDigestAckMessage. On receipt of this message node A sends node B a GossipDigestAck2Message which completes a round of Gossip. This module as and when it hears one of the three above mentioned messages updates the Failure Detector with the liveness information.


Field Summary
static Gossiper instance
           
static int intervalInMillis
           
static int QUARANTINE_DELAY
           
 
Method Summary
 void addLocalApplicationState(ApplicationState state, VersionedValue value)
           
 void addSavedEndpoint(java.net.InetAddress ep)
          Add an endpoint we knew about previously, but whose state is unknown
 void advertiseRemoving(java.net.InetAddress endpoint, Token token, Token mytoken, int delay)
          This method will begin removing an existing endpoint from the cluster by spoofing its state This should never be called unless this coordinator has had 'removetoken' invoked
 void advertiseTokenRemoved(java.net.InetAddress endpoint, Token token)
          Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN This should only be called after advertiseRemoving
 int compareEndpointStartup(java.net.InetAddress addr1, java.net.InetAddress addr2)
          determine which endpoint started up earlier
 void convict(java.net.InetAddress endpoint, double phi)
          This method is part of IFailureDetectionEventListener interface.
 int getCurrentGenerationNumber(java.net.InetAddress endpoint)
           
 int getCurrentGenerationNumber(java.lang.String address)
           
 long getEndpointDowntime(java.net.InetAddress ep)
           
 long getEndpointDowntime(java.lang.String address)
           
 EndpointState getEndpointStateForEndpoint(java.net.InetAddress ep)
           
 java.util.Set<java.util.Map.Entry<java.net.InetAddress,EndpointState>> getEndpointStates()
           
 java.util.Set<java.net.InetAddress> getLiveMembers()
           
 java.util.Set<java.net.InetAddress> getUnreachableMembers()
           
 java.lang.Integer getVersion(java.net.InetAddress address)
           
 int getVersion(java.lang.String address)
           
 void initializeNodeUnsafe(java.net.InetAddress addr, int generationNbr)
          This should *only* be used for testing purposes.
 java.lang.Boolean isDeadState(EndpointState epState)
           
 boolean isEnabled()
           
 boolean isKnownEndpoint(java.net.InetAddress endpoint)
           
 void maybeInitializeLocalState(int generationNbr)
           
 void register(IEndpointStateChangeSubscriber subscriber)
          Register for interesting state changes.
 void removeEndpoint(java.net.InetAddress endpoint)
          Removes the endpoint from Gossip but retains endpoint state
 void resetVersion(java.net.InetAddress endpoint)
           
 void setVersion(java.net.InetAddress address, int version)
           
 void start(int generationNbr)
          Start the gossiper with the generation # retrieved from the System table
 void stop()
           
 void unregister(IEndpointStateChangeSubscriber subscriber)
          Unregister interest for state changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intervalInMillis

public static final int intervalInMillis
See Also:
Constant Field Values

QUARANTINE_DELAY

public static final int QUARANTINE_DELAY
See Also:
Constant Field Values

instance

public static final Gossiper instance
Method Detail

register

public void register(IEndpointStateChangeSubscriber subscriber)
Register for interesting state changes.

Parameters:
subscriber - module which implements the IEndpointStateChangeSubscriber

unregister

public void unregister(IEndpointStateChangeSubscriber subscriber)
Unregister interest for state changes.

Parameters:
subscriber - module which implements the IEndpointStateChangeSubscriber

setVersion

public void setVersion(java.net.InetAddress address,
                       int version)

resetVersion

public void resetVersion(java.net.InetAddress endpoint)

getVersion

public java.lang.Integer getVersion(java.net.InetAddress address)

getLiveMembers

public java.util.Set<java.net.InetAddress> getLiveMembers()

getUnreachableMembers

public java.util.Set<java.net.InetAddress> getUnreachableMembers()

getEndpointDowntime

public long getEndpointDowntime(java.net.InetAddress ep)

convict

public void convict(java.net.InetAddress endpoint,
                    double phi)
This method is part of IFailureDetectionEventListener interface. This is invoked by the Failure Detector when it convicts an end point. param @ endpoint end point that is convicted.

Specified by:
convict in interface IFailureDetectionEventListener
Parameters:
endpoint - endpoint to be convicted
phi - the value of phi with with ep was convicted

removeEndpoint

public void removeEndpoint(java.net.InetAddress endpoint)
Removes the endpoint from Gossip but retains endpoint state


advertiseRemoving

public void advertiseRemoving(java.net.InetAddress endpoint,
                              Token token,
                              Token mytoken,
                              int delay)
This method will begin removing an existing endpoint from the cluster by spoofing its state This should never be called unless this coordinator has had 'removetoken' invoked

Parameters:
endpoint - - the endpoint being removed
token - - the token being removed
mytoken - - my own token for replication coordination
delay -

advertiseTokenRemoved

public void advertiseTokenRemoved(java.net.InetAddress endpoint,
                                  Token token)
Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN This should only be called after advertiseRemoving

Parameters:
endpoint -
token -

isKnownEndpoint

public boolean isKnownEndpoint(java.net.InetAddress endpoint)

getCurrentGenerationNumber

public int getCurrentGenerationNumber(java.net.InetAddress endpoint)

getEndpointStateForEndpoint

public EndpointState getEndpointStateForEndpoint(java.net.InetAddress ep)

getEndpointStates

public java.util.Set<java.util.Map.Entry<java.net.InetAddress,EndpointState>> getEndpointStates()

compareEndpointStartup

public int compareEndpointStartup(java.net.InetAddress addr1,
                                  java.net.InetAddress addr2)
determine which endpoint started up earlier


isDeadState

public java.lang.Boolean isDeadState(EndpointState epState)

start

public void start(int generationNbr)
Start the gossiper with the generation # retrieved from the System table


maybeInitializeLocalState

public void maybeInitializeLocalState(int generationNbr)

addSavedEndpoint

public void addSavedEndpoint(java.net.InetAddress ep)
Add an endpoint we knew about previously, but whose state is unknown


addLocalApplicationState

public void addLocalApplicationState(ApplicationState state,
                                     VersionedValue value)

stop

public void stop()

isEnabled

public boolean isEnabled()

initializeNodeUnsafe

public void initializeNodeUnsafe(java.net.InetAddress addr,
                                 int generationNbr)
This should *only* be used for testing purposes.


getVersion

public int getVersion(java.lang.String address)
               throws java.net.UnknownHostException
Specified by:
getVersion in interface GossiperMBean
Throws:
java.net.UnknownHostException

getEndpointDowntime

public long getEndpointDowntime(java.lang.String address)
                         throws java.net.UnknownHostException
Specified by:
getEndpointDowntime in interface GossiperMBean
Throws:
java.net.UnknownHostException

getCurrentGenerationNumber

public int getCurrentGenerationNumber(java.lang.String address)
                               throws java.net.UnknownHostException
Specified by:
getCurrentGenerationNumber in interface GossiperMBean
Throws:
java.net.UnknownHostException


Copyright © 2011 The Apache Software Foundation