Package io.vertigo.core.impl.daemon
Class DaemonManagerImpl
java.lang.Object
io.vertigo.core.impl.daemon.DaemonManagerImpl
- All Implemented Interfaces:
DaemonManager,Activeable,Component,CoreComponent,Manager,DefinitionProvider,SimpleDefinitionProvider
public final class DaemonManagerImpl
extends Object
implements DaemonManager, Activeable, SimpleDefinitionProvider
Manager of all the daemons.
- Author:
- mlaroche, pchretien, npiedeloup
-
Constructor Summary
ConstructorsConstructorDescriptionDaemonManagerImpl(AnalyticsManager analyticsManager, Optional<Integer> threadPoolSizeOpt, Optional<Integer> daemonMinDurationInSecondsOpt, Optional<Integer> daemonMaxDurationInSecondsOpt) Construct an instance of DaemonManagerImpl. -
Method Summary
Modifier and TypeMethodDescriptionChecks the pace of the daemon engine : YELLOW if a daemon has been waiting for a free thread for more than its limit, RED if it has been waiting for more than twice the max duration, or if the pool is shut down while the manager is active.Checks the state of each daemon : RED if a daemon is dead (its schedule was cancelled by a fatal Error), YELLOW if a daemon has been running for more than its limit.Checks the daemons in failure (from a failure until two consecutive successes) : YELLOW, never RED.Gets the metrics of the daemon pool : its size, and the executions over a window since the previous call (the reader resets the window).getStats()Provides a snapshot or copy of the execution statistics for all managed daemons.List<? extends Definition> provideDefinitions(DefinitionSpace definitionSpace) Provide definitions to be registered in the definitionSpacevoidstart()Initializes and activates the component.voidstop()Deactivates and prepares the component for destruction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.vertigo.core.node.definition.DefinitionProvider
addDefinitionResourceConfigMethods inherited from interface io.vertigo.core.node.definition.SimpleDefinitionProvider
get
-
Constructor Details
-
DaemonManagerImpl
@Inject public DaemonManagerImpl(AnalyticsManager analyticsManager, Optional<Integer> threadPoolSizeOpt, Optional<Integer> daemonMinDurationInSecondsOpt, Optional<Integer> daemonMaxDurationInSecondsOpt) Construct an instance of DaemonManagerImpl.- Parameters:
analyticsManager- AnalyticsManagerthreadPoolSizeOpt- thread pool size (default 2)daemonMinDurationInSecondsOpt- minimum duration before judging that a daemon has a problem, in seconds (default 120)daemonMaxDurationInSecondsOpt- maximum duration a daemon may run, in seconds (default 7200)
-
-
Method Details
-
provideDefinitions
Description copied from interface:SimpleDefinitionProviderProvide definitions to be registered in the definitionSpace- Specified by:
provideDefinitionsin interfaceSimpleDefinitionProvider- Parameters:
definitionSpace- the actual definitionSpace- Returns:
- the list of new definition to register
-
getStats
Provides a snapshot or copy of the execution statistics for all managed daemons. The returned list of DaemonStat objects contains information about the current execution statistics of each daemon managed by this DaemonManager.- Specified by:
getStatsin interfaceDaemonManager- Returns:
- a list of DaemonStat objects representing the execution statistics of managed daemons.
-
getDaemonPoolMetrics
Gets the metrics of the daemon pool : its size, and the executions over a window since the previous call (the reader resets the window). Counts are sums, durations are averages in millis (omitted when no execution in the window). Called hourly by the analytics daemon : any other caller of AnalyticsManager.getMetrics() consumes the window.- Returns:
- the daemon pool metrics
-
start
public void start()Initializes and activates the component. This method is called after the component has been created and fully initialized, typically after dependency injection for components built via configuration. Implementations should perform any necessary setup or resource allocation to prepare the component for use.- Specified by:
startin interfaceActiveable
-
stop
public void stop()Deactivates and prepares the component for destruction. This method is called before the component is stopped or destroyed. Implementations should release resources, terminate processes, or perform cleanup to ensure a graceful shutdown.- Specified by:
stopin interfaceActiveable
-
checkDaemonsAlive
Checks the state of each daemon : RED if a daemon is dead (its schedule was cancelled by a fatal Error), YELLOW if a daemon has been running for more than its limit.- Returns:
- the health measure
-
checkDaemonPoolUtilization
Checks the pace of the daemon engine : YELLOW if a daemon has been waiting for a free thread for more than its limit, RED if it has been waiting for more than twice the max duration, or if the pool is shut down while the manager is active.- Returns:
- the health measure
-
checkDaemonsExecs
Checks the daemons in failure (from a failure until two consecutive successes) : YELLOW, never RED.- Returns:
- the health measure
-