@Override
    public void shutdown(Duration timeout) {
        if (quorumPeer != null) {
            log.log(Level.FINE, "Shutting down ZooKeeper server");
            try {
                quorumPeer.shutdown();
                quorumPeer.join(timeout.toMillis()); // Wait for shutdown to complete
                if (quorumPeer.isAlive())
                    throw new IllegalStateException("Peer still alive after " + timeout);
            } catch (RuntimeException | InterruptedException e) {
                // If shutdown fails, we have no other option than forcing the JVM to stop and letting it be restarted.
                //
                // When a VespaZooKeeperServer component receives a new config, the container will try to start a new
                // server with the new config, this will fail until the old server is deconstructed. If the old server
                // fails to deconstruct/shutdown, the new one will never start and if that happens forcing a restart is
                // the better option.
                Process.logAndDie("Failed to shut down ZooKeeper server properly, forcing shutdown", e);
            }
        }
    }
Starts or stops a ZooKeeper server. Extends QuorumPeerMain to be able to call initializeAndRun() and wraps
exceptions so that it can be used by code that does not depend on ZooKeeper.

@author hmusum
zookeeper-server/zookeeper-server/src/main/java/com/yahoo/vespa/zookeeper/VespaQuorumPeer.java