Class HibernateJobQueue

  • All Implemented Interfaces:
    JobQueue

    @Transactional
    public class HibernateJobQueue
    extends java.lang.Object
    implements JobQueue
    Db Job Manager.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(PrintJobEntry jobEntry)
      Add new job entry to the queue.
      void cancel​(java.lang.String referenceId, java.lang.String message, boolean forceFinal)
      Mark job as canceling (if running) or canceled (if waiting / finished).
      void cancelOld​(long startTimeOut, long abandonTimeout, java.lang.String message)
      Cancel old WAITING tasks.
      void delete​(java.lang.String referenceId)
      Delete the job.
      void done​(java.lang.String referenceId, PrintJobResult result)
      Mark job as done.
      void fail​(java.lang.String referenceId, java.lang.String message)
      Mark job as failed.
      PrintJobStatus get​(java.lang.String referenceId, boolean external)
      Return the completed job object if the job has completed or absent otherwise.
      long getAverageTimeSpentPrinting()
      Get the average time print jobs take to complete.
      long getLastPrintCount()
      Get the number of prints that finished (either by error or success).
      long getNumberOfRequestsMade()
      Get the total number of print requests made.
      long getTimeToKeepAfterAccessInMillis()
      Return the amount of time the queue will keep an entry before purging the record.
      long getWaitingJobsCount()
      Get the total number of waiting/running jobs.
      void init()
      Called by spring on initialization.
      void setTimeToKeepAfterAccessInMinutes​(int timeToKeepAfterAccessInMinutes)  
      void shutdown()
      Called by spring when application context is being destroyed.
      java.util.List<? extends PrintJobStatus> start​(int number)
      Start the next [N] number of jobs at once.
      void start​(java.lang.String referenceId)
      Mark job as running.
      long timeSinceLastStatusCheck​(java.lang.String referenceId)
      Get the time since a client has last requested the print job.
      java.util.List<? extends PrintJobStatus> toCancel()
      Get the jobs that are marked as "CANCELING" and must be canceled.
      • Methods inherited from class java.lang.Object

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

      • HibernateJobQueue

        public HibernateJobQueue()
    • Method Detail

      • setTimeToKeepAfterAccessInMinutes

        public final void setTimeToKeepAfterAccessInMinutes​(int timeToKeepAfterAccessInMinutes)
      • getTimeToKeepAfterAccessInMillis

        public final long getTimeToKeepAfterAccessInMillis()
        Description copied from interface: JobQueue
        Return the amount of time the queue will keep an entry before purging the record.
        Specified by:
        getTimeToKeepAfterAccessInMillis in interface JobQueue
        Returns:
        the number of milliseconds between the last access of a record and the time when a record can be purged from the registry. -1 if there it is unlimited.
      • getLastPrintCount

        public final long getLastPrintCount()
        Description copied from interface: JobQueue
        Get the number of prints that finished (either by error or success).
        Specified by:
        getLastPrintCount in interface JobQueue
      • getWaitingJobsCount

        public final long getWaitingJobsCount()
        Description copied from interface: JobQueue
        Get the total number of waiting/running jobs.
        Specified by:
        getWaitingJobsCount in interface JobQueue
      • getNumberOfRequestsMade

        public final long getNumberOfRequestsMade()
        Description copied from interface: JobQueue
        Get the total number of print requests made.
        Specified by:
        getNumberOfRequestsMade in interface JobQueue
      • getAverageTimeSpentPrinting

        public final long getAverageTimeSpentPrinting()
        Description copied from interface: JobQueue
        Get the average time print jobs take to complete.
        Specified by:
        getAverageTimeSpentPrinting in interface JobQueue
      • timeSinceLastStatusCheck

        @Transactional(readOnly=true)
        public long timeSinceLastStatusCheck​(java.lang.String referenceId)
        Description copied from interface: JobQueue
        Get the time since a client has last requested the print job.
        Specified by:
        timeSinceLastStatusCheck in interface JobQueue
        Parameters:
        referenceId - the id of the print job
      • get

        public final PrintJobStatus get​(java.lang.String referenceId,
                                        boolean external)
                                 throws NoSuchReferenceException
        Description copied from interface: JobQueue
        Return the completed job object if the job has completed or absent otherwise.
        Specified by:
        get in interface JobQueue
        Parameters:
        referenceId - the referenceId of the report to lookup
        external - true if external status request
        Throws:
        NoSuchReferenceException
      • add

        public final void add​(PrintJobEntry jobEntry)
        Description copied from interface: JobQueue
        Add new job entry to the queue.
        Specified by:
        add in interface JobQueue
        Parameters:
        jobEntry - the job to run.
      • cancel

        public final void cancel​(java.lang.String referenceId,
                                 java.lang.String message,
                                 boolean forceFinal)
                          throws NoSuchReferenceException
        Description copied from interface: JobQueue
        Mark job as canceling (if running) or canceled (if waiting / finished).
        Specified by:
        cancel in interface JobQueue
        Parameters:
        referenceId - reference id to the job that has failed.
        message - the error message
        forceFinal - finalize, even if status is running
        Throws:
        NoSuchReferenceException
      • fail

        public final void fail​(java.lang.String referenceId,
                               java.lang.String message)
                        throws NoSuchReferenceException
        Description copied from interface: JobQueue
        Mark job as failed.
        Specified by:
        fail in interface JobQueue
        Parameters:
        referenceId - reference id to the job that has failed.
        message - the error message
        Throws:
        NoSuchReferenceException
      • cancelOld

        public final void cancelOld​(long startTimeOut,
                                    long abandonTimeout,
                                    java.lang.String message)
        Description copied from interface: JobQueue
        Cancel old WAITING tasks.
        Specified by:
        cancelOld in interface JobQueue
        Parameters:
        startTimeOut - time-out value from when job started
        abandonTimeout - time-out value form last status request
        message - error message
      • start

        public final java.util.List<? extends PrintJobStatus> start​(int number)
        Description copied from interface: JobQueue
        Start the next [N] number of jobs at once.
        Specified by:
        start in interface JobQueue
        Parameters:
        number - the number of jobs to start
        Returns:
        the jobs that were just started
      • toCancel

        public final java.util.List<? extends PrintJobStatus> toCancel()
        Description copied from interface: JobQueue
        Get the jobs that are marked as "CANCELING" and must be canceled.
        Specified by:
        toCancel in interface JobQueue
      • delete

        public void delete​(java.lang.String referenceId)
        Description copied from interface: JobQueue
        Delete the job.
        Specified by:
        delete in interface JobQueue
        Parameters:
        referenceId - reference id to the job.
      • init

        @PostConstruct
        public final void init()
        Called by spring on initialization.
      • shutdown

        @PreDestroy
        public final void shutdown()
        Called by spring when application context is being destroyed.