Skip to content

Commit

Permalink
Add jmx method to forcibly remove endpoints.
Browse files Browse the repository at this point in the history
Patch by brandonwilliams reviewed by Paul Cannon for CASSANDRA-3337.

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-1.0@1212556 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
driftx committed Dec 9, 2011
1 parent 114314d commit bf0f80c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/java/org/apache/cassandra/gms/Gossiper.java
Expand Up @@ -432,6 +432,66 @@ public void advertiseTokenRemoved(InetAddress endpoint, Token token)
}
}

/**
* 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.
* @param address
* @throws UnknownHostException
*/
public void unsafeAssassinateEndpoint(String address) throws UnknownHostException
{
InetAddress endpoint = InetAddress.getByName(address);
EndpointState epState = endpointStateMap.get(endpoint);
Token token = null;
logger.warn("Assassinating {} via gossip", endpoint);
if (epState == null)
{
epState = new EndpointState(new HeartBeatState((int)((System.currentTimeMillis() + 60000) / 1000), 9999));
}
else
{
try
{
token = StorageService.instance.getTokenMetadata().getToken(endpoint);
}
catch (AssertionError e)
{
}
int generation = epState.getHeartBeatState().getGeneration();
logger.info("Sleeping for " + StorageService.RING_DELAY + "ms to ensure " + endpoint + " does not change");
try
{
Thread.sleep(StorageService.RING_DELAY);
}
catch (InterruptedException e)
{
throw new AssertionError(e);
}
// make sure it did not change
epState = endpointStateMap.get(endpoint);
if (epState.getHeartBeatState().getGeneration() != generation)
throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it");
epState.updateTimestamp(); // make sure we don't evict it too soon
epState.getHeartBeatState().forceNewerGenerationUnsafe();
}
if (token == null)
token = StorageService.instance.getBootstrapToken();
// do not pass go, do not collect 200 dollars, just gtfo
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.left(token, computeExpireTime()));
handleMajorStateChange(endpoint, epState);
try
{
Thread.sleep(intervalInMillis * 4);
}
catch (InterruptedException e)
{
throw new AssertionError(e);
}
logger.warn("Finished killing {}", endpoint);
}

public boolean isKnownEndpoint(InetAddress endpoint)
{
return endpointStateMap.containsKey(endpoint);
Expand Down
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/gms/GossiperMBean.java
Expand Up @@ -28,4 +28,6 @@ public interface GossiperMBean

public int getCurrentGenerationNumber(String address) throws UnknownHostException;

public void unsafeAssassinateEndpoint(String address) throws UnknownHostException;

}

0 comments on commit bf0f80c

Please sign in to comment.