Package org.graylog.scheduler.worker
Class JobWorkerPool
java.lang.Object
org.graylog.scheduler.worker.JobWorkerPool
- All Implemented Interfaces:
GracefulShutdownHook
Worker pool to execute jobs.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionJobWorkerPool
(String name, int poolSize, Runnable shutdownCallback, GracefulShutdownService gracefulShutdownService, com.codahale.metrics.MetricRegistry metricRegistry) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if there are any slots used in the worker poolvoid
Execute shutdown tasks for the service that implements this interface.boolean
Exeute the given job in the worker pool if there are any free slots.int
Returns the number of free slots in the worker pool.boolean
Checks if there are free slots in the worker pool
-
Constructor Details
-
JobWorkerPool
@Inject public JobWorkerPool(String name, int poolSize, Runnable shutdownCallback, GracefulShutdownService gracefulShutdownService, 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
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
-
doGracefulShutdown
Description copied from interface:GracefulShutdownHook
Execute shutdown tasks for the service that implements this interface.Warning:
- This method is called from another thread so the class that implements
GracefulShutdownHook
must be thread-safe. - The server shutdown is waiting for this method call to complete. Blocking this method will block the server shutdown!
- Specified by:
doGracefulShutdown
in interfaceGracefulShutdownHook
- Throws:
Exception
- This method is called from another thread so the class that implements
-