Search in sources :

Example 1 with BaseJob

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);
}
Also used : BaseJob(io.datarouter.job.BaseJob)

Example 2 with BaseJob

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);
}
Also used : BaseJob(io.datarouter.job.BaseJob)

Example 3 with BaseJob

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);
}
Also used : Instant(java.time.Instant) BaseJob(io.datarouter.job.BaseJob) Duration(java.time.Duration) Date(java.util.Date)

Aggregations

BaseJob (io.datarouter.job.BaseJob)3 Duration (java.time.Duration)1 Instant (java.time.Instant)1 Date (java.util.Date)1