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.

    • 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)