use of org.quartz.JobDetail in project opennms by OpenNMS.
the class ReportJobFactory method newJob.
/** {@inheritDoc} */
@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = bundle.getJobDetail();
Class<ReportJob> jobClass = getJobClass(jobDetail);
ReportJob job = null;
try {
job = jobClass.newInstance();
job.setReportd(getReportd());
return job;
} catch (Throwable e) {
SchedulerException se = new SchedulerException("failed to create job class: " + jobDetail.getJobClass().getName() + "; " + e.getLocalizedMessage(), e);
throw se;
}
}
use of org.quartz.JobDetail in project opennms by OpenNMS.
the class ImportJobFactory method newJob.
/** {@inheritDoc} */
@Override
public Job newJob(final TriggerFiredBundle bundle, final Scheduler scheduler) throws SchedulerException {
JobDetail jobDetail = bundle.getJobDetail();
Class<ImportJob> jobClass = getJobClass(jobDetail);
ImportJob job = null;
try {
job = jobClass.newInstance();
job.setProvisioner(getProvisioner());
return job;
} catch (Throwable e) {
SchedulerException se = new SchedulerException("failed to create job class: " + jobDetail.getJobClass().getName() + "; " + e.getLocalizedMessage(), e);
throw se;
}
}
use of org.quartz.JobDetail in project opennms by OpenNMS.
the class ImportScheduler method buildImportSchedule.
/**
* <p>buildImportSchedule</p>
*/
protected void buildImportSchedule() {
synchronized (m_lock) {
Iterator<RequisitionDef> it = m_configDao.getDefs().iterator();
while (it.hasNext()) {
RequisitionDef def = it.next();
JobDetail detail = null;
CronTriggerImpl trigger = null;
try {
detail = new JobDetailImpl(def.getImportName().orElse(null), JOB_GROUP, ImportJob.class, false, false);
detail.getJobDataMap().put(ImportJob.URL, def.getImportUrlResource());
detail.getJobDataMap().put(ImportJob.RESCAN_EXISTING, def.getRescanExisting());
trigger = new CronTriggerImpl(def.getImportName().orElse(null), JOB_GROUP, def.getCronSchedule().orElse(null));
trigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
getScheduler().scheduleJob(detail, trigger);
} catch (ParseException e) {
LOG.error("buildImportSchedule: {}", e.getLocalizedMessage(), e);
} catch (SchedulerException e) {
LOG.error("buildImportSchedule: {}", e.getLocalizedMessage(), e);
}
}
}
printCurrentSchedule();
}
use of org.quartz.JobDetail in project series-rest-api by 52North.
the class PreRenderingJob method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
if (interrupted) {
return;
}
LOGGER.info("Start prerendering task");
final Stopwatch stopwatch = Stopwatch.startStopwatch();
final JobDetail details = context.getJobDetail();
JobDataMap jobDataMap = details.getJobDataMap();
taskConfigPrerendering = readJobConfig(jobDataMap.getString(JOB_DATA_CONFIG_FILE));
webappFolder = jobDataMap.getString(JOB_DATA_WEBAPP_FOLDER);
List<RenderingConfig> phenomenonStyles = taskConfigPrerendering.getPhenomenonStyles();
List<RenderingConfig> styles = taskConfigPrerendering.getSeriesStyles();
for (RenderingConfig config : phenomenonStyles) {
Map<String, String> parameters = new HashMap<>();
parameters.put("phenomenon", config.getId());
IoParameters query = QueryParameters.createFromQuery(parameters);
for (DatasetOutput<?, ?> metadata : datasetService.getCondensedParameters(query)) {
String timeseriesId = metadata.getId();
renderConfiguredIntervals(timeseriesId, config);
if (interrupted) {
return;
}
}
}
for (RenderingConfig config : styles) {
renderConfiguredIntervals(config.getId(), config);
if (interrupted) {
return;
}
}
LOGGER.debug("prerendering took '{}'", stopwatch.stopInSeconds());
}
use of org.quartz.JobDetail in project oxCore by GluuFederation.
the class QuartzSchedulerManager method schedule.
public void schedule(@Observes TimerEvent timerEvent) {
checkInitialized();
JobDataMap dataMap = new JobDataMap();
dataMap.put(TimerJob.KEY_TIMER_EVENT, timerEvent);
String uuid = UUID.randomUUID().toString();
JobDetail timerJob = JobBuilder.newJob(TimerJob.class).withIdentity(TimerJob.class.getSimpleName() + "_" + uuid, TimerJob.TIMER_JOB_GROUP).usingJobData(dataMap).build();
TimerSchedule timerSchedule = timerEvent.getSchedule();
Date triggerStartTime = new Date(System.currentTimeMillis() + timerSchedule.getDelay() * 1000L);
Trigger timerTrigger = TriggerBuilder.newTrigger().withIdentity(uuid, TimerJob.TIMER_JOB_GROUP).startAt(triggerStartTime).withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(timerSchedule.getInterval())).build();
try {
scheduler.scheduleJob(timerJob, timerTrigger);
} catch (SchedulerException ex) {
throw new IllegalStateException("Failed to schedule Timer Event", ex);
}
}
Aggregations