use of org.quartz.SimpleTrigger in project searchcode-server by boyter.
the class JobService method startDeleteJob.
/**
* Starts a background job which deletes repositories from the database, index and checked out disk
*/
private void startDeleteJob() {
try {
Scheduler scheduler = Singleton.getScheduler();
// Setup the indexer which runs forever adding documents to be indexed
JobDetail job = newJob(DeleteRepositoryJob.class).withIdentity("deletejob").build();
SimpleTrigger trigger = newTrigger().withIdentity("deletejob").withSchedule(simpleSchedule().withIntervalInSeconds(1).repeatForever()).build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException ex) {
Singleton.getLogger().severe(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
}
}
use of org.quartz.SimpleTrigger in project searchcode-server by boyter.
the class JobService method startIndexFileRepoJobs.
/**
* Creates a file repo indexer job which will pull from the file queue and index
*/
public void startIndexFileRepoJobs(String uniquename) {
try {
Scheduler scheduler = Singleton.getScheduler();
JobDetail job = newJob(IndexFileRepoJob.class).withIdentity("updateindex-file-" + uniquename).build();
SimpleTrigger trigger = newTrigger().withIdentity("updateindex-file-" + uniquename).withSchedule(simpleSchedule().withIntervalInSeconds(this.INDEXTIME).repeatForever()).build();
job.getJobDataMap().put("REPOLOCATIONS", this.REPOLOCATION);
job.getJobDataMap().put("LOWMEMORY", this.LOWMEMORY);
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException ex) {
Singleton.getLogger().severe(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
}
}
use of org.quartz.SimpleTrigger in project iaf by ibissource.
the class SchedulerAdapter method triggerToXmlBuilder.
public XmlBuilder triggerToXmlBuilder(Scheduler theScheduler, String triggerName, String groupName) {
XmlBuilder xbRoot = new XmlBuilder("triggerDetail");
try {
Trigger trigger = theScheduler.getTrigger(triggerName, groupName);
xbRoot.addAttribute("fullName", trigger.getFullName());
xbRoot.addAttribute("triggerName", trigger.getName());
xbRoot.addAttribute("triggerGroup", trigger.getGroup());
String cn = trigger.getCalendarName();
xbRoot.addAttribute("calendarName", (cn == null ? "none" : cn));
Date date;
try {
date = trigger.getEndTime();
xbRoot.addAttribute("endTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getFinalFireTime();
xbRoot.addAttribute("finalFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getPreviousFireTime();
xbRoot.addAttribute("previousFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getNextFireTime();
xbRoot.addAttribute("nextFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getStartTime();
xbRoot.addAttribute("startTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
xbRoot.addAttribute("misfireInstruction", Integer.toString(trigger.getMisfireInstruction()));
if (trigger instanceof CronTrigger) {
xbRoot.addAttribute("triggerType", "cron");
xbRoot.addAttribute("cronExpression", ((CronTrigger) trigger).getCronExpression());
} else if (trigger instanceof SimpleTrigger) {
xbRoot.addAttribute("triggerType", "simple");
xbRoot.addAttribute("repeatInterval", ((SimpleTrigger) trigger).getRepeatInterval());
} else {
xbRoot.addAttribute("triggerType", "unknown");
}
xbRoot.addAttribute("jobGroup", trigger.getJobGroup());
xbRoot.addAttribute("jobName", trigger.getJobName());
xbRoot.addAttribute("isVolatile", (trigger.isVolatile() ? "True" : "False"));
} catch (SchedulerException se) {
log.error(se);
}
return xbRoot;
}
use of org.quartz.SimpleTrigger in project motech by motech.
the class CronJobSimpleExpressionBuilderTest method shouldScheduleJobEverySevenDays.
@Test
public void shouldScheduleJobEverySevenDays() {
SimpleTrigger trigger = newTrigger().withIdentity(triggerKey("triggerName", "groupName")).startNow().withSchedule(simpleSchedule().withIntervalInHours(7 * 24).repeatForever()).build();
LocalDate today = DateUtil.today();
Date yesterday = today.plusDays(-1).toDate();
Date firstFireTime = trigger.getFireTimeAfter(yesterday);
Date secondFireTime = trigger.getFireTimeAfter(firstFireTime);
Date thirdFireTime = trigger.getFireTimeAfter(secondFireTime);
assertEquals(Duration.standardDays(7).getMillis(), secondFireTime.getTime() - firstFireTime.getTime());
assertEquals(Duration.standardDays(7).getMillis(), thirdFireTime.getTime() - secondFireTime.getTime());
}
use of org.quartz.SimpleTrigger in project motech by motech.
the class SchedulableJobBuilder method buildRepeatingSchedulableJob.
private static SchedulableJob buildRepeatingSchedulableJob(Trigger trigger, JobDataMap dataMap) {
RepeatingSchedulableJob job = new RepeatingSchedulableJob();
long interval;
if (trigger instanceof CalendarIntervalTrigger) {
CalendarIntervalTrigger calendarTrigger = (CalendarIntervalTrigger) trigger;
interval = calendarTrigger.getRepeatInterval();
} else {
SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
job.setRepeatCount(simpleTrigger.getRepeatCount());
interval = simpleTrigger.getRepeatInterval() / SECOND;
}
job.setEndDate(getEndDate(trigger));
job.setRepeatIntervalInSeconds((int) interval);
job.setIgnorePastFiresAtStart(dataMap.getBoolean(IGNORE_PAST_FIRES_AT_START));
job.setUseOriginalFireTimeAfterMisfire(dataMap.getBoolean(USE_ORIGINAL_FIRE_TIME_AFTER_MISFIRE));
return job;
}
Aggregations