Package org.opencastproject.util
Class JobUtil
java.lang.Object
org.opencastproject.util.JobUtil
Job related utility functions.
-
Method Summary
Modifier and TypeMethodDescriptiongetNonFinished(List<Job> jobs) Get all jobs that are not in stateJob.Status.FINISHED.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.jobFromHttpResponse(org.apache.http.HttpResponse response) static MediaPackageElementpayloadAsMediaPackageElement(Job waiter, ServiceRegistry reg, Job job) Interpret the payload of a completedJobas aMediaPackageElement.static MediaPackageElementpayloadAsMediaPackageElement(ServiceRegistry reg, Job job) Interpret the payload of a completedJobas aMediaPackageElement.static longsumQueueTime(List<Job> jobs) Sum up the queue time of a list of jobs.update(ServiceRegistry reg, Job job) Get the latest state of a job.static JobBarrier.ResultwaitForJob(Job waiter, ServiceRegistry reg, Optional<Long> timeout, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJob(Job waiter, ServiceRegistry reg, Job job) Check ifjobis not done yet and wait in case.static JobBarrier.ResultwaitForJob(ServiceRegistry reg, Optional<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.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.static booleanwaitForJobSuccess(Job waiter, ServiceRegistry reg, Optional<Long> timeout, Job job) Wait for the job to complete and return the success value.
-
Method Details
-
getPayload
public static Optional<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
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, Optional<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 boolean waitForJobSuccess(Job waiter, ServiceRegistry reg, Optional<Long> timeout, Job job) Wait for the job to complete and return the success value. -
payloadAsMediaPackageElement
public static MediaPackageElement payloadAsMediaPackageElement(Job waiter, ServiceRegistry reg, Job job) 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. -
jobFromHttpResponse
-
sumQueueTime
Sum up the queue time of a list of jobs. -
getNonFinished
Get all jobs that are not in stateJob.Status.FINISHED.
-