use of org.quartz.JobDetail in project engine by craftercms.
the class SchedulingUtils method createScriptJob.
public static JobDetail createScriptJob(SiteContext siteContext, String jobName, String scriptUrl, ServletContext servletContext) {
JobDataMap dataMap = new JobDataMap();
dataMap.put(SITE_CONTEXT_DATA_KEY, siteContext);
dataMap.put(SCRIPT_URL_DATA_KEY, scriptUrl);
dataMap.put(SERVLET_CONTEXT_DATA_KEY, servletContext);
JobDetail job = newJob(ScriptJob.class).withIdentity(jobName).setJobData(dataMap).build();
return job;
}
use of org.quartz.JobDetail in project ddf by codice.
the class ScheduledCommandTask method newTask.
@Override
public void newTask() {
LOGGER.trace("Creating new Task.");
long identifier = System.currentTimeMillis();
this.jobKey = new JobKey("job" + identifier, jobClass.getSimpleName());
this.triggerKey = new TriggerKey("trigger" + identifier, jobClass.getSimpleName());
JobDetail jobDetail = createJob();
Trigger trigger = createTrigger();
if (trigger == null) {
return;
}
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
LOGGER.info("Error with scheduling of task.", e);
}
}
use of org.quartz.JobDetail in project cdap by caskdata.
the class TimeScheduler method schedule.
public synchronized void schedule(ProgramId program, SchedulableProgramType programType, Iterable<Schedule> schedules, Map<String, String> properties) throws SchedulerException {
checkInitialized();
try {
validateSchedules(program, programType, schedules);
} catch (org.quartz.SchedulerException e) {
throw new SchedulerException(e);
}
JobDetail job = addJob(program, programType);
for (Schedule schedule : schedules) {
TimeSchedule timeSchedule = (TimeSchedule) schedule;
String scheduleName = timeSchedule.getName();
String cronEntry = timeSchedule.getCronEntry();
scheduleJob(program, programType, scheduleName, cronEntry, job, properties);
}
}
use of org.quartz.JobDetail in project cdap by caskdata.
the class DatasetBasedTimeScheduleStore method readJob.
private JobDetail readJob(Table table, JobKey key) {
byte[][] col = new byte[1][];
col[0] = Bytes.toBytes(key.toString());
Row row = table.get(JOB_KEY, col);
byte[] bytes = null;
if (!row.isEmpty()) {
bytes = row.get(col[0]);
}
if (bytes != null) {
return (JobDetail) SerializationUtils.deserialize(bytes);
} else {
return null;
}
}
use of org.quartz.JobDetail in project cdap by caskdata.
the class DatasetBasedTimeScheduleStore method readSchedulesFromPersistentStore.
// Get schedule information from persistent store
private void readSchedulesFromPersistentStore() throws Exception {
final List<JobDetail> jobs = Lists.newArrayList();
final List<TriggerStatusV2> triggers = Lists.newArrayList();
factory.createExecutor(ImmutableList.of((TransactionAware) table)).execute(new TransactionExecutor.Subroutine() {
@Override
public void apply() throws Exception {
Row result = table.get(JOB_KEY);
if (!result.isEmpty()) {
for (byte[] bytes : result.getColumns().values()) {
JobDetail jobDetail = (JobDetail) SerializationUtils.deserialize(bytes);
// If the job detail doesn't contain version id, add one.
jobDetail = addDefaultAppVersionIfNeeded(jobDetail);
LOG.debug("Schedule: Job with key {} found", jobDetail.getKey());
jobs.add(jobDetail);
}
} else {
LOG.debug("Schedule: No Jobs found in Job store");
}
result = table.get(TRIGGER_KEY);
if (!result.isEmpty()) {
for (byte[] bytes : result.getColumns().values()) {
TriggerStatusV2 trigger = (TriggerStatusV2) SerializationUtils.deserialize(bytes);
addDefaultAppVersionIfNeeded(trigger);
if (trigger.state.equals(Trigger.TriggerState.NORMAL) || trigger.state.equals(Trigger.TriggerState.PAUSED)) {
triggers.add(trigger);
LOG.debug("Schedule: trigger with key {} added", trigger.trigger.getKey());
} else {
LOG.debug("Schedule: trigger with key {} and state {} skipped", trigger.trigger.getKey(), trigger.state);
}
}
} else {
LOG.debug("Schedule: No triggers found in job store");
}
}
});
for (JobDetail job : jobs) {
super.storeJob(job, true);
}
for (TriggerStatusV2 trigger : triggers) {
super.storeTrigger(trigger.trigger, true);
// because the scheduler is actually not started at this point.
if (trigger.state == Trigger.TriggerState.PAUSED) {
super.pauseTrigger(trigger.trigger.getKey());
}
}
}
Aggregations