Search in sources :

Example 1 with ClusterPayload

use of water.zookeeper.nodes.ClusterPayload in project h2o-2 by h2oai.

the class h2odriver method doWait.

public MasterPayload doWait() throws Exception {
    ZooKeeper z = ZooKeeperFactory.makeZk(_zk);
    byte[] payload;
    payload = z.getData(_zkroot, null, null);
    ClusterPayload cp = ClusterPayload.fromPayload(payload, ClusterPayload.class);
    z.close();
    assert (cp.numNodes > 0);
    long startMillis = System.currentTimeMillis();
    while (true) {
        z = ZooKeeperFactory.makeZk(_zk);
        if (z.exists(_zkroot, false) == null) {
            z.close();
            throw new Exception("ZooKeeper node does not exist: " + _zkroot);
        }
        try {
            payload = z.getData(_zkroot + "/master", null, null);
            MasterPayload mp = MasterPayload.fromPayload(payload, MasterPayload.class);
            z.close();
            Thread.sleep(CLOUD_FORMATION_SETTLE_DOWN_SECONDS);
            return mp;
        } catch (KeeperException.NoNodeException e) {
        // This is OK, do nothing
        }
        long now = System.currentTimeMillis();
        if (Math.abs(now - startMillis) > (_cloudFormationTimeoutSeconds * 1000)) {
            z.close();
            throw new TimeoutException("Timed out waiting for cloud to form");
        }
        Thread.sleep(1000);
    }
}
Also used : ClusterPayload(water.zookeeper.nodes.ClusterPayload) MasterPayload(water.zookeeper.nodes.MasterPayload) TimeoutException(java.util.concurrent.TimeoutException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with ClusterPayload

use of water.zookeeper.nodes.ClusterPayload in project h2o-2 by h2oai.

the class h2odriver method doStart.

public void doStart() throws Exception {
    ZooKeeper z = ZooKeeperFactory.makeZk(_zk);
    ClusterPayload cp = new ClusterPayload();
    cp.numNodes = _numNodes;
    byte[] payload = cp.toPayload();
    z.create(_zkroot, payload, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    z.create(_zkroot + "/nodes", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    z.close();
}
Also used : ClusterPayload(water.zookeeper.nodes.ClusterPayload)

Aggregations

ClusterPayload (water.zookeeper.nodes.ClusterPayload)2 TimeoutException (java.util.concurrent.TimeoutException)1 MasterPayload (water.zookeeper.nodes.MasterPayload)1