@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_DELETE: return this; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } }
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_DELETE: return this; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } }
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_EXPIRE: return this; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_EXPIRE: return this; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SUBMIT: return this; case ON_SCHEDULE: return SchedulerJobState.SCHEDULED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SUSPEND: return this; case ON_RESUME: return SchedulerJobState.SCHEDULED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SCHEDULE: return this; case ON_SUSPEND: return SchedulerJobState.SUSPENDED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SCHEDULE: return this; case ON_SUSPEND: return SchedulerJobState.SUSPENDED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SUSPEND: return this; case ON_RESUME: return SchedulerJobState.SCHEDULED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
@Override public SchedulerJobState nextTransition(SchedulerJobEvent event) throws InvalidStateTransitionException { switch (event) { case ON_SUBMIT: return this; case ON_SCHEDULE: return SchedulerJobState.SCHEDULED; case ON_EXPIRE: return SchedulerJobState.EXPIRED; case ON_DELETE: return SchedulerJobState.DELETED; default: throw new InvalidStateTransitionException( "SchedulerJobEvent: " + event.name() + " is not a valid event for state: " + this.name()); } } },
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()); } }