List of usage examples for org.apache.zookeeper.server ZooKeeperServer isRunning
public boolean isRunning()
From source file:blazingcache.TestingZookeeperServerEmbedded.java
License:Apache License
public void start() throws Exception { mainsingle = new ZooKeeperServerMain(); thread = new Thread("zkservermainrunner") { @Override//from w w w. j ava2s . c om public void run() { try { ServerConfig cc = new ServerConfig(); cc.readFrom(config); mainsingle.runFromConfig(cc); System.out.println("ZK server died"); } catch (Throwable t) { t.printStackTrace(); } } }; thread.start(); this.cnxnFactory = getServerConnectionFactory(); if (cnxnFactory != null) { final ZooKeeperServer zkServer = getZooKeeperServer(cnxnFactory); if (zkServer != null) { synchronized (zkServer) { if (!zkServer.isRunning()) { zkServer.wait(); } } } } }
From source file:org.apache.airavata.common.utils.AiravataZKUtils.java
License:Apache License
public static void runZKFromConfig(ServerConfig config, ServerCnxnFactory cnxnFactory) throws IOException { AiravataZKUtils.logger.info("Starting Zookeeper server..."); FileTxnSnapLog txnLog = null;/* w w w . j a v a 2s. co m*/ try { // Note that this thread isn't going to be doing anything else, // so rather than spawning another thread, we will just call // run() in this thread. // create a file logger url from the command line args ZooKeeperServer zkServer = new ZooKeeperServer(); txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File(config.getDataDir())); zkServer.setTxnLogFactory(txnLog); zkServer.setTickTime(config.getTickTime()); zkServer.setMinSessionTimeout(config.getMinSessionTimeout()); zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout()); cnxnFactory = ServerCnxnFactory.createFactory(); cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns()); cnxnFactory.startup(zkServer); cnxnFactory.join(); if (zkServer.isRunning()) { zkServer.shutdown(); } } catch (InterruptedException e) { // warn, but generally this is ok AiravataZKUtils.logger.warn("Server interrupted", e); System.exit(1); } finally { if (txnLog != null) { txnLog.close(); } } }
From source file:org.apache.curator.test.TestingZooKeeperMain.java
License:Apache License
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @Override// www . jav a 2s . c o m public void blockUntilStarted() throws Exception { latch.await(); ServerCnxnFactory cnxnFactory = getServerConnectionFactory(); if (cnxnFactory != null) { final ZooKeeperServer zkServer = getZooKeeperServer(cnxnFactory); if (zkServer != null) { synchronized (zkServer) { if (!zkServer.isRunning()) { zkServer.wait(); } } } } Thread.sleep(1000); Exception exception = startingException.get(); if (exception != null) { throw exception; } }