Search in sources :

Example 1 with TimeoutException

use of org.jboss.netty.handler.timeout.TimeoutException in project graphdb by neo4j-attic.

the class LocalhostZooKeeperCluster method await.

private void await(ZooKeeper[] keepers, long timeout, TimeUnit unit) {
    timeout = System.currentTimeMillis() + unit.toMillis(timeout);
    do {
        ClusterManager cm = null;
        try {
            cm = new ClusterManager(getConnectionString());
            cm.waitForSyncConnected();
            break;
        } catch (Exception e) {
            e.printStackTrace();
        // ok retry
        } finally {
            if (cm != null) {
                try {
                    cm.shutdown();
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
        }
        if (System.currentTimeMillis() > timeout) {
            throw new TimeoutException("waiting for ZooKeeper cluster to start");
        }
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            Thread.interrupted();
        }
    } while (true);
}
Also used : ClusterManager(org.neo4j.kernel.ha.zookeeper.ClusterManager) IOException(java.io.IOException) TimeoutException(org.jboss.netty.handler.timeout.TimeoutException) MalformedObjectNameException(javax.management.MalformedObjectNameException) TimeoutException(org.jboss.netty.handler.timeout.TimeoutException)

Aggregations

IOException (java.io.IOException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 TimeoutException (org.jboss.netty.handler.timeout.TimeoutException)1 ClusterManager (org.neo4j.kernel.ha.zookeeper.ClusterManager)1