use of org.quartz.Scheduler 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.Scheduler 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.Scheduler in project engine by craftercms.
the class SiteContextFactory method scheduleJobs.
protected Scheduler scheduleJobs(SiteContext siteContext) {
String siteName = siteContext.getSiteName();
try {
List<JobContext> allJobContexts = new ArrayList<>();
for (ScriptJobResolver jobResolver : jobResolvers) {
List<JobContext> jobContexts = jobResolver.resolveJobs(siteContext);
if (CollectionUtils.isNotEmpty(jobContexts)) {
allJobContexts.addAll(jobContexts);
}
}
if (CollectionUtils.isNotEmpty(allJobContexts)) {
Scheduler scheduler = SchedulingUtils.createScheduler(siteName + "_scheduler");
logger.info("--------------------------------------------------");
logger.info("<Scheduling job scripts for site: " + siteName + ">");
logger.info("--------------------------------------------------");
for (JobContext jobContext : allJobContexts) {
scheduler.scheduleJob(jobContext.getDetail(), jobContext.getTrigger());
logger.info("Scheduled job: " + jobContext + " for site '" + siteName + "'");
}
scheduler.start();
logger.info("--------------------------------------------------");
logger.info("</Scheduling job scripts for site: " + siteName + ">");
logger.info("--------------------------------------------------");
return scheduler;
}
} catch (Exception e) {
logger.error("Unable to schedule jobs for site '" + siteName + "'", e);
}
return null;
}
Aggregations