public void shutdown(int id) { QuorumPeer qp = getPeer(id).peer; try { LOG.info("Shutting down quorum peer " + qp.getName()); qp.shutdown(); Election e = qp.getElectionAlg(); if (e != null) { LOG.info("Shutting down leader election " + qp.getName()); e.shutdown(); } else { LOG.info("No election available to shutdown " + qp.getName()); } LOG.info("Waiting for " + qp.getName() + " to exit thread"); qp.join(30000); if (qp.isAlive()) { Assert.fail("QP failed to shutdown in 30 seconds: " + qp.getName()); } } catch (InterruptedException e) { LOG.debug("QP interrupted: " + qp.getName(), e); } }
public static void shutdown(QuorumPeer qp) { if (qp == null) { return; } try { LOG.info("Shutting down quorum peer " + qp.getName()); qp.shutdown(); Election e = qp.getElectionAlg(); if (e != null) { LOG.info("Shutting down leader election " + qp.getName()); e.shutdown(); } else { LOG.info("No election available to shutdown " + qp.getName()); } LOG.info("Waiting for " + qp.getName() + " to exit thread"); long readTimeout = qp.getTickTime() * qp.getInitLimit(); long connectTimeout = qp.getTickTime() * qp.getSyncLimit(); long maxTimeout = Math.max(readTimeout, connectTimeout); maxTimeout = Math.max(maxTimeout, ClientBase.CONNECTION_TIMEOUT); qp.join(maxTimeout * 2); if (qp.isAlive()) { Assert.fail("QP failed to shutdown in " + (maxTimeout * 2) + " seconds: " + qp.getName()); } } catch (InterruptedException e) { LOG.debug("QP interrupted: " + qp.getName(), e); } }
@Override public void runFromConfig(QuorumPeerConfig config) throws IOException, AdminServerException { quorumPeer = new CustomQuorumPeer(config.getQuorumVerifier().getAllMembers(), config.getDataDir(), config.getDataLogDir(), config.getClientPortAddress().getPort(), config.getElectionAlg(), config.getServerId(), config.getTickTime(), config.getInitLimit(), config.getSyncLimit()); quorumPeer.setConfigFileName(config.getConfigFilename()); quorumPeer.start(); try { quorumPeer.join(); } catch (InterruptedException e) { LOG.warn("Quorum Peer interrupted", e); } } }
quorumPeer.join(); } catch (InterruptedException e) {
quorumPeer.join(); } catch (InterruptedException e) {
@Override public void destroy() throws Exception { peer.shutdown(); peer.join(); }
@Override public void destroy() throws Exception { peer.shutdown(); peer.join(); }
/** * Stop quorum and/or zookeeper. * @throws InterruptedException */ public void stop() throws InterruptedException { if (quorumPeer != null) { quorumPeer.shutdown(); quorumPeer.join(); } else if (serverRunner != null) { serverRunner.stop(); } else { LOG.warn("Neither quorum nor server is set"); } } }
quorumPeer.join(); } catch (InterruptedException e) {