Java Code Examples for org.quartz.CronTrigger#getCronExpression()
The following examples show how to use
org.quartz.CronTrigger#getCronExpression() .
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: CronTriggerSupport.java From lams with GNU General Public License v2.0 | 6 votes |
public static CompositeData toCompositeData(CronTrigger trigger) { try { return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES, new Object[] { trigger.getCronExpression(), trigger.getTimeZone(), 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 2
Source File: ScheduleJobService.java From springboot-quartz with MIT License | 6 votes |
private void wrapScheduleJob(ScheduleJob scheduleJob,Scheduler scheduler,JobKey jobKey,Trigger trigger){ try { scheduleJob.setJobName(jobKey.getName()); scheduleJob.setJobGroup(jobKey.getGroup()); JobDetail jobDetail = scheduler.getJobDetail(jobKey); ScheduleJob job = (ScheduleJob)jobDetail.getJobDataMap().get("scheduleJob"); scheduleJob.setDesc(job.getDesc()); scheduleJob.setJobId(job.getJobId()); Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey()); scheduleJob.setJobStatus(triggerState.name()); if(trigger instanceof CronTrigger){ CronTrigger cronTrigger = (CronTrigger)trigger; String cronExpression = cronTrigger.getCronExpression(); scheduleJob.setCronExpression(cronExpression); } } catch (SchedulerException e) { e.printStackTrace(); } }
Example 3
Source File: TriggerUtils.java From quartz-glass with Apache License 2.0 | 6 votes |
public static String getPlanification(Trigger trigger) { if (trigger instanceof CronTrigger) { CronTrigger cronTrigger = (CronTrigger) trigger; try { return CronExpressionDescriptor.getDescription(cronTrigger.getCronExpression()) + "<br/>(" + cronTrigger.getCronExpression() + ")"; } catch (ParseException e) { return cronTrigger.getCronExpression(); } } SimpleTrigger simpleTrigger = (SimpleTrigger) trigger; return getPlanification(simpleTrigger.getRepeatCount(), simpleTrigger.getRepeatInterval()); }
Example 4
Source File: SolrTrackerSchedulerTest.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
private void checkCronExpression(String exp) throws SchedulerException { for (JobKey jobKey : this.trackerScheduler.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(SolrTrackerScheduler.SOLR_JOB_GROUP))) { List<? extends Trigger> triggers = this.trackerScheduler.scheduler.getTriggersOfJob(jobKey); CronTrigger t = (CronTrigger) triggers.get(0); String cronExp = t.getCronExpression(); Assert.assertEquals(exp, cronExp); } }
Example 5
Source File: DetectionCronScheduler.java From incubator-pinot with Apache License 2.0 | 5 votes |
private boolean isJobUpdated(DetectionConfigDTO config, JobKey key) throws SchedulerException { List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(key); CronTrigger cronTrigger = (CronTrigger) triggers.get(0); String cronInSchedule = cronTrigger.getCronExpression(); if (!config.getCron().equals(cronInSchedule)) { LOG.info("Cron expression for detection pipeline {} has been changed from {} to {}. " + "Restarting schedule", config.getId(), cronInSchedule, config.getCron()); return true; } return false; }
Example 6
Source File: SubscriptionCronScheduler.java From incubator-pinot with Apache License 2.0 | 5 votes |
private void createOrUpdateAlertJob(Set<JobKey> scheduledJobs, DetectionAlertConfigDTO alertConfig) throws SchedulerException { Long id = alertConfig.getId(); boolean isActive = alertConfig.isActive(); JobKey key = new JobKey(getJobKey(id, TaskConstants.TaskType.DETECTION_ALERT), QUARTZ_SUBSCRIPTION_GROUPER); JobDetail job = JobBuilder.newJob(DetectionAlertJob.class).withIdentity(key).build(); boolean isScheduled = scheduledJobs.contains(key); if (isActive) { if (isScheduled) { String cronInDatabase = alertConfig.getCronExpression(); List<Trigger> triggers = (List<Trigger>) scheduler.getTriggersOfJob(key); CronTrigger cronTrigger = (CronTrigger) triggers.get(0); String cronInSchedule = cronTrigger.getCronExpression(); // cron expression has been updated, restart this job if (!cronInDatabase.equals(cronInSchedule)) { LOG.info( "Cron expression for config {} with jobKey {} has been changed from {} to {}. " + "Restarting schedule", id, key, cronInSchedule, cronInDatabase); stopJob(key); startJob(alertConfig, job); } } else { LOG.info("Found active but not scheduled {}", id); startJob(alertConfig, job); } } else { if (isScheduled) { LOG.info("Found inactive but scheduled {}", id); stopJob(key); } // for all jobs with not isActive, and not isScheduled, no change required } }
Example 7
Source File: QuartzAdapter.java From javamelody with Apache License 2.0 | 4 votes |
String getCronTriggerExpression(CronTrigger trigger) { // getCronExpression gives a PMD false+ return trigger.getCronExpression(); }
Example 8
Source File: Quartz2Adapter.java From javamelody with Apache License 2.0 | 4 votes |
@Override String getCronTriggerExpression(CronTrigger trigger) { // getCronExpression gives a PMD false+ return trigger.getCronExpression(); // NOPMD }