Class JobUtil

java.lang.Object
org.opencastproject.util.JobUtil

public final class JobUtil extends Object
Job related utility functions.
  • Field Details

    • jobFromHttpResponse

      public static final Function<org.apache.http.HttpResponse,Option<Job>> 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:
      NotFoundException
      ServiceRegistryException
    • 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 the job parameter.
      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 for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval. The waiter is the job which is waiting for the other jobs to finish.
      Parameters:
      waiter - the job waiting for the other jobs to finish
      reg - the service registry
      pollingInterval - the time in miliseconds between two polling operations
      timeout - the maximum amount of time to wait
      jobs - 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 for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval. The waiter is the job which is waiting for the other jobs to finish.
      Parameters:
      waiter - the job waiting for the other jobs to finish
      reg - the service registry
      timeout - the maximum amount of time to wait
      jobs - the jobs to monitor
      Returns:
      the job barrier result
    • waitForJobs

      public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, Job... jobs)
      Waits for the result of a created barrier for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval. The waiter is the job which is waiting for the other jobs to finish.
      Parameters:
      waiter - the job waiting for the other jobs to finish
      reg - the service registry
      jobs - the jobs to monitor
      Returns:
      the job barrier result
    • waitForJobs

      public static JobBarrier.Result waitForJobs(ServiceRegistry reg, Job... jobs)
      Waits for the result of a created barrier for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval.
      Parameters:
      reg - the service registry
      jobs - the jobs to monitor
      Returns:
      the job barrier result
    • waitForJobs

      public static JobBarrier.Result waitForJobs(Job waiter, ServiceRegistry reg, Collection<Job> jobs)
      Waits for the result of a created barrier for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval. The waiter is the job which is waiting for the other jobs to finish.
      Parameters:
      waiter - the job waiting for the other jobs to finish
      reg - the service registry
      jobs - the jobs to monitor
      Returns:
      the job barrier result
    • waitForJobs

      public static JobBarrier.Result waitForJobs(ServiceRegistry reg, Collection<Job> jobs)
      Waits for the result of a created barrier for jobs, using registry to poll for the outcome of the monitored jobs using the default polling interval.
      Parameters:
      reg - the service registry
      jobs - 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 if job is not done yet and wait in case.
    • waitForJob

      public static JobBarrier.Result waitForJob(ServiceRegistry reg, Option<Long> timeout, Job job)
      Check if job is not done yet and wait in case.
    • waitForJob

      public static JobBarrier.Result waitForJob(Job waiter, ServiceRegistry reg, Job job)
      Check if job is not done yet and wait in case.
      Parameters:
      waiter - the job waiting for the other jobs to finish
      reg - the service registry
      job - the job to monitor
      Returns:
      the job barrier result
    • waitForJob

      public static JobBarrier.Result waitForJob(ServiceRegistry reg, Job job)
      Check if job is not done yet and wait in case.
    • isReadyToDispatch

      public static boolean isReadyToDispatch(Job job) throws IllegalStateException
      Returns true if the job is ready to be dispatched.
      Parameters:
      job - the job
      Returns:
      true whether 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 completed Job as a MediaPackageElement. Wait for the job to complete if necessary.
    • payloadAsMediaPackageElement

      public static Function<Job,MediaPackageElement> payloadAsMediaPackageElement(ServiceRegistry reg)
      Interpret the payload of a completed Job as a MediaPackageElement. Wait for the job to complete if necessary.
    • sumQueueTime

      public static long sumQueueTime(List<Job> jobs)
      Sum up the queue time of a list of jobs.
    • getNonFinished

      public static List<Job> getNonFinished(List<Job> jobs)
      Get all jobs that are not in state Job.Status.FINISHED.