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);
}
}
Aggregations