Class ScheduledExecutorServiceHeaplet
- All Implemented Interfaces:
Heaplet
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 before
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 drains the queued tasks and notify the running tasks for interruption.
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).
-
Field Summary
-
Constructor Summary
-
Method Summary
Methods inherited from class org.forgerock.openig.heap.GenericHeaplet
create, endpointRegistry, evaluatedWithHeapProperties, expression, getConfig, getHeap, getType, initialBindings, meterRegistryHolder, start
-
Constructor Details
-
ScheduledExecutorServiceHeaplet
public ScheduledExecutorServiceHeaplet()
-
-
Method Details
-
create
Description copied from class:GenericHeaplet
Called to request the heaplet create an object. Called byHeaplet.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 theGenericHeaplet.start()
method.- Specified by:
create
in classGenericHeaplet
- Returns:
- The created object.
- Throws:
HeapException
- if an exception occurred during creation of the heap object or any of its dependencies.
-
destroy
public void destroy()Description copied from interface:Heaplet
Called to indicate that the object created by the heaplet is going to be dereferenced. This gives the heaplet an opportunity to free any resources that are being held prior to its dereference.- Specified by:
destroy
in interfaceHeaplet
- Overrides:
destroy
in classGenericHeaplet
-