refuse to decomission if not in state NORMAL

patch by Jan Karlsson and Stefania for CASSANDRA-8741
This commit is contained in:
Stefania Alborghetti 2015-08-27 10:01:07 +08:00 committed by Jonathan Ellis
parent 517058febb
commit 5bc56c3e40
3 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,5 @@
2.0.17
* Disallow decommission when node is in drained state (CASSANDRA-8741)
* Backport CASSANDRA-8013 to 2.0 (CASSANDRA-10144)
* Make getFullyExpiredSSTables less expensive (CASSANDRA-9882)
* Add tool to find why expired sstables are not getting dropped (CASSANDRA-10015)

View File

@ -2963,6 +2963,8 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
throw new UnsupportedOperationException("local node is not a member of the token ring yet");
if (tokenMetadata.cloneAfterAllLeft().sortedTokens().size() < 2)
throw new UnsupportedOperationException("no other normal nodes in the ring; decommission would be pointless");
if (operationMode != Mode.NORMAL)
throw new UnsupportedOperationException("Node in " + operationMode + " state; wait for status to become normal or restart");
PendingRangeCalculatorService.instance.blockUntilFinished();
for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())

View File

@ -1366,7 +1366,8 @@ public class NodeCmd
System.err.println("Decommission will decommission the node you are connected to and does not take arguments!");
System.exit(1);
}
probe.decommission();
try { probe.decommission(); }
catch (UnsupportedOperationException e) { err("Unsupported operation: " + e.getMessage()); }
break;
case DRAIN :
@ -1678,6 +1679,12 @@ public class NodeCmd
System.exit(1);
}
private static void err(String useStr)
{
System.err.println(useStr);
System.exit(1);
}
private static void err(Exception e, String errStr)
{
System.err.println(errStr);