Search in sources :

Example 1 with StopJobRequestDao

use of io.datarouter.job.storage.stopjobrequest.StopJobRequestDao in project datarouter by hotpads.

the class JobStopperService method requestStop.

/**
 * generates requests to stop a job running on the specified servers in the cluster. the requests are not processed
 * until {@link JobStopperService#stopRequestedLocalJobs} is called (see {@link DatarouterJobStopperJob})
 * @param jobName the name of the job (class) to stop
 * @param serverNames the servers on which to attempt to stop the job
 * @param username the username that requested the stop
 */
public void requestStop(String jobName, List<String> serverNames, String username) {
    Instant jobTriggerDeadline = Instant.now();
    Instant requestExpiration = jobTriggerDeadline.plus(3L, ChronoUnit.MINUTES);
    Scanner.of(serverNames).map(serverName -> new StopJobRequest(serverName, requestExpiration, jobTriggerDeadline, jobName, username)).flush(stopJobRequestDao::putMulti);
}
Also used : StopJobRequestDao(io.datarouter.job.storage.stopjobrequest.StopJobRequestDao) Scanner(io.datarouter.scanner.Scanner) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseJob(io.datarouter.job.BaseJob) StopJobRequest(io.datarouter.job.storage.stopjobrequest.StopJobRequest) JobWrapper(io.datarouter.job.scheduler.JobWrapper) DatarouterJobStopperJob(io.datarouter.job.job.DatarouterJobStopperJob) Instant(java.time.Instant) Singleton(javax.inject.Singleton) ServerName(io.datarouter.storage.config.properties.ServerName) Supplier(java.util.function.Supplier) ChangelogRecorder(io.datarouter.instrumentation.changelog.ChangelogRecorder) Inject(javax.inject.Inject) LocalTriggerLockService(io.datarouter.job.lock.LocalTriggerLockService) List(java.util.List) Future(java.util.concurrent.Future) ChronoUnit(java.time.temporal.ChronoUnit) JobScheduler(io.datarouter.job.scheduler.JobScheduler) ThreadTool(io.datarouter.util.concurrent.ThreadTool) Instant(java.time.Instant) StopJobRequest(io.datarouter.job.storage.stopjobrequest.StopJobRequest)

Aggregations

ChangelogRecorder (io.datarouter.instrumentation.changelog.ChangelogRecorder)1 DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)1 BaseJob (io.datarouter.job.BaseJob)1 DatarouterJobStopperJob (io.datarouter.job.job.DatarouterJobStopperJob)1 LocalTriggerLockService (io.datarouter.job.lock.LocalTriggerLockService)1 JobScheduler (io.datarouter.job.scheduler.JobScheduler)1 JobWrapper (io.datarouter.job.scheduler.JobWrapper)1 StopJobRequest (io.datarouter.job.storage.stopjobrequest.StopJobRequest)1 StopJobRequestDao (io.datarouter.job.storage.stopjobrequest.StopJobRequestDao)1 Scanner (io.datarouter.scanner.Scanner)1 ServerName (io.datarouter.storage.config.properties.ServerName)1 ThreadTool (io.datarouter.util.concurrent.ThreadTool)1 Instant (java.time.Instant)1 ChronoUnit (java.time.temporal.ChronoUnit)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 Supplier (java.util.function.Supplier)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1