Class ScheduledExecutorServiceHeaplet
- java.lang.Object
-
- org.forgerock.openig.heap.GenericHeaplet
-
- org.forgerock.openig.thread.ScheduledExecutorServiceHeaplet
-
- All Implemented Interfaces:
Heaplet
public class ScheduledExecutorServiceHeaplet extends GenericHeaplet
Heaplet for building ScheduledExecutorService instances.Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
Reference:
Usage:{ "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'] } }{ "type": "ScheduledExecutorService", "config": { "corePoolSize": 42 // defaults to 1 (will grow as needed), only positive and non-zero } }This class supports graceful stop.
gracefulStopis a setting that allows a thread pool to wind down nicely before killing aggressively running (and submitted) jobs.{ "gracefulStop": false // defaults to true }gracefulPeriodattribute defines how long the heaplet should wait for jobs to actually terminate properly.Note that this setting is only considered when
gracefulStopis 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
contextorrequestobjects that are not available at init time).
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorServiceHeaplet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExecutorServicecreate()Called to request the heaplet create an object.voiddestroy()Called to indicate that the object created by the heaplet is going to be dereferenced.-
Methods inherited from class org.forgerock.openig.heap.GenericHeaplet
create, endpointRegistry, evaluatedWithHeapProperties, expression, getConfig, getHeap, getSecretService, getType, meterRegistryHolder, start
-
-
-
-
Method Detail
-
create
public ExecutorService create() throws HeapException
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 interface:HeapletCalled 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:
destroyin interfaceHeaplet- Overrides:
destroyin classGenericHeaplet
-
-