Example usage for org.apache.zookeeper.server.quorum QuorumPeer getElectionAlg

List of usage examples for org.apache.zookeeper.server.quorum QuorumPeer getElectionAlg

Introduction

In this page you can find the example usage for org.apache.zookeeper.server.quorum QuorumPeer getElectionAlg.

Prototype

public Election getElectionAlg() 

Source Link

Document

Get an instance of LeaderElection

Usage

From source file:io.confluent.admin.utils.EmbeddedZookeeperEnsemble.java

License:Apache License

private void shutdown(QuorumPeer qp) {
    try {/*from  www. j a v  a  2 s.com*/
        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(30000L);
        if (qp.isAlive()) {
            Assert.fail("QP failed to shutdown in 30 seconds: " + qp.getName());
        }
    } catch (InterruptedException var2) {
        log.debug("QP interrupted: " + qp.getName(), var2);
    }

}