Java Code Examples for org.quartz.Trigger#getNextFireTime()
The following examples show how to use
org.quartz.Trigger#getNextFireTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchJobOperatorImpl.java From griffin with Apache License 2.0 | 6 votes |
private void setTriggerTime(AbstractJob job, JobState jobState) throws SchedulerException { List<? extends Trigger> triggers = jobService .getTriggers(job.getName(), job.getGroup()); // If triggers are empty, in Griffin it means job is completed whose // trigger state is NONE or not scheduled. if (CollectionUtils.isEmpty(triggers)) { return; } Trigger trigger = triggers.get(0); Date nextFireTime = trigger.getNextFireTime(); Date previousFireTime = trigger.getPreviousFireTime(); jobState.setNextFireTime(nextFireTime != null ? nextFireTime.getTime() : -1); jobState.setPreviousFireTime(previousFireTime != null ? previousFireTime.getTime() : -1); }
Example 2
Source File: LoggingJobHistoryPlugin.java From AsuraFramework with Apache License 2.0 | 6 votes |
/** * @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext) */ public void jobExecutionVetoed(JobExecutionContext context) { if (!getLog().isInfoEnabled()) { return; } Trigger trigger = context.getTrigger(); Object[] args = { context.getJobDetail().getName(), context.getJobDetail().getGroup(), new java.util.Date(), trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new Integer(context.getRefireCount()) }; getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args)); }
Example 3
Source File: TriggerSupport.java From AsuraFramework with Apache License 2.0 | 6 votes |
public static CompositeData toCompositeData(Trigger trigger) { try { return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { trigger.getName(), trigger.getGroup(), trigger.getJobName(), trigger.getJobGroup(), trigger.getDescription(), JobDataMapSupport.toTabularData(trigger .getJobDataMap()), trigger.isVolatile(), trigger.getCalendarName(), trigger.getFireInstanceId(), trigger.getMisfireInstruction(), trigger.getPriority(), trigger.getStartTime(), trigger.getEndTime(), trigger.getNextFireTime(), trigger.getPreviousFireTime(), trigger.getFinalFireTime() }); } catch (OpenDataException e) { throw new RuntimeException(e); } }
Example 4
Source File: JobStoreSupport.java From AsuraFramework with Apache License 2.0 | 6 votes |
private void doUpdateOfMisfiredTrigger(Connection conn, SchedulingContext ctxt, Trigger trig, boolean forceState, String newStateIfNotComplete, boolean recovering) throws JobPersistenceException { Calendar cal = null; if (trig.getCalendarName() != null) { cal = retrieveCalendar(conn, ctxt, trig.getCalendarName()); } schedSignaler.notifyTriggerListenersMisfired(trig); trig.updateAfterMisfire(cal); if (trig.getNextFireTime() == null) { storeTrigger(conn, ctxt, trig, null, true, STATE_COMPLETE, forceState, recovering); } else { storeTrigger(conn, ctxt, trig, null, true, newStateIfNotComplete, forceState, false); } }
Example 5
Source File: TriggerSupport.java From lams with GNU General Public License v2.0 | 6 votes |
public static CompositeData toCompositeData(Trigger trigger) { try { return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { trigger.getKey().getName(), trigger.getKey().getGroup(), trigger.getJobKey().getName(), trigger.getJobKey().getGroup(), trigger.getDescription(), JobDataMapSupport.toTabularData(trigger .getJobDataMap()), trigger.getCalendarName(), ((OperableTrigger)trigger).getFireInstanceId(), trigger.getMisfireInstruction(), trigger.getPriority(), trigger.getStartTime(), trigger.getEndTime(), trigger.getNextFireTime(), trigger.getPreviousFireTime(), trigger.getFinalFireTime() }); } catch (OpenDataException e) { throw new RuntimeException(e); } }
Example 6
Source File: SchedulerServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
@Override public Date getNextStartTime(BatchJobStatus job) { try { Trigger[] triggers = scheduler.getTriggersOfJob(job.getName(), job.getGroup()); Date nextDate = new Date(Long.MAX_VALUE); for (Trigger trigger : triggers) { if (trigger.getNextFireTime() != null){ if (trigger.getNextFireTime().getTime() < nextDate.getTime()) { nextDate = trigger.getNextFireTime(); } } } if (nextDate.getTime() == Long.MAX_VALUE) { nextDate = null; } return nextDate; } catch (SchedulerException ex) { } return null; }
Example 7
Source File: AbstractQuartzTaskManager.java From micro-integrator with Apache License 2.0 | 6 votes |
@Override public void triggerComplete(Trigger trigger, JobExecutionContext jobExecutionContext, Trigger.CompletedExecutionInstruction completedExecutionInstruction) { if (trigger.getNextFireTime() == null) { try { String taskName = trigger.getJobKey().getName(); TaskUtils.setTaskFinished(getTaskRepository(), taskName, true); if (getAllCoordinatedTasksDeployed().contains(taskName)) { removeTaskFromLocallyRunningTaskList(taskName); taskStore.updateTaskState(Collections.singletonList(taskName), CoordinatedTask.States.COMPLETED); } } catch (TaskException | TaskCoordinationException e) { log.error("Error in Finishing Task [" + trigger.getJobKey().getName() + "]: " + e.getMessage(), e); } } }
Example 8
Source File: LoggingTriggerHistoryPlugin.java From AsuraFramework with Apache License 2.0 | 5 votes |
public void triggerMisfired(Trigger trigger) { if (!getLog().isInfoEnabled()) { return; } Object[] args = { trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new java.util.Date(), trigger.getJobName(), trigger.getJobGroup() }; getLog().info(MessageFormat.format(getTriggerMisfiredMessage(), args)); }
Example 9
Source File: LoggingTriggerHistoryPlugin.java From lams with GNU General Public License v2.0 | 5 votes |
public void triggerMisfired(Trigger trigger) { if (!getLog().isInfoEnabled()) { return; } Object[] args = { trigger.getKey().getName(), trigger.getKey().getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new java.util.Date(), trigger.getJobKey().getName(), trigger.getJobKey().getGroup() }; getLog().info(MessageFormat.format(getTriggerMisfiredMessage(), args)); }
Example 10
Source File: LoggingTriggerHistoryPlugin.java From lams with GNU General Public License v2.0 | 5 votes |
public void triggerComplete(Trigger trigger, JobExecutionContext context, CompletedExecutionInstruction triggerInstructionCode) { if (!getLog().isInfoEnabled()) { return; } String instrCode = "UNKNOWN"; if (triggerInstructionCode == CompletedExecutionInstruction.DELETE_TRIGGER) { instrCode = "DELETE TRIGGER"; } else if (triggerInstructionCode == CompletedExecutionInstruction.NOOP) { instrCode = "DO NOTHING"; } else if (triggerInstructionCode == CompletedExecutionInstruction.RE_EXECUTE_JOB) { instrCode = "RE-EXECUTE JOB"; } else if (triggerInstructionCode == CompletedExecutionInstruction.SET_ALL_JOB_TRIGGERS_COMPLETE) { instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE"; } else if (triggerInstructionCode == CompletedExecutionInstruction.SET_TRIGGER_COMPLETE) { instrCode = "SET THIS TRIGGER COMPLETE"; } Object[] args = { trigger.getKey().getName(), trigger.getKey().getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new java.util.Date(), context.getJobDetail().getKey().getName(), context.getJobDetail().getKey().getGroup(), Integer.valueOf(context.getRefireCount()), triggerInstructionCode.toString(), instrCode }; getLog().info(MessageFormat.format(getTriggerCompleteMessage(), args)); }
Example 11
Source File: LoggingTriggerHistoryPlugin.java From AsuraFramework with Apache License 2.0 | 5 votes |
public void triggerComplete(Trigger trigger, JobExecutionContext context, int triggerInstructionCode) { if (!getLog().isInfoEnabled()) { return; } String instrCode = "UNKNOWN"; if (triggerInstructionCode == Trigger.INSTRUCTION_DELETE_TRIGGER) { instrCode = "DELETE TRIGGER"; } else if (triggerInstructionCode == Trigger.INSTRUCTION_NOOP) { instrCode = "DO NOTHING"; } else if (triggerInstructionCode == Trigger.INSTRUCTION_RE_EXECUTE_JOB) { instrCode = "RE-EXECUTE JOB"; } else if (triggerInstructionCode == Trigger.INSTRUCTION_SET_ALL_JOB_TRIGGERS_COMPLETE) { instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE"; } else if (triggerInstructionCode == Trigger.INSTRUCTION_SET_TRIGGER_COMPLETE) { instrCode = "SET THIS TRIGGER COMPLETE"; } Object[] args = { trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new java.util.Date(), context.getJobDetail().getName(), context.getJobDetail().getGroup(), new Integer(context.getRefireCount()), new Integer(triggerInstructionCode), instrCode }; getLog().info(MessageFormat.format(getTriggerCompleteMessage(), args)); }
Example 12
Source File: LoggingTriggerHistoryPlugin.java From AsuraFramework with Apache License 2.0 | 5 votes |
public void triggerFired(Trigger trigger, JobExecutionContext context) { if (!getLog().isInfoEnabled()) { return; } Object[] args = { trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new java.util.Date(), context.getJobDetail().getName(), context.getJobDetail().getGroup(), new Integer(context.getRefireCount()) }; getLog().info(MessageFormat.format(getTriggerFiredMessage(), args)); }
Example 13
Source File: QuartzAdapter.java From javamelody with Apache License 2.0 | 4 votes |
Date getTriggerNextFireTime(Trigger trigger) { return trigger.getNextFireTime(); }
Example 14
Source File: LoggingJobHistoryPlugin.java From lams with GNU General Public License v2.0 | 4 votes |
/** * @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException) */ public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { Trigger trigger = context.getTrigger(); Object[] args = null; if (jobException != null) { if (!getLog().isWarnEnabled()) { return; } String errMsg = jobException.getMessage(); args = new Object[] { context.getJobDetail().getKey().getName(), context.getJobDetail().getKey().getGroup(), new java.util.Date(), trigger.getKey().getName(), trigger.getKey().getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), Integer.valueOf(context.getRefireCount()), errMsg }; getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException); } else { if (!getLog().isInfoEnabled()) { return; } String result = String.valueOf(context.getResult()); args = new Object[] { context.getJobDetail().getKey().getName(), context.getJobDetail().getKey().getGroup(), new java.util.Date(), trigger.getKey().getName(), trigger.getKey().getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), Integer.valueOf(context.getRefireCount()), result }; getLog().info(MessageFormat.format(getJobSuccessMessage(), args)); } }
Example 15
Source File: QuartzSchedulerSPI.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private static long getNextFireMillis(final Trigger trigger) { Date nextFireTime = trigger.getNextFireTime(); return nextFireTime != null ? nextFireTime.getTime() : 0L; }
Example 16
Source File: Quartz2Adapter.java From javamelody with Apache License 2.0 | 4 votes |
@Override Date getTriggerNextFireTime(Trigger trigger) { return trigger.getNextFireTime(); }
Example 17
Source File: EmailNotificationsController.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Renders a page listing all scheduled emails. */ @RequestMapping("/showScheduledEmails") public String showScheduledEmails(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, SchedulerException { TreeSet<EmailScheduleMessageJobDTO> scheduleList = new TreeSet<>(); Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true); boolean isLessonNotifications = (lessonId != null); Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); if (isLessonNotifications) { if (!securityService.isLessonMonitor(lessonId, getCurrentUser().getUserID(), "show scheduled lesson email notifications", false)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the lesson"); return null; } } else { if (!securityService.isGroupMonitor(organisationId, getCurrentUser().getUserID(), "show scheduled course email notifications", false)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the organisation"); return null; } } Set<TriggerKey> triggerKeys = scheduler .getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP)); for (TriggerKey triggerKey : triggerKeys) { String triggerName = triggerKey.getName(); if (triggerName.startsWith(EmailNotificationsController.TRIGGER_PREFIX_NAME)) { Trigger trigger = scheduler.getTrigger(triggerKey); JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey()); JobDataMap jobDataMap = jobDetail.getJobDataMap(); // filter triggers if (isLessonNotifications) { Object jobLessonId = jobDataMap.get(AttributeNames.PARAM_LESSON_ID); if ((jobLessonId == null) || (!lessonId.equals(jobLessonId))) { continue; } } else { Object jobOrganisationId = jobDataMap.get(AttributeNames.PARAM_ORGANISATION_ID); if ((jobOrganisationId == null) || (!organisationId.equals(jobOrganisationId))) { continue; } } Date triggerDate = trigger.getNextFireTime(); String emailBody = WebUtil.convertNewlines((String) jobDataMap.get("emailBody")); int searchType = (Integer) jobDataMap.get("searchType"); EmailScheduleMessageJobDTO emailScheduleJobDTO = new EmailScheduleMessageJobDTO(); emailScheduleJobDTO.setTriggerName(triggerName); emailScheduleJobDTO.setTriggerDate(triggerDate); emailScheduleJobDTO.setEmailBody(emailBody); emailScheduleJobDTO.setSearchType(searchType); scheduleList.add(emailScheduleJobDTO); } } request.setAttribute("scheduleList", scheduleList); request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId); request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId); return "emailnotifications/scheduledEmailList"; }
Example 18
Source File: PointbaseDelegate.java From AsuraFramework with Apache License 2.0 | 4 votes |
public int updateTrigger(Connection conn, Trigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException { ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap()); int len = baos.toByteArray().length; ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); PreparedStatement ps = null; int insertResult = 0; try { ps = conn.prepareStatement(rtp(UPDATE_TRIGGER)); ps.setString(1, trigger.getJobName()); ps.setString(2, trigger.getJobGroup()); setBoolean(ps, 3, trigger.isVolatile()); ps.setString(4, trigger.getDescription()); long nextFireTime = -1; if (trigger.getNextFireTime() != null) { nextFireTime = trigger.getNextFireTime().getTime(); } ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime))); long prevFireTime = -1; if (trigger.getPreviousFireTime() != null) { prevFireTime = trigger.getPreviousFireTime().getTime(); } ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime))); ps.setString(7, state); if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) { // updateSimpleTrigger(conn, (SimpleTrigger)trigger); ps.setString(8, TTYPE_SIMPLE); } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) { // updateCronTrigger(conn, (CronTrigger)trigger); ps.setString(8, TTYPE_CRON); } else { // updateBlobTrigger(conn, trigger); ps.setString(8, TTYPE_BLOB); } ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger .getStartTime().getTime()))); long endTime = 0; if (trigger.getEndTime() != null) { endTime = trigger.getEndTime().getTime(); } ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime))); ps.setString(11, trigger.getCalendarName()); ps.setInt(12, trigger.getMisfireInstruction()); ps.setInt(13, trigger.getPriority()); ps.setBinaryStream(14, bais, len); ps.setString(15, trigger.getName()); ps.setString(16, trigger.getGroup()); insertResult = ps.executeUpdate(); } finally { closeStatement(ps); } if (insertResult > 0) { deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup()); String[] trigListeners = trigger.getTriggerListenerNames(); for (int i = 0; trigListeners != null && i < trigListeners.length; i++) { insertTriggerListener(conn, trigger, trigListeners[i]); } } return insertResult; }
Example 19
Source File: StdJDBCDelegate.java From AsuraFramework with Apache License 2.0 | 4 votes |
/** * <p> * Update the base trigger data. * </p> * * @param conn * the DB Connection * @param trigger * the trigger to insert * @param state * the state that the trigger should be stored in * @return the number of rows updated */ public int updateTrigger(Connection conn, Trigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException { // save some clock cycles by unnecessarily writing job data blob ... boolean updateJobData = trigger.getJobDataMap().isDirty(); ByteArrayOutputStream baos = null; if(updateJobData && trigger.getJobDataMap().size() > 0) { baos = serializeJobData(trigger.getJobDataMap()); } PreparedStatement ps = null; int insertResult = 0; try { if(updateJobData) { ps = conn.prepareStatement(rtp(UPDATE_TRIGGER)); } else { ps = conn.prepareStatement(rtp(UPDATE_TRIGGER_SKIP_DATA)); } ps.setString(1, trigger.getJobName()); ps.setString(2, trigger.getJobGroup()); setBoolean(ps, 3, trigger.isVolatile()); ps.setString(4, trigger.getDescription()); long nextFireTime = -1; if (trigger.getNextFireTime() != null) { nextFireTime = trigger.getNextFireTime().getTime(); } ps.setBigDecimal(5, new BigDecimal(String.valueOf(nextFireTime))); long prevFireTime = -1; if (trigger.getPreviousFireTime() != null) { prevFireTime = trigger.getPreviousFireTime().getTime(); } ps.setBigDecimal(6, new BigDecimal(String.valueOf(prevFireTime))); ps.setString(7, state); if (trigger instanceof SimpleTrigger && ((SimpleTrigger)trigger).hasAdditionalProperties() == false ) { // updateSimpleTrigger(conn, (SimpleTrigger)trigger); ps.setString(8, TTYPE_SIMPLE); } else if (trigger instanceof CronTrigger && ((CronTrigger)trigger).hasAdditionalProperties() == false ) { // updateCronTrigger(conn, (CronTrigger)trigger); ps.setString(8, TTYPE_CRON); } else { // updateBlobTrigger(conn, trigger); ps.setString(8, TTYPE_BLOB); } ps.setBigDecimal(9, new BigDecimal(String.valueOf(trigger .getStartTime().getTime()))); long endTime = 0; if (trigger.getEndTime() != null) { endTime = trigger.getEndTime().getTime(); } ps.setBigDecimal(10, new BigDecimal(String.valueOf(endTime))); ps.setString(11, trigger.getCalendarName()); ps.setInt(12, trigger.getMisfireInstruction()); ps.setInt(13, trigger.getPriority()); if(updateJobData) { setBytes(ps, 14, baos); ps.setString(15, trigger.getName()); ps.setString(16, trigger.getGroup()); } else { ps.setString(14, trigger.getName()); ps.setString(15, trigger.getGroup()); } insertResult = ps.executeUpdate(); } finally { closeStatement(ps); } if (insertResult > 0) { deleteTriggerListeners(conn, trigger.getName(), trigger.getGroup()); String[] trigListeners = trigger.getTriggerListenerNames(); for (int i = 0; trigListeners != null && i < trigListeners.length; i++) { insertTriggerListener(conn, trigger, trigListeners[i]); } } return insertResult; }
Example 20
Source File: LoggingJobHistoryPlugin.java From AsuraFramework with Apache License 2.0 | 4 votes |
/** * @see org.quartz.JobListener#jobWasExecuted(JobExecutionContext, JobExecutionException) */ public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { Trigger trigger = context.getTrigger(); Object[] args = null; if (jobException != null) { if (!getLog().isWarnEnabled()) { return; } String errMsg = jobException.getMessage(); args = new Object[] { context.getJobDetail().getName(), context.getJobDetail().getGroup(), new java.util.Date(), trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new Integer(context.getRefireCount()), errMsg }; getLog().warn(MessageFormat.format(getJobFailedMessage(), args), jobException); } else { if (!getLog().isInfoEnabled()) { return; } String result = String.valueOf(context.getResult()); args = new Object[] { context.getJobDetail().getName(), context.getJobDetail().getGroup(), new java.util.Date(), trigger.getName(), trigger.getGroup(), trigger.getPreviousFireTime(), trigger.getNextFireTime(), new Integer(context.getRefireCount()), result }; getLog().info(MessageFormat.format(getJobSuccessMessage(), args)); } }