Class RemoteJob

java.lang.Object
sg.dex.starfish.impl.remote.RemoteJob
All Implemented Interfaces:
Future<Map<String,​Object>>, Job

public class RemoteJob
extends Object
implements Job
This class represents a remote Job executed via the Invoke API on a remote agent.
  • Method Details

    • create

      public static RemoteJob create​(RemoteAgent agent2, String jobID)
      Creates a RemoteJob representing a Job on a given RemoteAgent.

      Does not perform any validation on the existence of the Job

      Parameters:
      agent2 -
      jobID -
      Returns:
    • isDone

      public boolean isDone()
      Description copied from interface: Job
      Returns true if the Job has been completed, either due to success, failure or cancellation.

      If the job has succeeded, the result may be obtained via get() or getResult()

      Specified by:
      isDone in interface Future<Map<String,​Object>>
      Specified by:
      isDone in interface Job
      Returns:
      boolean true if the job is complete, false otherwise.
    • pollResult

      public Map<String,​Object> pollResult()
      Polls the invokable service job for a complete result.

      Returns null if the Job has not completed, or if the remote service cannot be accessed

      Specified by:
      pollResult in interface Job
      Returns:
      The Map of where key will be the result and value will be the payload
      Throws:
      JobFailedException - If the job has failed
    • get

      public Map<String,​Object> get​(long timeout, TimeUnit timeUnit) throws TimeoutException
      Description copied from interface: Job
      Waits for the result of the Operation and returns the result map.

      Throws an exception if: - the timeout in milliseconds expires before the asset is available. - The Job fails or is cancelled

      A timeout will not prevent the Job from completing at a later time.

      Specified by:
      get in interface Future<Map<String,​Object>>
      Specified by:
      get in interface Job
      Returns:
      The result map from the job
      Throws:
      TimeoutException - if the result is not returned by the given timeout
    • getStatus

      public String getStatus()
      Description copied from interface: Job
      Gets the status of the Job associated with this Operation. As mentioned in DEP6 ,the status of job can be: scheduled ,running,succeeded,failed,unknown
      Specified by:
      getStatus in interface Job
      Returns:
      The the status of the Job
    • getJobID

      public String getJobID()
      Description copied from interface: Job
      Gets the Job ID associated with this Job. Job IDs are allocated by the agent implementation responsible for completing the job, and may be used to refer to the Job via other mechanisms.

      The definition of a Job ID is Agent-specific

      Specified by:
      getJobID in interface Job
      Returns:
      jobID