Constants.VM_POWER_ON_WAITING_SEC, clusterEntityMgr);
VcHost host = null;
if (node.getHostName() != null) {
host = VcResourceUtils.findHost(node.getHostName());
}
StartVmSP startSp = new StartVmSP(vcVm, prePowerOn, query, host);
storeProcedures.add(startSp);
nodesStatus.put(node.getVmName(),
new NodeOperationStatus(node.getVmName()));
}
try {
if (storeProcedures.isEmpty()) {
logger.info("no VM is available. Return directly.");
return true;
}
Callable<Void>[] storeProceduresArray =
storeProcedures.toArray(new Callable[0]);
// execute store procedures to start VMs
logger.info("ClusteringService, start to start vms.");
BaseProgressCallback callback = new BaseProgressCallback(statusUpdator);
ExecutionResult[] result =
Scheduler
.executeStoredProcedures(
com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
storeProceduresArray, callback);
if (result == null) {
for (NodeOperationStatus status : nodesStatus.values()) {
status.setSucceed(false);
}
logger.error("No VM is started.");
failedNodes.addAll(nodesStatus.values());
return false;
}
boolean success = true;
int total = 0;
for (int i = 0; i < storeProceduresArray.length; i++) {
StartVmSP sp = (StartVmSP) storeProceduresArray[i];
NodeOperationStatus status = nodesStatus.get(sp.getVmName());
VcVirtualMachine vm = sp.getVcVm();
if (result[i].finished && result[i].throwable == null) {
++total;
nodesStatus.remove(status.getNodeName()); // do not return success node
} else if (result[i].throwable != null) {
status.setSucceed(false);