public class JobWorkerPool extends Object implements GracefulShutdownHook
| Modifier and Type | Class and Description |
|---|---|
static interface |
JobWorkerPool.Factory |
| Constructor and Description |
|---|
JobWorkerPool(String name,
int poolSize,
Runnable shutdownCallback,
GracefulShutdownService gracefulShutdownService,
com.codahale.metrics.MetricRegistry metricRegistry) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
anySlotsUsed()
Checks if there are any slots used in the worker pool
|
void |
doGracefulShutdown()
Execute shutdown tasks for the service that implements this interface.
|
boolean |
execute(Runnable job)
Exeute the given job in the worker pool if there are any free slots.
|
int |
freeSlots()
Returns the number of free slots in the worker pool.
|
boolean |
hasFreeSlots()
Checks if there are free slots in the worker pool
|
@Inject public JobWorkerPool(String name, int poolSize, Runnable shutdownCallback, GracefulShutdownService gracefulShutdownService, com.codahale.metrics.MetricRegistry metricRegistry)
public int freeSlots()
public boolean hasFreeSlots()
public boolean anySlotsUsed()
public boolean execute(Runnable job)
job - the job to executepublic void doGracefulShutdown()
throws Exception
GracefulShutdownHookGracefulShutdownHook must be thread-safe.doGracefulShutdown in interface GracefulShutdownHookExceptionCopyright © 2012–2022 Graylog, Inc.. All rights reserved.