/** * {@inheritDoc} */ @Override public void deleteJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo info = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, info.getUserName()); if (alarmService.checkExists(jobHandle)) { alarmService.unSchedule(jobHandle); log.info("Successfully unscheduled the job with handle {} ", jobHandle); } setStateOfJob(info, SchedulerJobEvent.ON_DELETE); }
/** * {@inheritDoc} */ @Override public void expireJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo info = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, info.getUserName()); if (alarmService.checkExists(jobHandle)) { alarmService.unSchedule(jobHandle); log.info("Successfully unscheduled the job with handle {} in AlarmService ", jobHandle); } setStateOfJob(info, SchedulerJobEvent.ON_EXPIRE); }
/** * {@inheritDoc} */ @Override public void resumeJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo info = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, info.getUserName()); alarmService.resumeJob(jobHandle); setStateOfJob(info, SchedulerJobEvent.ON_RESUME); }
/** * {@inheritDoc} */ @Override public void scheduleJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo jobInfo = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, jobInfo.getUserName()); XJob job = jobInfo.getJob(); DateTime start = new DateTime(job.getStartTime().toGregorianCalendar().getTime()); DateTime end = new DateTime(job.getEndTime().toGregorianCalendar().getTime()); XFrequency frequency = job.getTrigger().getFrequency(); // check query checkQuery(sessionHandle, job); alarmService.schedule(start, end, frequency, jobHandle.getHandleIdString()); log.info("Successfully scheduled job with handle {} in AlarmService", jobHandle); setStateOfJob(jobInfo, SchedulerJobEvent.ON_SCHEDULE); }
/** * {@inheritDoc} */ @Override public void suspendJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo info = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, info.getUserName()); alarmService.pauseJob(jobHandle); setStateOfJob(info, SchedulerJobEvent.ON_SUSPEND); }
/** * {@inheritDoc} */ @Override public void updateJob(LensSessionHandle sessionHandle, SchedulerJobHandle jobHandle, XJob newJobDefinition) throws LensException { SchedulerJobInfo jobInfo = checkAndGetSchedulerJobInfo(jobHandle); doesSessionBelongToUser(sessionHandle, jobInfo.getUserName()); // This will allow only the job definition and configuration change. jobInfo.setJob(newJobDefinition); jobInfo.setModifiedOn(System.currentTimeMillis()); int updated = schedulerDAO.updateJob(jobInfo); if (updated > 0) { return; } throw new LensException(LensSchedulerErrorCode.CANT_UPDATE_RESOURCE_WITH_HANDLE.getLensErrorInfo(), null, "job", jobHandle.getHandleIdString()); }
/** * Inserts the Job info object into job table * * @param jobInfo * @return number of rows inserted. * @throws SQLException */ public int insertIntoJobTable(SchedulerJobInfo jobInfo) throws SQLException { String insertSQL = "INSERT INTO " + JOB_TABLE + " VALUES(?,?,?,?,?,?,?)"; JAXBElement<XJob> xmlJob = jobFactory.createJob(jobInfo.getJob()); return runner.update(insertSQL, jobInfo.getId().toString(), ToXMLString.toString(xmlJob), jobInfo.getUserName(), jobInfo.getJobState().name(), jobInfo.getCreatedOn(), jobInfo.getModifiedOn(), jobInfo.getJob().getName()); }