Class JobWorkerPool

java.lang.Object
org.graylog.scheduler.worker.JobWorkerPool

public class JobWorkerPool extends Object
Worker pool to execute jobs.
  • Constructor Details

    • JobWorkerPool

      @Inject public JobWorkerPool(String name, int poolSize, com.codahale.metrics.MetricRegistry metricRegistry)
  • Method Details

    • freeSlots

      public int freeSlots()
      Returns the number of free slots in the worker pool.
      Returns:
      numer of free slots
    • hasFreeSlots

      public boolean hasFreeSlots()
      Checks if there are free slots in the worker pool
      Returns:
      true if there are free slots, false otherwise
    • anySlotsUsed

      public boolean anySlotsUsed()
      Checks if there are any slots used in the worker pool
      Returns:
      true if there are slots used, false otherwise
    • execute

      public boolean execute(Runnable job)
      Exeute the given job in the worker pool if there are any free slots.
      Parameters:
      job - the job to execute
      Returns:
      true if the job could be executed, false otherwise
    • shutdown

      public void shutdown(Duration timeout) throws InterruptedException
      Throws:
      InterruptedException