if (CollectionUtils.isEmpty(scheduleExecution.getNodes())) {
return ScheduleExecutionStatus.EMPTYNODES;
}
// Remember when the process started
ChronometerTimer timer = new ChronometerTimer(chronometer);
// Succeed nodes counter
int succeedNodes = 0;
// All nodes iterator
Iterator<ScheduleExecutionNode> nodeIterator = scheduleExecution.getNodes().iterator();
// Start loop throught all execution nodes
while (nodeIterator.hasNext()) {
// Get fresh copy of execution and check the cancellation flag
ScheduleExecution scheduleExecutionReloaded =
executionManagementService.findExecution(scheduleExecution.getId());
if (scheduleExecutionReloaded.isCancelled()) {
LOGGER.debug("Execution [{}] is cancelled", scheduleExecution.getId());
return ScheduleExecutionStatus.CANCELED;
}
// Current node
ScheduleExecutionNode currentNode = nodeIterator.next();
// Execution action on node
ScheduleExecutionResult scheduleExecutionResult = executeJobNode(scheduleExecution, currentNode);
// If last action succeedes break the node loop
if (scheduleExecutionResult.isSucceed()) {
LOGGER.debug("Success execution [{}] on node [{}]",
scheduleExecution.getId(), currentNode.getAddress());
succeedNodes++;
if (!scheduleExecution.isAllNodes()) {
return ScheduleExecutionStatus.SUCCEED;
}
} else {
LOGGER.debug("Failed execution [{}] on node [{}]",
scheduleExecution.getId(), currentNode.getAddress());
}
// Are there any other pending nodes?
if (nodeIterator.hasNext()) {
// Check timeout
if ((scheduleExecution.getTimeout() > 0) && (timer.elapsed() > scheduleExecution.getTimeout())) {
LOGGER.debug("Execution [{}] is timed out", scheduleExecution.getId());
return ScheduleExecutionStatus.TIMEOUT;
}
} else {
if (scheduleExecution.isAllNodes() && (succeedNodes == scheduleExecution.getNodes().size())) {