public class Gossiper extends java.lang.Object implements IFailureDetectionEventListener, GossiperMBean
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 |
Modifier and Type | Method and Description |
---|---|
void |
addExpireTimeForEndpoint(java.net.InetAddress endpoint,
long expireTime) |
void |
addLocalApplicationState(ApplicationState applicationState,
VersionedValue value) |
void |
addLocalApplicationStates(java.util.List<Pair<ApplicationState,VersionedValue>> states) |
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
|
void |
assassinateEndpoint(java.lang.String address)
Do not call this method unless you know what you are doing.
|
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.
|
java.util.Map<java.net.InetAddress,EndpointState> |
doShadowRound()
Do a single 'shadow' round of gossip by retrieving endpoint states that will be stored exclusively in the
map return value, instead of endpointStateMap.
|
protected void |
finishShadowRound(java.util.Map<java.net.InetAddress,EndpointState> epStateMap) |
void |
forceNewerGeneration() |
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.UUID |
getHostId(java.net.InetAddress endpoint,
java.util.Map<java.net.InetAddress,EndpointState> epStates) |
java.util.Set<java.net.InetAddress> |
getLiveMembers() |
java.util.Set<java.net.InetAddress> |
getLiveTokenOwners() |
java.util.Set<java.net.InetAddress> |
getUnreachableMembers() |
java.util.Set<java.net.InetAddress> |
getUnreachableTokenOwners() |
void |
initializeNodeUnsafe(java.net.InetAddress addr,
java.util.UUID uuid,
int generationNbr) |
void |
injectApplicationState(java.net.InetAddress endpoint,
ApplicationState state,
VersionedValue value) |
boolean |
isAlive(java.net.InetAddress endpoint) |
boolean |
isDeadState(EndpointState epState) |
boolean |
isEnabled() |
boolean |
isGossipOnlyMember(java.net.InetAddress endpoint) |
protected boolean |
isInShadowRound() |
boolean |
isKnownEndpoint(java.net.InetAddress endpoint) |
boolean |
isSafeForBootstrap(java.net.InetAddress endpoint,
java.util.Map<java.net.InetAddress,EndpointState> epStates)
Check if this endpoint can safely bootstrap into the cluster.
|
boolean |
isSilentShutdownState(EndpointState epState) |
protected void |
markAsShutdown(java.net.InetAddress 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(java.net.InetAddress addr,
EndpointState localState) |
void |
maybeInitializeLocalState(int generationNbr) |
void |
realMarkAlive(java.net.InetAddress addr,
EndpointState localState) |
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 |
replacementQuarantine(java.net.InetAddress endpoint)
Quarantine endpoint specifically for replacement purposes.
|
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) |
void |
unregister(IEndpointStateChangeSubscriber subscriber)
Unregister interest for state changes.
|
void |
unsafeAssassinateEndpoint(java.lang.String address) |
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 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<java.net.InetAddress> getLiveMembers()
public java.util.Set<java.net.InetAddress> getLiveTokenOwners()
public java.util.Set<java.net.InetAddress> getUnreachableMembers()
public java.util.Set<java.net.InetAddress> getUnreachableTokenOwners()
public long getEndpointDowntime(java.net.InetAddress ep)
public void convict(java.net.InetAddress 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(java.net.InetAddress endpoint)
endpoint
- endpoint that has shut itself downpublic void removeEndpoint(java.net.InetAddress endpoint)
public void replacementQuarantine(java.net.InetAddress endpoint)
endpoint
- public void replacedEndpoint(java.net.InetAddress endpoint)
endpoint
- The endpoint that has been replacedpublic void advertiseRemoving(java.net.InetAddress 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(java.net.InetAddress 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(java.net.InetAddress endpoint)
public int getCurrentGenerationNumber(java.net.InetAddress endpoint)
public boolean isGossipOnlyMember(java.net.InetAddress endpoint)
public boolean isSafeForBootstrap(java.net.InetAddress endpoint, java.util.Map<java.net.InetAddress,EndpointState> epStates)
endpoint
- - the endpoint to checkepStates
- - endpoint states in the clusterprotected long getExpireTimeForEndpoint(java.net.InetAddress endpoint)
public EndpointState getEndpointStateForEndpoint(java.net.InetAddress ep)
public java.util.Set<java.util.Map.Entry<java.net.InetAddress,EndpointState>> getEndpointStates()
public java.util.UUID getHostId(java.net.InetAddress endpoint)
public java.util.UUID getHostId(java.net.InetAddress endpoint, java.util.Map<java.net.InetAddress,EndpointState> epStates)
public int compareEndpointStartup(java.net.InetAddress addr1, java.net.InetAddress addr2)
public void realMarkAlive(java.net.InetAddress addr, EndpointState localState)
public void markDead(java.net.InetAddress addr, EndpointState localState)
public boolean isAlive(java.net.InetAddress endpoint)
public boolean isDeadState(EndpointState epState)
public boolean isSilentShutdownState(EndpointState epState)
public void start(int generationNumber)
public void start(int generationNbr, java.util.Map<ApplicationState,VersionedValue> preloadLocalStates)
public java.util.Map<java.net.InetAddress,EndpointState> doShadowRound()
finishShadowRound(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.public void maybeInitializeLocalState(int generationNbr)
public void forceNewerGeneration()
public void addSavedEndpoint(java.net.InetAddress ep)
public void addLocalApplicationState(ApplicationState applicationState, VersionedValue value)
public void addLocalApplicationStates(java.util.List<Pair<ApplicationState,VersionedValue>> states)
public void stop()
public boolean isEnabled()
protected void finishShadowRound(java.util.Map<java.net.InetAddress,EndpointState> epStateMap)
protected boolean isInShadowRound()
public void initializeNodeUnsafe(java.net.InetAddress addr, java.util.UUID uuid, int generationNbr)
public void injectApplicationState(java.net.InetAddress 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(java.net.InetAddress endpoint, long expireTime)
public static long computeExpireTime()
public void stopShutdownAndWait(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
Copyright © 2019 The Apache Software Foundation