Interface JobCoordinator
-
- All Known Implementing Classes:
JobCoordinatorImpl
,OSGiJobCoordinator
public interface JobCoordinator
This interface defines methods for a JobCoordinator which enables executing jobs in a parallel/sequential fashion based on their keys.Jobs will be retried if any of the Futures returned from the Callable task have failed (Future contains an Exception). However if the Callable throws any Exception (which is not the same as as returning a failed Future containing an Exception), then there will be no retries.
Enqueued jobs are stored in unbounded queues until they are run, this should be kept in mind as it might lead to an OOM.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_RETRIES
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker)
Enqueues a job with DEFAULT_MAX_RETRIES (3) retries.default void
enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, int maxRetries)
Enqueues a job with max retries.default void
enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, RollbackCallable rollbackWorker)
Enqueues a job with a rollback task and DEFAULT_MAX_RETRIES (3) retries..void
enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, RollbackCallable rollbackWorker, int maxRetries)
Enqueues a job with a rollback task and max retries.
-
-
-
Field Detail
-
DEFAULT_MAX_RETRIES
static final int DEFAULT_MAX_RETRIES
- See Also:
- Constant Field Values
-
-
Method Detail
-
enqueueJob
default void enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker)
Enqueues a job with DEFAULT_MAX_RETRIES (3) retries. See class level documentation above for details re. the retry strategy.- Parameters:
key
- The job's key. Jobs with the same key are run sequentially. Jobs with different keys are run in parallel.mainWorker
- The task that runs for the job.
-
enqueueJob
default void enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, RollbackCallable rollbackWorker)
Enqueues a job with a rollback task and DEFAULT_MAX_RETRIES (3) retries.. See class level documentation above for details re. the retry strategy.- Parameters:
rollbackWorker
- The rollback task which runs in case the job's main task fails.- See Also:
enqueueJob(String, Callable)
-
enqueueJob
default void enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, int maxRetries)
Enqueues a job with max retries. In case the job's main task fails, it will be retried until it succeeds or the specified maximum number of retries has been reached. See class level documentation above for details re. the retry strategy.- Parameters:
maxRetries
- The maximum number of retries for the job's main task until it succeeds.- See Also:
enqueueJob(String, Callable)
-
enqueueJob
void enqueueJob(String key, Callable<List<? extends com.google.common.util.concurrent.ListenableFuture<?>>> mainWorker, RollbackCallable rollbackWorker, int maxRetries)
Enqueues a job with a rollback task and max retries. See class level documentation above for details re. the retry strategy.- Parameters:
rollbackWorker
- The rollback task which runs in case the job's main task fails.maxRetries
- The maximum number of retries for the job's main task until it succeeds.- See Also:
enqueueJob(String, Callable, RollbackCallable)
,enqueueJob(String, Callable, int)
-
-