Skip to content

Commit

Permalink
Wait until the reset is complete before starting another server (#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelZaytsev committed Jun 26, 2023
1 parent ad01838 commit 513cdbe
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static org.corfudb.common.metrics.micrometer.MeterRegistryProvider.MeterRegistryInitializer.initServerMetrics;
Expand All @@ -38,6 +39,7 @@
public class CorfuServer {
private static final Duration TIMEOUT = Duration.ofSeconds(3);

private static volatile CountDownLatch resetLatch;
// Active Corfu Server.
private static volatile CorfuServerNode activeServer;

Expand Down Expand Up @@ -127,6 +129,7 @@ private static void startServer(Map<String, Object> opts) throws InterruptedExce

// Manages the lifecycle of the Corfu Server.
while (!shutdownServer) {
resetLatch = new CountDownLatch(1);
ServerContext serverContext;
try {
serverContext = new ServerContext(opts);
Expand All @@ -152,7 +155,9 @@ private static void startServer(Map<String, Object> opts) throws InterruptedExce
}

if (!shutdownServer) {
log.info("main: Server restarting.");
log.info("main: Waiting until restart is complete.");
resetLatch.await();
log.info("main: Server restarted.");
}
}

Expand Down Expand Up @@ -298,6 +303,7 @@ static void restartServer(boolean resetData) {

log.info("RestartServer: Shutting down corfu server");
activeServer.close();
resetLatch.countDown();
log.info("RestartServer: Starting corfu server");
}

Expand Down

0 comments on commit 513cdbe

Please sign in to comment.