summaryrefslogtreecommitdiffstats
path: root/zookeeper-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2021-02-19 11:40:46 +0100
committerGitHub <noreply@github.com>2021-02-19 11:40:46 +0100
commitd17f332e2d7cf3ef46d2631a95ced792277c1242 (patch)
tree54cf2a3457f814eb01462f36efe5ddd2d122f998 /zookeeper-server
parent4445201826c39ae1b8e6518e8a3c35e27d9e8ba6 (diff)
parent58a829cd024b3ee088aec14952969f3c686b7b8a (diff)
Merge pull request #16585 from vespa-engine/hmusum/die-if-zookeeper-shutdown-takes-too-long
Die if waiting for shutdown takes longer than 1 minute, and log when …
Diffstat (limited to 'zookeeper-server')
-rw-r--r--zookeeper-server/zookeeper-server-3.6.2/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/zookeeper-server/zookeeper-server-3.6.2/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java b/zookeeper-server/zookeeper-server-3.6.2/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java
index 86325f587eb..ba11286404a 100644
--- a/zookeeper-server/zookeeper-server-3.6.2/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java
+++ b/zookeeper-server/zookeeper-server-3.6.2/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java
@@ -8,6 +8,9 @@ import org.apache.zookeeper.server.quorum.QuorumPeerMain;
import java.io.IOException;
import java.nio.file.Path;
+import java.time.Duration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Starts/stops a ZooKeeper server. Extends QuorumPeerMain to be able to call initializeAndRun() and wraps
@@ -17,15 +20,19 @@ import java.nio.file.Path;
*/
class VespaQuorumPeer extends QuorumPeerMain {
+ private static final Logger log = java.util.logging.Logger.getLogger(Reconfigurer.class.getName());
+ private static final Duration timeToWaitForShutdown = Duration.ofSeconds(60);
+
public void start(Path path) {
initializeAndRun(new String[]{ path.toFile().getAbsolutePath()});
}
public void shutdown() {
if (quorumPeer != null) {
+ log.log(Level.INFO, "Shutting down ZooKeeper server");
try {
quorumPeer.shutdown();
- quorumPeer.join(); // Wait for shutdown to complete
+ quorumPeer.join(timeToWaitForShutdown.toMillis()); // Wait for shutdown to complete
} catch (RuntimeException|InterruptedException e) {
// If shutdown fails, we have no other option than forcing the JVM to stop and letting it be restarted.
//