List<Callable<Void>> storeNodeProcedures = new ArrayList<Callable<Void>>();
try {
for (NodeEntity node : nodes) {
if (node.needUpgrade(serverVersion)) {
NodeUpgradeSP nodeUpgradeSP = new NodeUpgradeSP(node, serverVersion);
storeNodeProcedures.add(nodeUpgradeSP);
}
}
if (storeNodeProcedures.isEmpty()) {
logger.info("no VM is available. Return directly.");
return true;
}
Callable<Void>[] storeNodeProceduresArray = storeNodeProcedures.toArray(new Callable[0]);
NoProgressUpdateCallback callback = new NoProgressUpdateCallback();
ExecutionResult[] result =
Scheduler
.executeStoredProcedures(
com.vmware.aurora.composition.concurrent.Priority.BACKGROUND,
storeNodeProceduresArray, callback);
if (result == null || result.length == 0) {
logger.error("No node is upgraded.");
return false;
}
boolean success = true;
int total = 0;
for (int i = 0; i < storeNodeProceduresArray.length; i++) {
Throwable nodeUpgradeSPException = result[i].throwable;
NodeUpgradeSP sp = (NodeUpgradeSP) storeNodeProceduresArray[i];
NodeEntity node = sp.getNode();
if (result[i].finished && nodeUpgradeSPException == null) {
updateNodeData(node);
++total;
} else if (nodeUpgradeSPException != null) {
updateNodeData(node, false, nodeUpgradeSPException.getMessage(), CommonUtil.getCurrentTimestamp());