protected ScheduleExecution executeJob(long scheduleJobId, StartExecutionParameters parameters) {
BeanValidationUtils.checkValidity(parameters, beanValidator);
// Compose execution descriptor
ScheduleExecution scheduleExecution = executionManagementService.startExecution(scheduleJobId, parameters);
// The only reason the status is not assigned is that exception occurs in executeJobNodes*() call
ScheduleExecutionStatus status = ScheduleExecutionStatus.EXCEPTION;
// Try to execute action on a node from the cluster
try {
try {
if (scheduleExecution.isAllNodes() && (scheduleExecution.getAllNodesPool() > 0)) {
status = executeJobNodesParallel(scheduleExecution);
} else {
status = executeJobNodesSequentially(scheduleExecution);
}
} catch (Exception e) {
LOGGER.error("Internal error while executing the job : " + scheduleExecution.getJob().getId(), e);
} finally {
scheduleExecution = executionManagementService.finishExecution(scheduleExecution.getId(), status);
}
} catch (AbstractServiceException e) {
throw new SystemIntegrityException("Fail to finish execution", e);
}