} else if (this.quorumPeer != null && !this.quorumPeer.isAlive()) {
this.quorumPeer.start();
return;
}
try {
final QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
quorumPeerConfig.parse(conf.getConfFile());
QuorumPeer.Factory qpFactory = new QuorumPeer.Factory() {
public QuorumPeer create(NIOServerCnxn.Factory cnxnFactory) throws IOException {
ServerConfig serverConfig = new ServerConfig();
serverConfig.readFrom(quorumPeerConfig);
QuorumPeer peer = new QuorumPeer(quorumPeerConfig.getServers(), new File(serverConfig.getDataDir()), new File(
serverConfig.getDataLogDir()), quorumPeerConfig.getElectionAlg(), quorumPeerConfig.getServerId(),
quorumPeerConfig.getTickTime(), quorumPeerConfig.getInitLimit(), quorumPeerConfig.getSyncLimit(), cnxnFactory,
quorumPeerConfig.getQuorumVerifier());
ZooDiscoveryContainer.this.quorumPeer = peer;
return peer;
}
public NIOServerCnxn.Factory createConnectionFactory() throws IOException {
return new NIOServerCnxn.Factory(quorumPeerConfig.getClientPortAddress());
}
};
quorumPeer = qpFactory.create(qpFactory.createConnectionFactory());
quorumPeer.start();
quorumPeer.setDaemon(true);