public XJob getXJob(String name, String query, String db, String startTime, String endTime, XFrequencyEnum frequency) throws ParseException, DatatypeConfigurationException { XJob job = new XJob(); job.setName(name); job.setStartTime(Util.getGregorianCalendar(startTime)); job.setEndTime(Util.getGregorianCalendar(endTime)); job.setTrigger(getXTrigger(frequency)); job.setExecution(getXExecution(query, db)); return job; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName); theExecution = this.getExecution(); strategy.appendField(locator, this, "execution", buffer, theExecution); theTrigger = this.getTrigger(); strategy.appendField(locator, this, "trigger", buffer, theTrigger); theJobConf = (((this.jobConf!= null)&&(!this.jobConf.isEmpty()))?this.getJobConf():null); strategy.appendField(locator, this, "jobConf", buffer, theJobConf); theStartTime = this.getStartTime(); strategy.appendField(locator, this, "startTime", buffer, theStartTime); theEndTime = this.getEndTime(); strategy.appendField(locator, this, "endTime", buffer, theEndTime);
@Test public void testUpdateJob() throws Exception { String endDate = Util.modifyDate(currentDate, format, Calendar.DATE, 4); XJob job = scheduleHelper.getXJob("job-update", QueryInventory.QUERY, null, currentDate, endDate, XFrequencyEnum.WEEKLY); String jobHandle = scheduleHelper.submitJob(job, sessionHandleString); XJob tmp = scheduleHelper.getJobDefinition(jobHandle, sessionHandleString).getData(); tmp.setName("modified-name"); endDate = Util.modifyDate(currentDate, format, Calendar.DATE, 6); tmp.setEndTime(Util.getGregorianCalendar(endDate)); scheduleHelper.updateJob(tmp, jobHandle, sessionHandleString); XJob modifiedJob = scheduleHelper.getJobDefinition(jobHandle, sessionHandleString).getData(); Assert.assertEquals(modifiedJob.getName(), "modified-name"); String modifiedEndTime = Util.getDateStringFromGregorainCalender(modifiedJob.getEndTime(), format); Assert.assertEquals(modifiedEndTime, endDate); }
/** * {@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); }
@Test public void submitNScheduleQueryCronExp() throws Exception { String endDate = Util.modifyDate(currentDate, format, Calendar.DATE, 1); XJob xJob = scheduleHelper.getXJob("job-submit-schedule-cronExp", QueryInventory.QUERY, null, currentDate, endDate, "0/30 * * * * ?"); String jobHandle = scheduleHelper.submitNScheduleJob(xJob, sessionHandleString); Assert.assertNotNull(jobHandle); XJob job = scheduleHelper.getJobDefinition(jobHandle, sessionHandleString, MediaType.APPLICATION_XML_TYPE, MediaType.APPLICATION_XML).getData(); Assert.assertNotNull(job); Assert.assertEquals(job.getName(), "job-submit-schedule-cronExp"); }
public XJob withName(String value) { setName(value); return this; }
public XJob withEndTime(XMLGregorianCalendar value) { setEndTime(value); return this; }
String query = job.getExecution().getQuery().getQuery(); String queryName = job.getName(); queryName += "-" + scheduledTimeMillis;
/** * Create an instance of {@link XJob } * */ public XJob createXJob() { return new XJob(); }
public XJob withTrigger(XTrigger value) { setTrigger(value); return this; }
public XJob withExecution(XExecution value) { setExecution(value); return this; }
public XJob withStartTime(XMLGregorianCalendar value) { setStartTime(value); return this; }
private LensConf getLensConf(XJob job, SchedulerJobInstanceHandle instanceHandle, DateTime scheduledTime) { List<MapType> jobConf = job.getExecution().getQuery().getConf(); LensConf queryConf = new LensConf(); for (MapType element : jobConf) { queryConf.addProperty(element.getKey(), element.getValue()); } queryConf.addProperty(JOB_INSTANCE_ID_KEY, instanceHandle.getHandleId()); // Current time is used for resolving date. queryConf.addProperty(LensConfConstants.QUERY_CURRENT_TIME_IN_MILLIS, scheduledTime.getMillis()); return queryConf; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName); theExecution = this.getExecution(); strategy.appendField(locator, this, "execution", buffer, theExecution); theTrigger = this.getTrigger(); strategy.appendField(locator, this, "trigger", buffer, theTrigger); theJobConf = (((this.jobConf!= null)&&(!this.jobConf.isEmpty()))?this.getJobConf():null); strategy.appendField(locator, this, "jobConf", buffer, theJobConf); theStartTime = this.getStartTime(); strategy.appendField(locator, this, "startTime", buffer, theStartTime); theEndTime = this.getEndTime(); strategy.appendField(locator, this, "endTime", buffer, theEndTime);
/** * {@inheritDoc} */ @Override public SchedulerJobHandle submitJob(LensSessionHandle sessionHandle, XJob job) throws LensException { LensSessionImpl session = getSession(sessionHandle); // Validate XJob validateJob(session, job); SchedulerJobHandle handle = UtilityMethods.generateSchedulerJobHandle(); long createdOn = System.currentTimeMillis(); SchedulerJobInfo info = new SchedulerJobInfo(handle, job, session.getLoggedInUser(), SchedulerJobState.NEW, createdOn, createdOn); if (schedulerDAO.storeJob(info) == 1) { log.info("Successfully submitted job with handle {}", handle); return handle; } else { throw new LensException(LensSchedulerErrorCode.CANT_SUBMIT_JOB.getLensErrorInfo(), null, job.getName()); } }
public XJob withName(String value) { setName(value); return this; }
public XJob withEndTime(XMLGregorianCalendar value) { setEndTime(value); return this; }
/** * Create an instance of {@link XJob } * */ public XJob createXJob() { return new XJob(); }
public XJob withTrigger(XTrigger value) { setTrigger(value); return this; }
public XJob withExecution(XExecution value) { setExecution(value); return this; }