/** * String representation of the SchedulerJobHandle. * * @return string representation of the handleId */ @Override public String toString() { return getHandleIdString(); }
/** * String representation of the SchedulerJobHandle. * * @return string representation of the handleId */ @Override public String toString() { return getHandleIdString(); }
@Override public String getEventId() { return jobHandle.getHandleIdString(); }
@Override public String getEventId() { return jobHandle.getHandleIdString(); }
/** * Gets the job definition from the store * * @param id : Job handle id. * @return XJob definition */ public XJob getJob(SchedulerJobHandle id) { try { return store.getJob(id.getHandleIdString()); } catch (SQLException e) { log.error("Error while getting the job for {}", id.getHandleIdString(), e); return null; } }
/** * Gets the Job status * * @param id : Job handle id. * @return SchedulerJobStatus of the job. */ public SchedulerJobState getJobState(SchedulerJobHandle id) { try { return store.getJobState(id.getHandleIdString()); } catch (SQLException e) { log.error("Error while getting the job status for {}", id.getHandleIdString(), e); return null; } }
/** * Get the user of the job who submitted the job. * * @param id * @return */ public String getUser(SchedulerJobHandle id) { try { return store.getUser(id.getHandleIdString()); } catch (SQLException e) { log.error("Error while getting the user for the job with handle {}", id.getHandleIdString(), e); return null; } }
/** * Fetches the SchedulerJobInfo object corresponding to handle id. * * @param id: Job handle id. * @return SchedulerJobInfo */ public SchedulerJobInfo getSchedulerJobInfo(SchedulerJobHandle id) { try { return store.getSchedulerJobInfo(id.getHandleIdString()); } catch (SQLException e) { log.error("Error while getting the job detail for {}", id.getHandleIdString(), e); return null; } }
/** * Gets all the instance handle id for a job. * * @param id: Job handle id. * @return List of instance handles. */ public List<SchedulerJobInstanceInfo> getJobInstances(SchedulerJobHandle id) { // TODO: Add number of results to be fetched try { return store.getAllJobInstances(id.getHandleIdString()); } catch (SQLException e) { log.error("Error while getting instances of a job with id {}", id.getHandleIdString(), e); return new ArrayList<>(); } }
public boolean checkExists(SchedulerJobHandle handle) throws LensException { try { return scheduler.checkExists(JobKey.jobKey(handle.getHandleIdString(), LENS_JOBS)); } catch (SchedulerException e) { log.error("Failed to check the job with jobHandle: {}", handle); return false; } }
public void resumeJob(SchedulerJobHandle jobHandle) throws LensException { try { scheduler.resumeJob(JobKey.jobKey(jobHandle.getHandleIdString(), LENS_JOBS)); } catch (SchedulerException e) { log.error("Failed to resume alarm triggers for job with jobHandle: {}", jobHandle); throw new LensException(LensSchedulerErrorCode.FAILED_ALARM_SERVICE_OPERATION.getLensErrorInfo(), e, "resume", jobHandle.getHandleIdString()); } }
public boolean unSchedule(SchedulerJobHandle jobHandle) throws LensException { // stop sending notifications for this job handle try { return scheduler.deleteJob(JobKey.jobKey(jobHandle.getHandleIdString(), LENS_JOBS)); } catch (SchedulerException e) { log.error("Failed to remove alarm triggers for job with jobHandle: {}", jobHandle); throw new LensException(LensSchedulerErrorCode.FAILED_ALARM_SERVICE_OPERATION.getLensErrorInfo(), e, "unschedule", jobHandle.getHandleIdString()); } }
public void pauseJob(SchedulerJobHandle jobHandle) throws LensException { try { scheduler.pauseJob(JobKey.jobKey(jobHandle.getHandleIdString(), LENS_JOBS)); } catch (SchedulerException e) { log.error("Failed to pause alarm triggers for job with jobHandle: {}", jobHandle); throw new LensException(LensSchedulerErrorCode.FAILED_ALARM_SERVICE_OPERATION.getLensErrorInfo(), e, "pause", jobHandle.getHandleIdString()); } }
/** * Saves the SchedulerJobInfo object into the store. * * @param jobInfo object * @return the number of records stored */ public int storeJob(SchedulerJobInfo jobInfo) { try { return store.insertIntoJobTable(jobInfo); } catch (SQLException e) { log.error("Error while storing the jobInfo for {}", jobInfo.getId().getHandleIdString(), e); return 0; } }
public String submitJob(String action, XJob job, String session) throws JAXBException, IOException, ParseException, DatatypeConfigurationException { Response response = submitJobReturnResponse(action, job, session); AssertUtil.assertSucceededResponse(response); LensAPIResult<SchedulerJobHandle> handle = response.readEntity( new GenericType<LensAPIResult<SchedulerJobHandle>>(){}); return handle.getData().getHandleIdString(); }
/** * Updates the job definition from the new SchedulerJobInfo * * @param info: Updated info object. * @return number of rows updated. */ public int updateJob(SchedulerJobInfo info) { try { return store.updateJob(info.getId().getHandleIdString(), info.getJob(), info.getModifiedOn()); } catch (SQLException e) { log.error("Error while updating job for {}", info.getId().getHandleIdString(), e); return 0; } }
/** * Updates the job status form the new SchedulerJobInfo * * @param info: Updated info objects * @return number of rows updated. */ public int updateJobStatus(SchedulerJobInfo info) { try { return store.updateJobStatus(info.getId().getHandleIdString(), info.getJobState().name(), info.getModifiedOn()); } catch (SQLException e) { log.error("Error while updating job status for {}", info.getId().getHandleIdString(), e); return 0; } }
/** * {@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); }
/** * 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()); }
private SchedulerJobInfo checkAndGetSchedulerJobInfo(SchedulerJobHandle jobHandle) throws LensException { SchedulerJobInfo jobInfo = schedulerDAO.getSchedulerJobInfo(jobHandle); if (jobInfo == null) { throw new LensException( new LensErrorInfo(LensCommonErrorCode.RESOURCE_NOT_FOUND.getValue(), 0, "Job handle not found"), null, "job", jobHandle.getHandleIdString()); } return jobInfo; }