use of org.quartz.TriggerKey in project kylo by Teradata.
the class QuartzScheduler method scheduleWithFixedDelay.
public void scheduleWithFixedDelay(JobIdentifier jobIdentifier, Object task, String runMethod, Date startTime, long startDelay) throws JobSchedulerException {
try {
JobDetail jobDetail = getJobDetail(jobIdentifier, task, runMethod);
Date triggerStartTime = startTime;
if (startDelay > 0L || startTime == null) {
triggerStartTime = new Date(System.currentTimeMillis() + startDelay);
}
Trigger trigger = newTrigger().withIdentity(new TriggerKey(jobIdentifier.getName(), jobIdentifier.getGroup())).forJob(jobDetail).startAt(triggerStartTime).build();
getScheduler().scheduleJob(jobDetail, trigger);
triggerListeners(JobSchedulerEvent.scheduledJobEvent(jobIdentifier));
} catch (Exception e) {
throw new JobSchedulerException();
}
}
use of org.quartz.TriggerKey in project kylo by Teradata.
the class QuartzScheduler method scheduleAtFixedRateWithDelay.
public void scheduleAtFixedRateWithDelay(JobIdentifier jobIdentifier, Object task, String runMethod, Date startTime, long period, long startDelay) throws JobSchedulerException {
JobDetail jobDetail = null;
try {
jobDetail = getJobDetail(jobIdentifier, task, runMethod);
Date triggerStartTime = startTime;
if (startDelay > 0L || startTime == null) {
triggerStartTime = new Date(System.currentTimeMillis() + startDelay);
}
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(new TriggerKey(jobIdentifier.getName(), jobIdentifier.getGroup())).forJob(jobDetail).startAt(triggerStartTime).withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(period).repeatForever()).build();
getScheduler().scheduleJob(jobDetail, trigger);
triggerListeners(JobSchedulerEvent.scheduledJobEvent(jobIdentifier));
} catch (NoSuchMethodException | ClassNotFoundException | SchedulerException e) {
throw new JobSchedulerException("Error calling scheduleAtFixedRateWithDelay", e);
}
}
use of org.quartz.TriggerKey in project kylo by Teradata.
the class QuartzSchedulerTest method staticHelperTest.
@Test
public void staticHelperTest() throws Exception {
JobIdentifier identifier = QuartzScheduler.jobIdentifierForJobKey(new JobKey("job-name", "group"));
JobKey jobKey = QuartzScheduler.jobKeyForJobIdentifier(identifier);
assertEquals(jobKey.getName(), identifier.getName());
TriggerKey triggerKey = new TriggerKey("trigger-key-name", "trigger-key-name");
TriggerIdentifier triggerIdentifier = QuartzScheduler.triggerIdentifierForTriggerKey(triggerKey);
triggerKey = QuartzScheduler.triggerKeyForTriggerIdentifier(triggerIdentifier);
assertEquals(triggerKey.getName(), triggerIdentifier.getName());
}
use of org.quartz.TriggerKey in project BRFS by zhangnianli.
the class QuartzBaseSchedulers method pauseTask.
@Override
public boolean pauseTask(T task) throws Exception {
TriggerKey triggerKey = TriggerKey.triggerKey(task.getTaskName(), task.getTaskGroupName());
JobKey jobKey = new JobKey(task.getTaskName(), task.getTaskGroupName());
Scheduler scheduler = this.ssf.getScheduler(this.instanceName);
if (!scheduler.isShutdown()) {
// 1.停止触发器
scheduler.pauseTrigger(triggerKey);
// 2.停止任务
scheduler.pauseJob(jobKey);
}
return true;
}
use of org.quartz.TriggerKey in project BRFS by zhangnianli.
the class QuartzBaseSchedulers method resumeTask.
@Override
public boolean resumeTask(T task) throws Exception {
TriggerKey triggerKey = TriggerKey.triggerKey(task.getTaskName(), task.getTaskGroupName());
JobKey jobKey = new JobKey(task.getTaskName(), task.getTaskGroupName());
Scheduler scheduler = this.ssf.getScheduler(this.instanceName);
if (!scheduler.isShutdown()) {
Set<String> pauseGroup = scheduler.getPausedTriggerGroups();
if (pauseGroup == null || (pauseGroup != null && !pauseGroup.contains(task.getTaskGroupName()))) {
return false;
}
scheduler.resumeTrigger(triggerKey);
scheduler.resumeJob(jobKey);
}
return true;
}
Aggregations