org.apache.cassandra.gms

## Class Gossiper

- java.lang.Object
- - 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. Upon hearing a GossipShutdownMessage, this module will instantly mark the remote node as down in the Failure Detector.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `aVeryLongTime`
    `static Gossiper` | `instance`
    `static int` | `intervalInMillis`
    `static int` | `QUARANTINE_DELAY`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addExpireTimeForEndpoint(java.net.InetAddress endpoint, long expireTime)`
    `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, java.util.UUID hostId, java.util.UUID localHostId)` 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 'removenode' invoked
    `void` | `advertiseTokenRemoved(java.net.InetAddress endpoint, java.util.UUID hostId)` Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN This should only be called after advertiseRemoving
    `protected void` | `checkSeedContact(java.net.InetAddress ep)`
    `int` | `compareEndpointStartup(java.net.InetAddress addr1, java.net.InetAddress addr2)` determine which endpoint started up earlier
    `static long` | `computeExpireTime()`
    `void` | `convict(java.net.InetAddress endpoint, double phi)` This method is part of IFailureDetectionEventListener interface.
    `void` | `doShadowRound()` Do a single 'shadow' round of gossip, where we do not modify any state Only used when replacing a node, to get and assume its states
    `protected void` | `finishShadowRound()`
    `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()`
    `protected long` | `getExpireTimeForEndpoint(java.net.InetAddress endpoint)`
    `java.util.UUID` | `getHostId(java.net.InetAddress endpoint)`
    `java.util.Set<java.net.InetAddress>` | `getLiveMembers()`
    `java.util.Set<java.net.InetAddress>` | `getLiveTokenOwners()`
    `java.util.Set<java.net.InetAddress>` | `getUnreachableMembers()`
    `void` | `initializeNodeUnsafe(java.net.InetAddress addr, java.util.UUID uuid, int generationNbr)`
    `void` | `injectApplicationState(java.net.InetAddress endpoint, ApplicationState state, VersionedValue value)`
    `java.lang.Boolean` | `isDeadState(EndpointState epState)`
    `boolean` | `isEnabled()`
    `boolean` | `isFatClient(java.net.InetAddress endpoint)`
    `protected boolean` | `isInShadowRound()`
    `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` | `replacedEndpoint(java.net.InetAddress endpoint)` Remove the Endpoint and evict immediately, to avoid gossiping about this node.
    `void` | `resetEndpointStateMap()`
    `boolean` | `seenAnySeed()`
    `void` | `start(int generationNumber)`
    `void` | `start(int generationNbr, java.util.Map<ApplicationState,VersionedValue> preloadLocalStates)` Start the gossiper with the generation number, preloading the map of application states before starting
    `void` | `stop()`
    `void` | `unregister(IEndpointStateChangeSubscriber subscriber)` Unregister interest for state changes.
    `void` | `unsafeAssassinateEndpoint(java.lang.String address)` Do not call this method unless you know what you are doing.
    `boolean` | `usesHostId(java.net.InetAddress endpoint)`
    `boolean` | `usesVnodes(java.net.InetAddress endpoint)`

    - ### 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

    - #### instance

          public static final Gossiper instance

    - #### aVeryLongTime

          public static final long aVeryLongTime

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### checkSeedContact

          protected void checkSeedContact(java.net.InetAddress ep)

    - #### seenAnySeed

          public boolean seenAnySeed()

    - #### 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

    - #### getLiveMembers

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

    - #### getLiveTokenOwners

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

    - #### 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.
      Specified by:
        `convict` in interface `IFailureDetectionEventListener`
      Parameters:
        `endpoint` - end point that is 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

    - #### replacedEndpoint

          public void replacedEndpoint(java.net.InetAddress endpoint)

      Remove the Endpoint and evict immediately, to avoid gossiping about this node. This should only be called when a token is taken over by a new IP address.
      Parameters:
        `endpoint` - The endpoint that has been replaced

    - #### advertiseRemoving

          public void advertiseRemoving(java.net.InetAddress endpoint,
                               java.util.UUID hostId,
                               java.util.UUID localHostId)

      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 'removenode' invoked
      Parameters:
        `endpoint` - - the endpoint being removed
        `hostId` - - the ID of the host being removed
        `localHostId` - - my own host ID for replication coordination

    - #### advertiseTokenRemoved

          public void advertiseTokenRemoved(java.net.InetAddress endpoint,
                                   java.util.UUID hostId)

      Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN This should only be called after advertiseRemoving
      Parameters:
        `endpoint` -
        `hostId` -

    - #### unsafeAssassinateEndpoint

          public void unsafeAssassinateEndpoint(java.lang.String address)
                                         throws java.net.UnknownHostException

      Do not call this method unless you know what you are doing. It will try extremely hard to obliterate any endpoint from the ring, even if it does not know about it. This should only ever be called by human via JMX.
      Specified by:
        `unsafeAssassinateEndpoint` in interface `GossiperMBean`
      Parameters:
        `address` -
      Throws:
        `java.net.UnknownHostException`

    - #### isKnownEndpoint

          public boolean isKnownEndpoint(java.net.InetAddress endpoint)

    - #### getCurrentGenerationNumber

          public int getCurrentGenerationNumber(java.net.InetAddress endpoint)

    - #### isFatClient

          public boolean isFatClient(java.net.InetAddress endpoint)

    - #### getExpireTimeForEndpoint

          protected long getExpireTimeForEndpoint(java.net.InetAddress endpoint)

    - #### getEndpointStateForEndpoint

          public EndpointState getEndpointStateForEndpoint(java.net.InetAddress ep)

    - #### resetEndpointStateMap

          public void resetEndpointStateMap()

    - #### getEndpointStates

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

    - #### usesHostId

          public boolean usesHostId(java.net.InetAddress endpoint)

    - #### usesVnodes

          public boolean usesVnodes(java.net.InetAddress endpoint)

    - #### getHostId

          public java.util.UUID getHostId(java.net.InetAddress endpoint)

    - #### 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 generationNumber)

    - #### start

          public void start(int generationNbr,
                   java.util.Map<ApplicationState,VersionedValue> preloadLocalStates)

      Start the gossiper with the generation number, preloading the map of application states before starting

    - #### doShadowRound

          public void doShadowRound()

      Do a single 'shadow' round of gossip, where we do not modify any state Only used when replacing a node, to get and assume its states

    - #### 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()

    - #### finishShadowRound

          protected void finishShadowRound()

    - #### isInShadowRound

          protected boolean isInShadowRound()

    - #### initializeNodeUnsafe

          public void initializeNodeUnsafe(java.net.InetAddress addr,
                                  java.util.UUID uuid,
                                  int generationNbr)

    - #### injectApplicationState

          public void injectApplicationState(java.net.InetAddress endpoint,
                                    ApplicationState state,
                                    VersionedValue value)

    - #### 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`

    - #### addExpireTimeForEndpoint

          public void addExpireTimeForEndpoint(java.net.InetAddress endpoint,
                                      long expireTime)

    - #### computeExpireTime

          public static long computeExpireTime()

Copyright © 2014 The Apache Software Foundation