private void notifyRerun(SchedulerJobInstanceInfo instanceInfo) throws LensException { getEventService().notifyEvent( new SchedulerAlarmEvent(instanceInfo.getJobId(), new DateTime(instanceInfo.getScheduleTime()), SchedulerAlarmEvent.EventType.SCHEDULE, instanceInfo.getId())); }
/** * Inserts the job instance info object into job instance table * * @param instanceInfo * @return number of rows inserted. * @throws SQLException */ public int insertIntoJobInstanceTable(SchedulerJobInstanceInfo instanceInfo) throws SQLException { String insertSQL = "INSERT INTO " + JOB_INSTANCE_TABLE + " VALUES(?,?,?)"; return runner .update(insertSQL, instanceInfo.getId().getHandleIdString(), instanceInfo.getJobId().getHandleIdString(), instanceInfo.getScheduleTime()); }
@Override public void run() { while (!Thread.currentThread().isInterrupted()) { // Get all the instance runs which are waiting. List<SchedulerJobInstanceRun> instanceRuns = schedulerDAO.getInstanceRuns(SchedulerJobInstanceState.WAITING); for (SchedulerJobInstanceRun run : instanceRuns) { SchedulerJobInstanceInfo instanceInfo = schedulerDAO.getSchedulerJobInstanceInfo(run.getHandle()); try { run.setInstanceState(run.getInstanceState().nextTransition(ON_PREPARE)); run.setEndTime(System.currentTimeMillis()); schedulerDAO.updateJobInstanceRun(run); eventService.notifyEvent( new SchedulerAlarmEvent(instanceInfo.getJobId(), new DateTime(instanceInfo.getScheduleTime()), SchedulerAlarmEvent.EventType.SCHEDULE, instanceInfo.getId())); } catch (LensException e) { log.error("Not able to notify schedule event for job {} and instanceId {}", instanceInfo.getJobId(), instanceInfo.getId()); } catch (InvalidStateTransitionException e) { log.error("Wrong state transition", e); } } } try { Thread.sleep(delay); } catch (InterruptedException e) { log.warn("Thread WaitingInstanceHandler was inerrupted", e); } } }