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).
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.forgerock.openig.heap.GenericHeaplet
create, endpointRegistry, evaluatedWithHeapProperties, expression, getConfig, getHeap, getType, initialBindings, meterRegistryHolder, start
-
Field Details
-
NAME
Public name used by resolver.- See Also:
-
-
Constructor Details
-
ScheduledExecutorServiceHeaplet
public ScheduledExecutorServiceHeaplet()
-
-
Method Details
-
create
Description copied from class:GenericHeapletCalled 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:
createin 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 class:GenericHeapletReleases observability resources: deregisters the HTTP endpoint, all meters, and startup metrics.Subclasses that override this method must call
super.destroy()last, after releasing their own domain resources. This ensures that monitoring remains active for the full lifetime of those resources and that any metrics emitted during shutdown are not lost.- Specified by:
destroyin interfaceHeaplet- Overrides:
destroyin classGenericHeaplet
-