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 Details

    • DaemonManagerImpl

      @Inject public DaemonManagerImpl(AnalyticsManager analyticsManager, Optional<Integer> threadPoolSizeOpt, Optional<Integer> daemonMinDurationInSecondsOpt, Optional<Integer> daemonMaxDurationInSecondsOpt)
      Construct an instance of DaemonManagerImpl.
      Parameters:
      analyticsManager - AnalyticsManager
      threadPoolSizeOpt - 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

      public List<? extends Definition> provideDefinitions(DefinitionSpace definitionSpace)
      Description copied from interface: SimpleDefinitionProvider
      Provide definitions to be registered in the definitionSpace
      Specified by:
      provideDefinitions in interface SimpleDefinitionProvider
      Parameters:
      definitionSpace - the actual definitionSpace
      Returns:
      the list of new definition to register
    • getStats

      public List<DaemonStat> 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:
      getStats in interface DaemonManager
      Returns:
      a list of DaemonStat objects representing the execution statistics of managed daemons.
    • getDaemonPoolMetrics

      public List<Metric> 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:
      start in interface Activeable
    • 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:
      stop in interface Activeable
    • checkDaemonsAlive

      public HealthMeasure 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

      public HealthMeasure 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

      public HealthMeasure checkDaemonsExecs()
      Checks the daemons in failure (from a failure until two consecutive successes) : YELLOW, never RED.
      Returns:
      the health measure