Class JobQueuer

java.lang.Object
io.github.qsy7.queue.impl.scheduling.JobQueuer
All Implemented Interfaces:
StartupAware, AutoCloseable

@Singleton public class JobQueuer extends Object implements StartupAware
Makes jobs persistent that are registered with @Job.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final QueueService
     
    protected final org.reflections.Reflections
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JobQueuer(QueueService queueService, org.reflections.Reflections reflections)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addJobs(Set<io.github.qsy7.queue.api.model.QueuedJob> queuedJobs, Set<io.github.qsy7.queue.api.model.ScheduleInstance> scheduleInstances, Class jobClass, boolean system)
     
    protected boolean
    cancelJob(io.github.qsy7.queue.api.model.AbstractQueued queuedJob)
     
    protected void
    Cancel old Jobs (QueuedJob) versus (QueuedEvent), events are generated by the application and cannot be rescheduled However, QueuedJobs are "permanent" and can be rescheduled when the application is restarted.
    void
     
    protected Set<io.github.qsy7.queue.api.model.QueuedJob>
     
    protected Set<io.github.qsy7.queue.api.model.ScheduleInstance>
    getScheduleInstances(Job jobAnnotation)
     
    protected void
    scheduleJob(io.github.qsy7.queue.api.model.QueuedJob queuedJob)
     
    protected void
     
    void
    Any jobs that were in-flight at time of shutdown will be marked as cancelled and discovered jobs will be recreated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • queueService

      protected final QueueService queueService
    • reflections

      protected final org.reflections.Reflections reflections
  • Constructor Details

    • JobQueuer

      @Inject public JobQueuer(QueueService queueService, org.reflections.Reflections reflections)
  • Method Details

    • startup

      public void startup()
      Any jobs that were in-flight at time of shutdown will be marked as cancelled and discovered jobs will be recreated.
      Specified by:
      startup in interface StartupAware
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • cancelOldJobs

      protected void cancelOldJobs()
      Cancel old Jobs (QueuedJob) versus (QueuedEvent), events are generated by the application and cannot be rescheduled However, QueuedJobs are "permanent" and can be rescheduled when the application is restarted. In order to handle job schedule changes, mark all the incomplete ones as aborted, then reschedule anything found.
    • cancelJob

      protected boolean cancelJob(io.github.qsy7.queue.api.model.AbstractQueued queuedJob)
    • scheduleJobs

      protected void scheduleJobs()
    • scheduleJob

      protected void scheduleJob(io.github.qsy7.queue.api.model.QueuedJob queuedJob)
    • getQueuedJobs

      protected Set<io.github.qsy7.queue.api.model.QueuedJob> getQueuedJobs()
    • getScheduleInstances

      protected Set<io.github.qsy7.queue.api.model.ScheduleInstance> getScheduleInstances(Job jobAnnotation)
    • addJobs

      protected void addJobs(Set<io.github.qsy7.queue.api.model.QueuedJob> queuedJobs, Set<io.github.qsy7.queue.api.model.ScheduleInstance> scheduleInstances, Class jobClass, boolean system)