use of org.apache.zookeeper.server.quorum.Election in project zookeeper by apache.
the class QuorumBase method shutdown.
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);
}
}
use of org.apache.zookeeper.server.quorum.Election in project zookeeper by apache.
the class QuorumUtil method shutdown.
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);
}
}
use of org.apache.zookeeper.server.quorum.Election in project rest.li by linkedin.
the class ZKPeer method shutdown.
public void shutdown(boolean removeDirectories) throws IOException {
try {
String peerType = "";
if (_peer.leader != null) {
peerType = "leader";
}
_log.info("Shutting down quorum " + peerType + " peer #" + getPeerPortsInfo());
try {
_peer.shutdown();
} catch (Exception e) {
_log.debug("Exception during peer " + _peer.getName() + " shutdown.", e);
}
Election e = _peer.getElectionAlg();
if (e != null) {
_log.debug("Shutting down " + _peer.getName() + " leader election ");
e.shutdown();
} else {
_log.debug("No election available to shutdown ");
}
_log.debug("Waiting for " + _peer.getName() + " to exit thread");
_peer.join(60000);
if (_peer.isAlive()) {
fail("QP failed to shutdown in 60 seconds: " + _peer.getName());
}
if (removeDirectories) {
FileUtils.deleteDirectory(_dataDir);
FileUtils.deleteDirectory(_logDir);
}
} catch (InterruptedException e) {
_log.debug("Shutdown interrupted: " + _peer.getName(), e);
}
try {
waitForServerDown(TIMEOUT);
} catch (Exception e) {
}
}
Aggregations