use of io.datarouter.job.BaseJob in project datarouter by hotpads.
the class JobScheduler method triggerManualJob.
public Outcome triggerManualJob(Class<? extends BaseJob> jobClass, String triggeredBy) {
JobPackage jobPackage = JobPackage.createManualFromScheduledPackage(jobPackageTracker.getForClass(jobClass));
BaseJob job = injector.getInstance(jobClass);
JobWrapper jobWrapper = jobWrapperFactory.createManual(jobPackage, job, triggeredBy);
return triggerManual(jobWrapper);
}
use of io.datarouter.job.BaseJob in project datarouter by hotpads.
the class JobScheduler method scheduleRetriggeredJob.
public void scheduleRetriggeredJob(JobPackage jobPackage, Instant officialTriggerTime) {
logger.warn("retriggering {} with official triggerTime {} to run immediately", jobPackage.jobClass.getSimpleName(), DateTool.formatAlphanumeric(officialTriggerTime.toEpochMilli()));
BaseJob nextJobInstance = injector.getInstance(jobPackage.jobClass);
JobWrapper jobWrapper = jobWrapperFactory.createRetriggered(jobPackage, nextJobInstance, officialTriggerTime, Instant.now(), getClass().getSimpleName() + " JobRetriggeringJob");
schedule(jobWrapper, 0, true, true);
}
use of io.datarouter.job.BaseJob in project datarouter by hotpads.
the class JobScheduler method scheduleNextRun.
/*-------------- schedule ----------------*/
private void scheduleNextRun(JobPackage jobPackage) {
Instant now = Instant.now();
Optional<Date> nextValidTimeAfter = jobPackage.getNextValidTimeAfter(Date.from(now));
if (nextValidTimeAfter.isEmpty()) {
logger.warn("couldn't schedule " + getClass() + " because no trigger defined");
return;
}
Instant nextTriggerTime = nextValidTimeAfter.get().toInstant();
Duration durationUntilNextTrigger = Duration.between(now, nextTriggerTime);
BaseJob nextJobInstance = injector.getInstance(jobPackage.jobClass);
JobWrapper jobWrapper = jobWrapperFactory.createScheduled(jobPackage, nextJobInstance, nextTriggerTime, nextTriggerTime, getClass().getSimpleName());
schedule(jobWrapper, durationUntilNextTrigger.toMillis(), false, false);
}