use of org.apache.zookeeper.server.NIOServerCnxn.Factory in project ecf by eclipse.
the class ZooDiscoveryContainer method startStandAlone.
/**
* Start a ZooKeeer server locally to write nodes to. Implied by
* {@link IDiscoveryConfig#ZOODISCOVERY_FLAVOR_STANDALONE} configuration.
*
* @param conf
*/
void startStandAlone(final Configuration conf) {
if (ZooDiscoveryContainer.zooKeeperServer != null && ZooDiscoveryContainer.zooKeeperServer.isRunning())
return;
else if (ZooDiscoveryContainer.zooKeeperServer != null && !ZooDiscoveryContainer.zooKeeperServer.isRunning())
try {
ZooDiscoveryContainer.zooKeeperServer.startup();
return;
} catch (Exception e) {
// $NON-NLS-1$
Logger.log(LogService.LOG_DEBUG, "Zookeeper server cannot be started! ", e);
}
try {
ZooDiscoveryContainer.zooKeeperServer = new ZooKeeperServer();
FileTxnSnapLog fileTxnSnapLog = new FileTxnSnapLog(conf.getZookeeperDataFile(), conf.getZookeeperDataFile());
ZooDiscoveryContainer.zooKeeperServer.setTxnLogFactory(fileTxnSnapLog);
ZooDiscoveryContainer.zooKeeperServer.setTickTime(conf.getTickTime());
Factory cnxnFactory = new NIOServerCnxn.Factory(new InetSocketAddress(conf.getClientPort()));
cnxnFactory.startup(ZooDiscoveryContainer.zooKeeperServer);
} catch (Exception e) {
Logger.log(LogService.LOG_ERROR, "Zookeeper server cannot be started! Possibly another instance is already running on the same port. ", e);
}
}
Aggregations