Class JobCoordinatorImpl
- java.lang.Object
-
- org.opendaylight.infrautils.jobcoordinator.internal.JobCoordinatorImpl
-
- All Implemented Interfaces:
JobCoordinator
,JobCoordinatorMonitor
@Singleton public class JobCoordinatorImpl extends Object implements JobCoordinator, JobCoordinatorMonitor
-
-
Field Summary
-
Fields inherited from interface org.opendaylight.infrautils.jobcoordinator.JobCoordinator
DEFAULT_MAX_RETRIES
-
-
Constructor Summary
Constructors Constructor Description JobCoordinatorImpl(MetricProvider metricProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker)
Enqueues a job with DEFAULT_MAX_RETRIES (3) retries.void
enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, int maxRetries)
Enqueues a job with max retries.void
enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, RollbackCallable rollbackWorker)
Enqueues a job with a rollback task and DEFAULT_MAX_RETRIES (3) retries..void
enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, RollbackCallable rollbackWorker, int maxRetries)
Enqueues a job with a rollback task and max retries.long
getClearedTaskCount()
Returns the cleared task count.long
getCreatedTaskCount()
Returns the created task count.long
getFailedJobCount()
Returns the failed jobs count.long
getIncompleteTaskCount()
Returns the incomplete task count.protected Thread
getJobQueueHandlerThread()
Map<String,JobQueue>
getJobQueueMap()
long
getPendingTaskCount()
Returns the pending task count.long
getRetriesCount()
Returns the retry jobs count.String
toString()
-
-
-
Constructor Detail
-
JobCoordinatorImpl
@Inject public JobCoordinatorImpl(MetricProvider metricProvider)
-
-
Method Detail
-
destroy
@PreDestroy public void destroy()
-
enqueueJob
public void enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker)
Description copied from interface:JobCoordinator
Enqueues a job with DEFAULT_MAX_RETRIES (3) retries. See class level documentation above for details re. the retry strategy.- Specified by:
enqueueJob
in interfaceJobCoordinator
- 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
public void enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, RollbackCallable rollbackWorker)
Description copied from interface:JobCoordinator
Enqueues a job with a rollback task and DEFAULT_MAX_RETRIES (3) retries.. See class level documentation above for details re. the retry strategy.- Specified by:
enqueueJob
in interfaceJobCoordinator
rollbackWorker
- The rollback task which runs in case the job's main task fails.- See Also:
JobCoordinator.enqueueJob(String, Callable)
-
enqueueJob
public void enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, int maxRetries)
Description copied from interface:JobCoordinator
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.- Specified by:
enqueueJob
in interfaceJobCoordinator
maxRetries
- The maximum number of retries for the job's main task until it succeeds.- See Also:
JobCoordinator.enqueueJob(String, Callable)
-
enqueueJob
public void enqueueJob(String key, Callable<List<com.google.common.util.concurrent.ListenableFuture<Void>>> mainWorker, RollbackCallable rollbackWorker, int maxRetries)
Description copied from interface:JobCoordinator
Enqueues a job with a rollback task and max retries. See class level documentation above for details re. the retry strategy.- Specified by:
enqueueJob
in interfaceJobCoordinator
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:
JobCoordinator.enqueueJob(String, Callable, RollbackCallable)
,JobCoordinator.enqueueJob(String, Callable, int)
-
getClearedTaskCount
public long getClearedTaskCount()
Description copied from interface:JobCoordinatorMonitor
Returns the cleared task count.- Specified by:
getClearedTaskCount
in interfaceJobCoordinatorMonitor
-
getCreatedTaskCount
public long getCreatedTaskCount()
Description copied from interface:JobCoordinatorMonitor
Returns the created task count.- Specified by:
getCreatedTaskCount
in interfaceJobCoordinatorMonitor
-
getIncompleteTaskCount
public long getIncompleteTaskCount()
Description copied from interface:JobCoordinatorMonitor
Returns the incomplete task count.- Specified by:
getIncompleteTaskCount
in interfaceJobCoordinatorMonitor
-
getPendingTaskCount
public long getPendingTaskCount()
Description copied from interface:JobCoordinatorMonitor
Returns the pending task count.- Specified by:
getPendingTaskCount
in interfaceJobCoordinatorMonitor
-
getFailedJobCount
public long getFailedJobCount()
Description copied from interface:JobCoordinatorMonitor
Returns the failed jobs count.- Specified by:
getFailedJobCount
in interfaceJobCoordinatorMonitor
-
getRetriesCount
public long getRetriesCount()
Description copied from interface:JobCoordinatorMonitor
Returns the retry jobs count.- Specified by:
getRetriesCount
in interfaceJobCoordinatorMonitor
-
getJobQueueHandlerThread
protected Thread getJobQueueHandlerThread()
-
toString
public String toString()
- Specified by:
toString
in interfaceJobCoordinatorMonitor
- Overrides:
toString
in classObject
-
-