Class DefaultJobWorkerService

java.lang.Object
io.github.qsy7.queue.impl.worker.DefaultJobWorkerService
All Implemented Interfaces:
JobWorkerService, AutoCloseable

public class DefaultJobWorkerService extends Object implements JobWorkerService, AutoCloseable
  • Field Details

    • noOperation

      protected final boolean noOperation
    • shutdownTimeout

      protected final long shutdownTimeout
    • shutdownTimeoutUnits

      protected final TimeUnit shutdownTimeoutUnits
    • jobBuilder

      protected final JobBuilder jobBuilder
    • worker

      protected final io.github.qsy7.queue.api.model.Worker worker
    • scheduledThreadPoolExecutor

      protected final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor
    • shutdown

      protected boolean shutdown
    • runningFutures

      protected final Set<RunningFuture> runningFutures
  • Constructor Details

    • DefaultJobWorkerService

      @Inject public DefaultJobWorkerService(boolean noOperation, long shutdownTimeout, TimeUnit shutdownTimeoutUnits, JobBuilder jobBuilder, io.github.qsy7.queue.api.model.Worker worker)
  • Method Details

    • close

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

      protected void updateCancelledJobs()
    • handleRemovalOfRunnable

      protected void handleRemovalOfRunnable(Runnable runnable)
    • checkIfShutdown

      protected void checkIfShutdown()
    • queue

      public io.github.qsy7.queue.api.model.AbstractQueued queue(io.github.qsy7.queue.api.model.AbstractQueued queued)
      Specified by:
      queue in interface JobWorkerService
    • doQueue

      protected void doQueue(io.github.qsy7.queue.api.model.AbstractQueued queued)
    • cancel

      public void cancel(io.github.qsy7.queue.api.model.AbstractQueued queued)
      To be invoked by the queue service directly for cancelling jobs. The queue service handles the persistence operations.
      Specified by:
      cancel in interface JobWorkerService
      Parameters:
      queued - the job to cancel
    • cancel

      public void cancel(io.github.qsy7.queue.api.model.JobExecution jobExecution)
      To be invoked by the queue service directly for cancelling a specific job execution. The queue service handles the persistence operations.
      Specified by:
      cancel in interface JobWorkerService
      Parameters:
      jobExecution - the job execution to cancel
    • remove

      public void remove(RunningFuture runningFuture)
      To be invoked by the AbstractRunnable upon completion or failure.
      Specified by:
      remove in interface JobWorkerService
      Parameters:
      runningFuture - the completed job to remove from the list of running jobs
    • isNoOperation

      public boolean isNoOperation()
    • getShutdownTimeout

      public long getShutdownTimeout()
    • getShutdownTimeoutUnits

      public TimeUnit getShutdownTimeoutUnits()
    • getJobBuilder

      public JobBuilder getJobBuilder()
    • getWorker

      public io.github.qsy7.queue.api.model.Worker getWorker()
    • getScheduledThreadPoolExecutor

      public ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor()
    • isShutdown

      public boolean isShutdown()
    • getRunningFutures

      public Set<RunningFuture> getRunningFutures()