LOGGER.debug("Start execution of job [id={}]", scheduleJobId);
Date now = chronometer.getCurrentMoment();
// Select job by id
ScheduleJob scheduleJob = businessEntityDao.lockById(ScheduleJob.class, scheduleJobId);
if (scheduleJob == null) {
throw new MissingEntityException(ScheduleJob.class, scheduleJobId);
}
// Action
ScheduleAction scheduleAction = scheduleJob.getAction();
scheduleAction.setUsedDate(now);
scheduleAction.incrementUsedCount();
// Create new execution
ScheduleExecution scheduleExecution = new ScheduleExecution();
scheduleExecution.setJob(scheduleJob);
scheduleExecution.setAction(scheduleAction);
scheduleExecution.setCron(scheduleJob.getCron());
scheduleExecution.setName(scheduleJob.getName());
scheduleExecution.setStrategy(scheduleJob.getStrategy());
scheduleExecution.setTimeout(scheduleJob.getTimeout());
scheduleExecution.setAllNodes(scheduleJob.isAllNodes());
scheduleExecution.setAllNodesPool(scheduleJob.getAllNodesPool());
scheduleExecution.setScheduled(parameters.getScheduled());
scheduleExecution.setFired(parameters.getFired());
scheduleExecution.setForced(parameters.isManual());
scheduleExecution.setDescription(parameters.getComment());
scheduleExecution.setStatus(ScheduleExecutionStatus.INPROGRESS);