private void setStateOfJob(SchedulerJobInfo info, SchedulerJobEvent event) throws LensException {
SchedulerJobState currentState = info.getJobState();
try {
SchedulerJobState nextState = currentState.nextTransition(event);
info.setJobState(nextState);
info.setModifiedOn(System.currentTimeMillis());
int ret = schedulerDAO.updateJobStatus(info);
if (ret == 1) {
log.info("Successfully changed the status of job with handle {} from {} to {}", info.getId(), currentState,
nextState);
} else {
throw new LensException(LensSchedulerErrorCode.CANT_UPDATE_RESOURCE_WITH_HANDLE.getLensErrorInfo(), null, "job",
info.getId().getHandleIdString());
}
} catch (InvalidStateTransitionException e) {
throw new LensException(LensSchedulerErrorCode.INVALID_EVENT_FOR_JOB.getLensErrorInfo(), e, event.name(),
currentState.name(), info.getId().getHandleIdString());
}
}