use of org.quartz.JobDetail in project Dempsy by Dempsy.
the class CronOutputSchedule method start.
/* (non-Javadoc)
* @see com.nokia.dempsy.output.OutputExecuter#start()
*/
public void start() {
try {
JobDetail jobDetail = super.getJobDetail();
Trigger trigger = getCronTrigger(cronExpression);
scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(jobDetail, trigger);
scheduler.start();
} catch (SchedulerException se) {
logger.error("Error occurred while starting the cron scheduler : " + se.getMessage(), se);
}
}
use of org.quartz.JobDetail in project Dempsy by Dempsy.
the class RelativeOutputSchedule method start.
/**
* Container will invoke this method.
*/
@Override
public void start() {
try {
JobDetail jobDetail = super.getJobDetail();
Trigger trigger = getSimpleTrigger(timeUnit, (int) interval);
scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(jobDetail, trigger);
scheduler.start();
} catch (SchedulerException se) {
logger.error("Error occurred while starting the relative scheduler : " + se.getMessage(), se);
}
}
use of org.quartz.JobDetail in project series-rest-api by 52North.
the class JobScheduler method scheduleJob.
private void scheduleJob(ScheduledJob taskToSchedule) {
try {
JobDetail details = taskToSchedule.createJobDetails();
Trigger trigger = taskToSchedule.createTrigger(details.getKey());
scheduler.scheduleJob(details, trigger);
if (taskToSchedule.isTriggerAtStartup()) {
LOGGER.debug("Schedule job '{}' to run once at startup.", details.getKey());
Trigger onceAtStartup = TriggerBuilder.newTrigger().withIdentity("onceAtStartup").forJob(details.getKey()).build();
scheduler.scheduleJob(onceAtStartup);
}
} catch (SchedulerException e) {
LOGGER.warn("Could not schdule Job '{}'.", taskToSchedule.getJobName(), e);
}
}
use of org.quartz.JobDetail in project opennms by OpenNMS.
the class ReportScheduler method buildReportSchedule.
private void buildReportSchedule() {
synchronized (m_lock) {
for (Report report : m_configDao.getReports()) {
JobDetail detail = null;
CronTriggerImpl trigger = null;
try {
detail = new JobDetailImpl(report.getReportName(), JOB_GROUP, ReportJob.class, false, false);
detail.getJobDataMap().put(ReportJob.KEY, report);
trigger = new CronTriggerImpl(report.getReportName(), JOB_GROUP, report.getCronSchedule());
trigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
getScheduler().scheduleJob(detail, trigger);
} catch (ParseException e) {
LOG.error("buildReportSchedule: {}", e.getMessage(), e);
} catch (SchedulerException e) {
LOG.error("buildReportSchedule: {}", e.getMessage(), e);
}
}
}
}
use of org.quartz.JobDetail in project karaf by apache.
the class QuartzScheduler method schedule.
/**
* Schedule a job
* @see org.apache.karaf.scheduler.Scheduler#schedule(java.lang.Object, org.apache.karaf.scheduler.ScheduleOptions)
* @throws SchedulerException if the job can't be scheduled
* @throws IllegalArgumentException If the preconditions are not met
*/
public void schedule(final Object job, final ScheduleOptions options) throws IllegalArgumentException, SchedulerException {
this.checkJob(job);
if (!(options instanceof InternalScheduleOptions)) {
throw new IllegalArgumentException("Options has not been created via schedule or is null.");
}
final InternalScheduleOptions opts = (InternalScheduleOptions) options;
if (opts.argumentException != null) {
throw opts.argumentException;
}
// as this method might be called from unbind and during
// unbind a deactivate could happen, we check the scheduler first
final org.quartz.Scheduler s = this.scheduler;
if (s == null) {
throw new IllegalStateException("Scheduler is not available anymore.");
}
final String name;
if (opts.name != null) {
// if there is already a job with the name, remove it first
try {
final JobKey key = JobKey.jobKey(opts.name);
final JobDetail jobdetail = s.getJobDetail(key);
if (jobdetail != null) {
s.deleteJob(key);
this.logger.debug("Unscheduling job with name {}", opts.name);
}
} catch (final SchedulerException ignored) {
// ignore
}
name = opts.name;
} else {
name = job.getClass().getName() + ':' + UUID.randomUUID();
opts.name = name;
}
final Trigger trigger = opts.trigger.withIdentity(name).build();
// create the data map
final JobDataMap jobDataMap = this.initDataMap(name, job, opts);
final JobDetail detail = this.createJobDetail(name, jobDataMap, opts.canRunConcurrently);
this.logger.debug("Scheduling job {} with name {} and trigger {}", job, name, trigger);
s.scheduleJob(detail, trigger);
}
Aggregations