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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionJobWorkerPool(String name, int poolSize, Runnable shutdownCallback, GracefulShutdownService gracefulShutdownService, com.codahale.metrics.MetricRegistry metricRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if there are any slots used in the worker poolvoidExecute shutdown tasks for the service that implements this interface.booleanExeute the given job in the worker pool if there are any free slots.intReturns the number of free slots in the worker pool.booleanChecks 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:GracefulShutdownHookExecute shutdown tasks for the service that implements this interface.Warning:
- This method is called from another thread so the class that implements
GracefulShutdownHookmust be thread-safe. - The server shutdown is waiting for this method call to complete. Blocking this method will block the server shutdown!
- Specified by:
doGracefulShutdownin interfaceGracefulShutdownHook- Throws:
Exception
- This method is called from another thread so the class that implements
-