Skip to content

Commit

Permalink
Nodetool Drain throws immediately if the server is not initialized (#584
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rhuffy authored Nov 21, 2024
1 parent 056d3ac commit 47abc3b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ private void handleStateRemoving(InetAddress endpoint, String[] pieces)
logger.info("Received removenode gossip about myself. Is this node rejoining after an explicit removenode?");
try
{
drain();
drainInternal();
}
catch (Exception e)
{
Expand Down Expand Up @@ -4602,11 +4602,22 @@ public String getDrainProgress()

/**
* Shuts node off to writes, empties memtables and the commit log.
* There are two differences between drain and the normal shutdown hook:
* - Drain waits for in-progress streaming to complete
* There is one difference between drain and the normal shutdown hook:
* - Drain flushes *all* columnfamilies (shutdown hook only flushes non-durable CFs)
*/
public synchronized void drain() throws IOException, InterruptedException, ExecutionException
public void drain() throws IOException, InterruptedException, ExecutionException
{
if (daemon.setupCompleted())
{
drainInternal();
}
else
{
throw new IllegalStateException("Cannot drain a node that is initializing or bootstrapping");
}
}

private synchronized void drainInternal() throws IOException, InterruptedException, ExecutionException
{
Stopwatch watch = Stopwatch.createStarted();

Expand Down

0 comments on commit 47abc3b

Please sign in to comment.