Class BasicJob

  • All Implemented Interfaces:
    Job, java.lang.Comparable<Job>

    public class BasicJob
    extends java.lang.Object
    implements Job
    Author:
    Ween Jiann Lee
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Job job)  
      Handler getHandler()
      Get the handler to handle the response of the job.
      Priority getPriority()
      Get the current priority set for this job.
      Request getRequest()
      Get the request of this job.
      int getTryCount()
      Get attempt number of this job.
      void reQueue()
      Remove any existing in queue, downgrades the priority and adds the job back into queue.
      • Methods inherited from class java.lang.Object

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

      • BasicJob

        public BasicJob​(Request request,
                        Handler handler,
                        Priority priority,
                        Priority priorityFloor,
                        java.util.Queue<Job> queue)
        Constructs a basic job.
        Parameters:
        request - The request of this job.
        handler - The handler of this job.
        priority - The priority of this job.
        priorityFloor - The priority floor of this job.
        queue - The queue for this job.
    • Method Detail

      • getRequest

        public final Request getRequest()
        Description copied from interface: Job
        Get the request of this job.
        Specified by:
        getRequest in interface Job
        Returns:
        Request of the job.
      • getHandler

        public final Handler getHandler()
        Description copied from interface: Job
        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.

        Specified by:
        getHandler in interface Job
        Returns:
        Handler for the response or null.
      • getPriority

        public final Priority getPriority()
        Description copied from interface: Job
        Get the current priority set for this job.
        Specified by:
        getPriority in interface Job
        Returns:
        the current priority of the job.
      • reQueue

        public final void reQueue()
        Description copied from interface: Job
        Remove any existing in queue, downgrades the priority and adds the job back into queue.
        Specified by:
        reQueue in interface Job
      • getTryCount

        public final int getTryCount()
        Description copied from interface: Job
        Get attempt number of this job.
        Specified by:
        getTryCount in interface Job
        Returns:
        Attempt (try) count of the job.
      • compareTo

        public final int compareTo​(@Nonnull
                                   Job job)
        Specified by:
        compareTo in interface java.lang.Comparable<Job>