Class Job


  • public class Job
    extends java.lang.Object
    This class will be placed in a scheduler for queuing requests.
    Author:
    Maksim Tkachenko, Ween Jiann Lee
    • Constructor Summary

      Constructors 
      Constructor Description
      Job​(@NotNull Request request)
      Constructs a basic job.
      Job​(@NotNull Request request, Handler handler)
      Constructs a basic job.
      Job​(@NotNull Request request, Handler handler, @NotNull JobAttribute... jobAttributes)
      Constructs a basic job.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Handler getHandler()
      Get the handler to handle the response of the job.
      <T extends JobAttribute>
      T
      getJobAttribute​(java.lang.Class<T> clazz)
      Get the job attribute for a specific attribute class or return null if not found.
      @NotNull Request getRequest()
      Get the request of this job.
      int getTryCount()
      Get attempt number of this job.
      void prepareRetry()
      This method is called before the job is scheduled for a retry.
      Job setJobAttribute​(JobAttribute jobAttribute)
      Adds or replace the current job attribute if the class of attribute is already present in the map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Job

        public Job​(@NotNull
                   @NotNull Request request,
                   Handler handler,
                   @NotNull
                   @NotNull JobAttribute... jobAttributes)
        Constructs a basic job.
        Parameters:
        request - The request of this job.
        handler - The handler of this job.
        jobAttributes - attributes to insert to the job.
      • Job

        public Job​(@NotNull
                   @NotNull Request request,
                   Handler handler)
        Constructs a basic job.
        Parameters:
        request - The request of this job.
        handler - The handler of this job.
      • Job

        public Job​(@NotNull
                   @NotNull Request request)
        Constructs a basic job.
        Parameters:
        request - The request of this job.
    • Method Detail

      • getRequest

        @NotNull
        public final @NotNull Request getRequest()
        Get the request of this job.
        Returns:
        Request of the job.
      • getHandler

        @Nullable
        public final Handler getHandler()
        Get the handler to handle the response of the job.

        If handler is null, routed handler will be used to assign a handler to the response, based on its criteria.

        Returns:
        Handler for the response or null.
      • getTryCount

        public final int getTryCount()
        Get attempt number of this job.
        Returns:
        Attempt (try) count of the job.
      • prepareRetry

        public final void prepareRetry()
        This method is called before the job is scheduled for a retry.

        This method allows you to specify the logic to move the job into its subsequent state for a retry.

      • setJobAttribute

        public final Job setJobAttribute​(JobAttribute jobAttribute)
        Adds or replace the current job attribute if the class of attribute is already present in the map.
        Parameters:
        jobAttribute - the job attribute to add or replace.
        Returns:
        this.
      • getJobAttribute

        public final <T extends JobAttribute> T getJobAttribute​(java.lang.Class<T> clazz)
        Get the job attribute for a specific attribute class or return null if not found.
        Type Parameters:
        T - the class of attribute to find.
        Parameters:
        clazz - the class of attribute to find.
        Returns:
        an instance of job attribute for class or null.