public final class JobBarrier extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JobBarrier.Result
Result of a waiting operation on a certain number of jobs.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_POLLING_INTERVAL
Default polling interval is 5 seconds
|
| Constructor and Description |
|---|
JobBarrier(Job waiter,
ServiceRegistry registry)
Creates a barrier without any jobs, using
registry to poll for the outcome of the monitored jobs using
the default polling interval DEFAULT_POLLING_INTERVAL. |
JobBarrier(Job waiter,
ServiceRegistry registry,
Job... jobs)
Creates a barrier for
jobs, using registry to poll for the outcome of the monitored jobs
using the default polling interval DEFAULT_POLLING_INTERVAL. |
JobBarrier(Job waiter,
ServiceRegistry registry,
long pollingInterval)
Creates a wrapper for
job, using registry to poll for the job outcome. |
JobBarrier(Job waiter,
ServiceRegistry registry,
long pollingInterval,
Job... jobs)
Creates a wrapper for
job, using registry to poll for the job outcome. |
| Modifier and Type | Method and Description |
|---|---|
void |
addJob(Job job)
Adds the job to the list of jobs to wait for.
|
JobBarrier.Result |
getStatus()
Returns the resulting status map.
|
JobBarrier.Result |
waitForJobs()
Waits for a status change and returns the new status.
|
JobBarrier.Result |
waitForJobs(long timeout)
Waits for a status change on all jobs and returns.
|
public static final long DEFAULT_POLLING_INTERVAL
public JobBarrier(Job waiter, ServiceRegistry registry)
registry to poll for the outcome of the monitored jobs using
the default polling interval DEFAULT_POLLING_INTERVAL. The waiter is the job which is waiting
for the other jobs to finish. Use addJob(Job) to add jobs to monitor.registry - the registrywaiter - the job waiting for the other jobs to finishpublic JobBarrier(Job waiter, ServiceRegistry registry, Job... jobs)
jobs, using registry to poll for the outcome of the monitored jobs
using the default polling interval DEFAULT_POLLING_INTERVAL. The waiter is the job which is
waiting for the other jobs to finish.registry - the registryjobs - the jobs to monitorwaiter - the job waiting for the other jobs to finishpublic JobBarrier(Job waiter, ServiceRegistry registry, long pollingInterval)
job, using registry to poll for the job outcome. The
waiter is the job which is waiting for the other jobs to finish.registry - the registrypollingInterval - the time in miliseconds between two polling operationswaiter - the job waiting for the other jobs to finishpublic JobBarrier(Job waiter, ServiceRegistry registry, long pollingInterval, Job... jobs)
job, using registry to poll for the job outcome. The
waiter is the job which is waiting for the other jobs to finish.jobs - the job to pollregistry - the registrypollingInterval - the time in miliseconds between two polling operationswaiter - the job waiting for the other jobs to finishpublic JobBarrier.Result waitForJobs()
public JobBarrier.Result waitForJobs(long timeout) throws JobCanceledException, IllegalStateException
timeout - the maximum amount of time to waitIllegalStateException - if there are no jobs to wait forJobCanceledException - if one of the jobs was canceledpublic void addJob(Job job) throws IllegalStateException
IllegalStateException is thrown if the barrier has already
been asked to wait for jobs by calling waitForJobs().job - the jobIllegalStateException - if the barrier already started waitingpublic JobBarrier.Result getStatus()
Copyright © 2009–2021 Opencast Project. All rights reserved.