public void start() throws Exception {
Preconditions.checkState(this.tmpDir.get() != null, "Not Initialized.");
val s = new ZooKeeperServer(this.tmpDir.get(), this.tmpDir.get(), ZooKeeperServer.DEFAULT_TICK_TIME);
if (!this.server.compareAndSet(null, s)) {
s.shutdown();
throw new IllegalStateException("Already started.");
}
this.serverFactory.set(NettyServerCnxnFactory.createFactory());
val address = LOOPBACK_ADDRESS + ":" + this.zkPort;
log.info("Starting Zookeeper server at " + address + " ...");
this.serverFactory.get().configure(new InetSocketAddress(LOOPBACK_ADDRESS, this.zkPort), 1000, secureZK);
this.serverFactory.get().startup(s);
if (!waitForServerUp(this.zkPort, this.secureZK, this.trustStore, this.keyStore, this.keyStorePassword, this.keyStorePassword)) {
throw new IllegalStateException("ZooKeeper server failed to start");
}
}