Package org.opencastproject.util
Class JobUtil
java.lang.Object
org.opencastproject.util.JobUtil
Job related utility functions.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Method Summary
Modifier and TypeMethodDescriptiongetNonFinished(List<Job> jobs) Get all jobs that are not in stateJob.Status.FINISHED.static com.entwinemedia.fn.data.Opt<String> getPayload(ServiceRegistry reg, Job job) Update the job from the service registry and get its payload.static booleanisReadyToDispatch(Job job) Returnstrueif the job is ready to be dispatched.static Function<Job, MediaPackageElement> payloadAsMediaPackageElement(Job waiter, ServiceRegistry reg) Interpret the payload of a completedJobas aMediaPackageElement.static Function<Job, MediaPackageElement> Interpret the payload of a completedJobas aMediaPackageElement.static longsumQueueTime(List<Job> jobs) Sum up the queue time of a list of jobs.static com.entwinemedia.fn.data.Opt<Job> update(ServiceRegistry reg, Job job) Get the latest state of a job.static JobBarrier.ResultwaitForJob(Job waiter, ServiceRegistry reg, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJob(Job waiter, ServiceRegistry reg, Option<Long> timeout, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJob(ServiceRegistry reg, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJob(ServiceRegistry reg, Option<Long> timeout, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJobs(Job waiter, ServiceRegistry reg, long pollingInterval, long timeout, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.static JobBarrier.ResultwaitForJobs(Job waiter, ServiceRegistry reg, long timeout, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.static JobBarrier.ResultwaitForJobs(Job waiter, ServiceRegistry reg, Collection<Job> jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.static JobBarrier.ResultwaitForJobs(Job waiter, ServiceRegistry reg, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.static JobBarrier.ResultwaitForJobs(ServiceRegistry reg, Collection<Job> jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.static JobBarrier.ResultwaitForJobs(ServiceRegistry reg, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.waitForJobSuccess(Job waiter, ServiceRegistry reg, Option<Long> timeout) Wait for the job to complete and return the success value.
-
Field Details
-
jobFromHttpResponse
-
-
Method Details
-
getPayload
public static com.entwinemedia.fn.data.Opt<String> getPayload(ServiceRegistry reg, Job job) throws NotFoundException, ServiceRegistryException Update the job from the service registry and get its payload.- Returns:
- the payload or none, if either to job cannot be found or if the job has no or an empty payload
- Throws:
NotFoundExceptionServiceRegistryException
-
update
public static com.entwinemedia.fn.data.Opt<Job> update(ServiceRegistry reg, Job job) throws ServiceRegistryException Get the latest state of a job. Does not modify thejobparameter.- Returns:
- the updated job or none, if it cannot be found
- Throws:
ServiceRegistryException
-
waitForJobs
public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, long pollingInterval, long timeout, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval. Thewaiteris the job which is waiting for the other jobs to finish.- Parameters:
waiter- the job waiting for the other jobs to finishreg- the service registrypollingInterval- the time in miliseconds between two polling operationstimeout- the maximum amount of time to waitjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJobs
public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, long timeout, Job... jobs) Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval. Thewaiteris the job which is waiting for the other jobs to finish.- Parameters:
waiter- the job waiting for the other jobs to finishreg- the service registrytimeout- the maximum amount of time to waitjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJobs
Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval. Thewaiteris the job which is waiting for the other jobs to finish.- Parameters:
waiter- the job waiting for the other jobs to finishreg- the service registryjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJobs
Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.- Parameters:
reg- the service registryjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJobs
Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval. Thewaiteris the job which is waiting for the other jobs to finish.- Parameters:
waiter- the job waiting for the other jobs to finishreg- the service registryjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJobs
Waits for the result of a created barrier forjobs, usingregistryto poll for the outcome of the monitored jobs using the default polling interval.- Parameters:
reg- the service registryjobs- the jobs to monitor- Returns:
- the job barrier result
-
waitForJob
public static JobBarrier.Result waitForJob(Job waiter, ServiceRegistry reg, Option<Long> timeout, Job job) Check ifjobis not done yet and wait in case. -
waitForJob
Check ifjobis not done yet and wait in case. -
waitForJob
Check ifjobis not done yet and wait in case.- Parameters:
waiter- the job waiting for the other jobs to finishreg- the service registryjob- the job to monitor- Returns:
- the job barrier result
-
waitForJob
Check ifjobis not done yet and wait in case. -
isReadyToDispatch
Returnstrueif the job is ready to be dispatched.- Parameters:
job- the job- Returns:
truewhether the job is ready to be dispatched- Throws:
IllegalStateException- if the job status is unknown
-
waitForJobSuccess
public static Function<Job,Boolean> waitForJobSuccess(Job waiter, ServiceRegistry reg, Option<Long> timeout) Wait for the job to complete and return the success value. -
payloadAsMediaPackageElement
public static Function<Job,MediaPackageElement> payloadAsMediaPackageElement(Job waiter, ServiceRegistry reg) Interpret the payload of a completedJobas aMediaPackageElement. Wait for the job to complete if necessary. -
payloadAsMediaPackageElement
Interpret the payload of a completedJobas aMediaPackageElement. Wait for the job to complete if necessary. -
sumQueueTime
Sum up the queue time of a list of jobs. -
getNonFinished
Get all jobs that are not in stateJob.Status.FINISHED.
-