public class ScheduledExecutorServiceHeaplet extends GenericHeaplet
Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
Reference:
{
"type": "ScheduledExecutorService",
"config": {
"corePoolSize": integer > 0 [ OPTIONAL - default to 1 (will grow as needed)]
"gracefulStop": boolean [ OPTIONAL - default to true (all running jobs will complete)]
"gracePeriod" : duration [ OPTIONAL - default to '10 second']
}
}
Usage:
{
"type": "ScheduledExecutorService",
"config": {
"corePoolSize": 42 // defaults to 1 (will grow as needed), only positive and non-zero
}
}
This class supports graceful stop.
gracefulStop
is a setting that allows a thread pool to wind down nicely without
killing aggressively running (and submitted) jobs.
{
"gracefulStop": false // defaults to true
}
gracefulPeriod
attribute defines how long the heaplet should wait for jobs to actually terminate properly.
Note that this setting is only considered when gracefulStop
is set to true.
{
"gracePeriod": "20 seconds" // defaults to 10 seconds
}
When the period is over, if the executor service is not properly terminated, the heaplet prints a message and exits.
Note that all configuration attributes can be defined using static expressions (they can't be resolved against
context
or request
objects that are not available at init time).
Constructor and Description |
---|
ScheduledExecutorServiceHeaplet() |
Modifier and Type | Method and Description |
---|---|
ExecutorService |
create()
Called to request the heaplet create an object.
|
void |
destroy()
Called to indicate that the object created by the heaplet is going to be dereferenced.
|
create, endpointRegistry, evaluatedWithHeapProperties, expression, getConfig, getHeap, getSecretService, getType, meterRegistryHolder, start
public ExecutorService create() throws HeapException
GenericHeaplet
Heaplet.create(Name, JsonValue, Heap)
after initializing
the protected field members. Implementations should parse configuration
but not acquire resources, start threads, or log any initialization
messages. These tasks should be performed by the GenericHeaplet.start()
method.create
in class GenericHeaplet
HeapException
- if an exception occurred during creation of the heap object
or any of its dependencies.public void destroy()
Heaplet
destroy
in interface Heaplet
destroy
in class GenericHeaplet
Copyright 2011-2017 ForgeRock AS.