public class Gossiper extends java.lang.Object implements IFailureDetectionEventListener, GossiperMBean
Modifier and Type | Class and Description |
---|---|
static class |
Gossiper.Props |
Modifier and Type | Field and Description |
---|---|
static long |
aVeryLongTime |
static Gossiper |
instance |
static int |
intervalInMillis |
static java.lang.String |
MBEAN_NAME |
static int |
QUARANTINE_DELAY |
Constructor and Description |
---|
Gossiper(boolean registerJmx) |
Modifier and Type | Method and Description |
---|---|
void |
addExpireTimeForEndpoint(InetAddressAndPort endpoint,
long expireTime) |
void |
addLocalApplicationState(ApplicationState applicationState,
VersionedValue value) |
void |
addLocalApplicationStates(java.util.List<Pair<ApplicationState,VersionedValue>> states) |
void |
addSavedEndpoint(InetAddressAndPort ep)
Add an endpoint we knew about previously, but whose state is unknown
|
void |
advertiseRemoving(InetAddressAndPort 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(InetAddressAndPort endpoint,
java.util.UUID hostId)
Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN
This should only be called after advertiseRemoving
|
void |
applyStateLocally(java.util.Map<InetAddressAndPort,EndpointState> epStateMap) |
void |
assassinateEndpoint(java.lang.String address)
Do not call this method unless you know what you are doing.
|
void |
clearUnsafe() |
int |
compareEndpointStartup(InetAddressAndPort addr1,
InetAddressAndPort addr2)
determine which endpoint started up earlier
|
static long |
computeExpireTime() |
void |
convict(InetAddressAndPort endpoint,
double phi)
This method is part of IFailureDetectionEventListener interface.
|
java.util.Map<InetAddressAndPort,EndpointState> |
doShadowRound() |
java.util.Map<InetAddressAndPort,EndpointState> |
doShadowRound(java.util.Set<InetAddressAndPort> peers)
Do a single 'shadow' round of gossip by retrieving endpoint states that will be stored exclusively in the
map return value, instead of endpointStateMap.
|
void |
expireUpgradeFromVersion() |
void |
forceNewerGeneration() |
java.lang.String |
getApplicationState(InetAddressAndPort endpoint,
ApplicationState state)
The value for the provided application state for the provided endpoint as currently known by this Gossip instance.
|
int |
getCurrentGenerationNumber(InetAddressAndPort endpoint) |
int |
getCurrentGenerationNumber(java.lang.String address) |
int |
getEndpointCount() |
long |
getEndpointDowntime(InetAddressAndPort ep) |
long |
getEndpointDowntime(java.lang.String address) |
com.google.common.collect.ImmutableSet<InetAddressAndPort> |
getEndpoints() |
EndpointState |
getEndpointStateForEndpoint(InetAddressAndPort ep) |
protected long |
getExpireTimeForEndpoint(InetAddressAndPort endpoint) |
java.util.UUID |
getHostId(InetAddressAndPort endpoint) |
java.util.UUID |
getHostId(InetAddressAndPort endpoint,
java.util.Map<InetAddressAndPort,EndpointState> epStates) |
InetAddressAndPort |
getInternalAddressAndPort(InetAddressAndPort endpoint) |
java.util.Set<InetAddressAndPort> |
getLiveMembers() |
java.util.Set<InetAddressAndPort> |
getLiveTokenOwners() |
CassandraVersion |
getMinVersion(long delay,
java.util.concurrent.TimeUnit timeUnit) |
CassandraVersion |
getReleaseVersion(InetAddressAndPort ep) |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getReleaseVersionsWithPort()
Returns each node's database release version
|
java.util.UUID |
getSchemaVersion(InetAddressAndPort ep) |
java.util.List<java.lang.String> |
getSeeds()
JMX endpoint for getting the list of seeds from the node
|
java.util.Set<InetAddressAndPort> |
getUnreachableMembers() |
java.util.Set<InetAddressAndPort> |
getUnreachableTokenOwners() |
boolean |
hasMajorVersion3Nodes()
Returns
false only if the information about the version of each node in the cluster is available and
ALL the nodes are on 4.0+ (regardless of the patch version). |
void |
initializeNodeUnsafe(InetAddressAndPort addr,
java.util.UUID uuid,
int generationNbr) |
void |
initializeNodeUnsafe(InetAddressAndPort addr,
java.util.UUID uuid,
int netVersion,
int generationNbr) |
void |
initializeUnreachableNodeUnsafe(InetAddressAndPort addr)
Creates a new dead
EndpointState that is empty . |
void |
injectApplicationState(InetAddressAndPort endpoint,
ApplicationState state,
VersionedValue value) |
boolean |
isAdministrativelyInactiveState(EndpointState epState) |
boolean |
isAdministrativelyInactiveState(InetAddressAndPort endpoint) |
boolean |
isAlive(InetAddressAndPort endpoint) |
boolean |
isDeadState(EndpointState epState) |
boolean |
isEnabled() |
boolean |
isGossipOnlyMember(InetAddressAndPort endpoint) |
protected boolean |
isInShadowRound() |
boolean |
isKnownEndpoint(InetAddressAndPort endpoint) |
boolean |
isSafeForStartup(InetAddressAndPort endpoint,
java.util.UUID localHostUUID,
boolean isBootstrapping,
java.util.Map<InetAddressAndPort,EndpointState> epStates)
Check if this node can safely be started and join the ring.
|
boolean |
isSilentShutdownState(EndpointState epState) |
boolean |
isUpgradingFromVersionLowerThan(CassandraVersion referenceVersion)
Returns
true if there are nodes on version lower than the provided version |
protected void |
markAsShutdown(InetAddressAndPort endpoint)
This method is used to mark a node as shutdown; that is it gracefully exited on its own and told us about it
|
void |
markDead(InetAddressAndPort addr,
EndpointState localState) |
protected void |
maybeFinishShadowRound(InetAddressAndPort respondent,
boolean isInShadowRound,
java.util.Map<InetAddressAndPort,EndpointState> epStateMap) |
void |
maybeInitializeLocalState(int generationNbr) |
void |
realMarkAlive(InetAddressAndPort addr,
EndpointState localState) |
void |
register(IEndpointStateChangeSubscriber subscriber)
Register for interesting state changes.
|
java.util.List<java.lang.String> |
reloadSeeds()
JMX interface for triggering an update of the seed node list.
|
void |
removeEndpoint(InetAddressAndPort endpoint)
Removes the endpoint from Gossip but retains endpoint state
|
void |
replacedEndpoint(InetAddressAndPort endpoint)
Remove the Endpoint and evict immediately, to avoid gossiping about this node.
|
void |
replacementQuarantine(InetAddressAndPort endpoint)
Quarantine endpoint specifically for replacement purposes.
|
static void |
runInGossipStageBlocking(java.lang.Runnable runnable) |
boolean |
seenAnySeed() |
void |
setLastProcessedMessageAt(long timeInMillis) |
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 |
stopShutdownAndWait(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
sufficientForStartupSafetyCheck(java.util.Map<InetAddressAndPort,EndpointState> epStateMap) |
void |
unregister(IEndpointStateChangeSubscriber subscriber)
Unregister interest for state changes.
|
void |
unsafeAssassinateEndpoint(java.lang.String address) |
boolean |
waitForSchemaAgreement(long maxWait,
java.util.concurrent.TimeUnit unit,
java.util.function.BooleanSupplier abortCondition)
Blockingly wait for all live nodes to agree on the current schema version.
|
static void |
waitToSettle() |
public static final java.lang.String MBEAN_NAME
public static final int intervalInMillis
public static final int QUARANTINE_DELAY
public static final Gossiper instance
public static final long aVeryLongTime
public void clearUnsafe()
public void expireUpgradeFromVersion()
public void setLastProcessedMessageAt(long timeInMillis)
public boolean seenAnySeed()
public void register(IEndpointStateChangeSubscriber subscriber)
subscriber
- module which implements the IEndpointStateChangeSubscriberpublic void unregister(IEndpointStateChangeSubscriber subscriber)
subscriber
- module which implements the IEndpointStateChangeSubscriberpublic java.util.Set<InetAddressAndPort> getLiveMembers()
public java.util.Set<InetAddressAndPort> getLiveTokenOwners()
public java.util.Set<InetAddressAndPort> getUnreachableMembers()
public java.util.Set<InetAddressAndPort> getUnreachableTokenOwners()
public long getEndpointDowntime(InetAddressAndPort ep)
public static void runInGossipStageBlocking(java.lang.Runnable runnable)
public void convict(InetAddressAndPort endpoint, double phi)
convict
in interface IFailureDetectionEventListener
endpoint
- end point that is convicted.phi
- the value of phi with with ep was convictedprotected void markAsShutdown(InetAddressAndPort endpoint)
endpoint
- endpoint that has shut itself downpublic void removeEndpoint(InetAddressAndPort endpoint)
public void replacementQuarantine(InetAddressAndPort endpoint)
endpoint
- public void replacedEndpoint(InetAddressAndPort endpoint)
endpoint
- The endpoint that has been replacedpublic void advertiseRemoving(InetAddressAndPort endpoint, java.util.UUID hostId, java.util.UUID localHostId)
endpoint
- - the endpoint being removedhostId
- - the ID of the host being removedlocalHostId
- - my own host ID for replication coordinationpublic void advertiseTokenRemoved(InetAddressAndPort endpoint, java.util.UUID hostId)
endpoint
- hostId
- public void unsafeAssassinateEndpoint(java.lang.String address) throws java.net.UnknownHostException
unsafeAssassinateEndpoint
in interface GossiperMBean
java.net.UnknownHostException
public void assassinateEndpoint(java.lang.String address) throws java.net.UnknownHostException
assassinateEndpoint
in interface GossiperMBean
address
- java.net.UnknownHostException
public boolean isKnownEndpoint(InetAddressAndPort endpoint)
public int getCurrentGenerationNumber(InetAddressAndPort endpoint)
public boolean isGossipOnlyMember(InetAddressAndPort endpoint)
public boolean isSafeForStartup(InetAddressAndPort endpoint, java.util.UUID localHostUUID, boolean isBootstrapping, java.util.Map<InetAddressAndPort,EndpointState> epStates)
endpoint
- - the endpoint to checklocalHostUUID
- - the host id to checkisBootstrapping
- - whether the node intends to bootstrap when joiningepStates
- - endpoint states in the clusterprotected long getExpireTimeForEndpoint(InetAddressAndPort endpoint)
public EndpointState getEndpointStateForEndpoint(InetAddressAndPort ep)
public com.google.common.collect.ImmutableSet<InetAddressAndPort> getEndpoints()
public int getEndpointCount()
public java.util.UUID getHostId(InetAddressAndPort endpoint)
public java.util.UUID getHostId(InetAddressAndPort endpoint, java.util.Map<InetAddressAndPort,EndpointState> epStates)
public InetAddressAndPort getInternalAddressAndPort(InetAddressAndPort endpoint)
public java.lang.String getApplicationState(InetAddressAndPort endpoint, ApplicationState state)
endpoint
- the endpoint from which to get the endpoint state.state
- the endpoint state to get.state
for endpoint
, or null
if either
endpoint
is not known by Gossip or has no value for state
.public int compareEndpointStartup(InetAddressAndPort addr1, InetAddressAndPort addr2)
public void realMarkAlive(InetAddressAndPort addr, EndpointState localState)
public void markDead(InetAddressAndPort addr, EndpointState localState)
public boolean isAlive(InetAddressAndPort endpoint)
public boolean isDeadState(EndpointState epState)
public boolean isSilentShutdownState(EndpointState epState)
public boolean isAdministrativelyInactiveState(EndpointState epState)
public boolean isAdministrativelyInactiveState(InetAddressAndPort endpoint)
public void applyStateLocally(java.util.Map<InetAddressAndPort,EndpointState> epStateMap)
public void start(int generationNumber)
public void start(int generationNbr, java.util.Map<ApplicationState,VersionedValue> preloadLocalStates)
public java.util.Map<InetAddressAndPort,EndpointState> doShadowRound()
public java.util.Map<InetAddressAndPort,EndpointState> doShadowRound(java.util.Set<InetAddressAndPort> peers)
maybeFinishShadowRound(InetAddressAndPort, boolean, Map)
. This will update
endpointShadowStateMap
with received values, in order to return an immutable copy to the
caller of doShadowRound()
. Therefor only a single shadow round execution is permitted at
the same time.peers
- Additional peers to try gossiping with.public java.util.List<java.lang.String> reloadSeeds()
reloadSeeds
in interface GossiperMBean
public java.util.List<java.lang.String> getSeeds()
getSeeds
in interface GossiperMBean
public void maybeInitializeLocalState(int generationNbr)
public void forceNewerGeneration()
public void addSavedEndpoint(InetAddressAndPort ep)
public void addLocalApplicationState(ApplicationState applicationState, VersionedValue value)
public void addLocalApplicationStates(java.util.List<Pair<ApplicationState,VersionedValue>> states)
public void stop()
public boolean isEnabled()
public boolean sufficientForStartupSafetyCheck(java.util.Map<InetAddressAndPort,EndpointState> epStateMap)
protected void maybeFinishShadowRound(InetAddressAndPort respondent, boolean isInShadowRound, java.util.Map<InetAddressAndPort,EndpointState> epStateMap)
protected boolean isInShadowRound()
public void initializeUnreachableNodeUnsafe(InetAddressAndPort addr)
EndpointState
that is empty
. This is used during
host replacement for edge cases where the seed notified that the endpoint was empty, so need to add such state
into gossip explicitly (as empty endpoints are not gossiped outside of the shadow round).
see CASSANDRA-16213public void initializeNodeUnsafe(InetAddressAndPort addr, java.util.UUID uuid, int generationNbr)
public void initializeNodeUnsafe(InetAddressAndPort addr, java.util.UUID uuid, int netVersion, int generationNbr)
public void injectApplicationState(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value)
public long getEndpointDowntime(java.lang.String address) throws java.net.UnknownHostException
getEndpointDowntime
in interface GossiperMBean
java.net.UnknownHostException
public int getCurrentGenerationNumber(java.lang.String address) throws java.net.UnknownHostException
getCurrentGenerationNumber
in interface GossiperMBean
java.net.UnknownHostException
public void addExpireTimeForEndpoint(InetAddressAndPort endpoint, long expireTime)
public static long computeExpireTime()
@Nullable public CassandraVersion getReleaseVersion(InetAddressAndPort ep)
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getReleaseVersionsWithPort()
GossiperMBean
getReleaseVersionsWithPort
in interface GossiperMBean
@Nullable public java.util.UUID getSchemaVersion(InetAddressAndPort ep)
public static void waitToSettle()
public boolean waitForSchemaAgreement(long maxWait, java.util.concurrent.TimeUnit unit, java.util.function.BooleanSupplier abortCondition)
maxWait
- maximum time to wait for schema agreementunit
- TimeUnit of maxWaitpublic boolean hasMajorVersion3Nodes()
false
only if the information about the version of each node in the cluster is available and
ALL the nodes are on 4.0+ (regardless of the patch version).public boolean isUpgradingFromVersionLowerThan(CassandraVersion referenceVersion)
true
if there are nodes on version lower than the provided versionpublic void stopShutdownAndWait(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
@Nullable public CassandraVersion getMinVersion(long delay, java.util.concurrent.TimeUnit timeUnit)
Copyright © 2009- The Apache Software Foundation