Search in sources :

Example 1 with DaemonStateZK

use of com.ms.silverking.cloud.dht.meta.DaemonStateZK in project SilverKing by Morgan-Stanley.

the class SKAdmin method waitUntilRunning.

// /////////////////////////////////////////
public Pair<Set<IPAndPort>, Boolean> waitUntilRunning(Set<IPAndPort> activeNodes, int timeoutSeconds) {
    DaemonStateZK daemonStateZK;
    Map<IPAndPort, DaemonState> daemonState;
    daemonStateZK = new DaemonStateZK(dhtMC);
    daemonState = daemonStateZK.waitForQuorumState(activeNodes, DaemonState.RUNNING, timeoutSeconds, true);
    Log.warningf("daemonState: %s", daemonState);
    if (daemonState.isEmpty()) {
        return new Pair<>(ImmutableSet.of(), true);
    } else {
        HashSet<IPAndPort> failedDaemons;
        boolean running;
        running = true;
        failedDaemons = new HashSet<>();
        for (IPAndPort activeNode : activeNodes) {
            DaemonState ds;
            ds = daemonState.get(activeNode);
            System.out.printf("Node: %s\tstate: %s\n", activeNode, ds);
            if (ds == null) {
                failedDaemons.add(activeNode);
                running = false;
            } else {
                if (ds != DaemonState.RUNNING) {
                    running = false;
                }
            }
        }
        return new Pair<>(failedDaemons, running);
    }
}
Also used : DaemonStateZK(com.ms.silverking.cloud.dht.meta.DaemonStateZK) IPAndPort(com.ms.silverking.net.IPAndPort) DaemonState(com.ms.silverking.cloud.dht.daemon.DaemonState) Pair(com.ms.silverking.collection.Pair)

Aggregations

DaemonState (com.ms.silverking.cloud.dht.daemon.DaemonState)1 DaemonStateZK (com.ms.silverking.cloud.dht.meta.DaemonStateZK)1 Pair (com.ms.silverking.collection.Pair)1 IPAndPort (com.ms.silverking.net.IPAndPort)1