Class ResourceMonitoringServiceImpl

  • All Implemented Interfaces:
    ResourceMonitoringService, ej.kf.FeatureStateListener

    public class ResourceMonitoringServiceImpl
    extends java.lang.Object
    implements ResourceMonitoringService, ej.kf.FeatureStateListener
    This class represents the implementation for the ResourceMonitorService.
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceMonitoringServiceImpl​(ej.bon.Timer timer, long intervalMS, boolean runGcBeforeCollecting)
      Instantiates the resource monitoring service.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getFreeMemory()  
      long getMaxMemory()  
      long getTotalMemory()  
      ej.basictool.map.PackedMap<java.lang.String,​java.lang.Float> getUsedCpuPercentPerModule()
      Retrieves the CPU usage for each module from the previous monitoring cycle, expressed as a percentage.
      ej.basictool.map.PackedMap<java.lang.String,​java.lang.Float> getUsedMemoryPercentPerModule()
      Retrieves the RAM usage values expressed as a percentage (a value between 0 and 1.0).
      ej.basictool.map.PackedMap<java.lang.String,​java.lang.Long> getUsedMemoryPerModule()
      Retrieves the current RAM usage for each module.
      void start()
      Starts the resource monitoring task by enabling monitoring on each module.
      void stateChanged​(ej.kf.Feature app, ej.kf.Feature.State state)  
      void stop()
      Stops resource monitoring by disabling monitoring on each module.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceMonitoringServiceImpl

        public ResourceMonitoringServiceImpl​(ej.bon.Timer timer,
                                             long intervalMS,
                                             boolean runGcBeforeCollecting)
        Instantiates the resource monitoring service.
        Parameters:
        timer - the timer
        intervalMS - the timer interval read from the kernel properties
        runGcBeforeCollecting - the boolean read from kernel properties to run GC before collecting monitoring data
    • Method Detail

      • start

        public void start()
        Starts the resource monitoring task by enabling monitoring on each module.
      • stop

        public void stop()
        Stops resource monitoring by disabling monitoring on each module.
      • stateChanged

        public void stateChanged​(ej.kf.Feature app,
                                 @Nullable
                                 ej.kf.Feature.State state)
        Specified by:
        stateChanged in interface ej.kf.FeatureStateListener
      • getUsedCpuPercentPerModule

        public ej.basictool.map.PackedMap<java.lang.String,​java.lang.Float> getUsedCpuPercentPerModule()
        Description copied from interface: ResourceMonitoringService
        Retrieves the CPU usage for each module from the previous monitoring cycle, expressed as a percentage.
        Specified by:
        getUsedCpuPercentPerModule in interface ResourceMonitoringService
        Returns:
        A map where each entry contains a module name as the key and its CPU usage percentage (0.0 to 1.0) as the value.
      • getUsedMemoryPerModule

        public ej.basictool.map.PackedMap<java.lang.String,​java.lang.Long> getUsedMemoryPerModule()
        Description copied from interface: ResourceMonitoringService
        Retrieves the current RAM usage for each module.
        Specified by:
        getUsedMemoryPerModule in interface ResourceMonitoringService
        Returns:
        A map where each entry contains a module identifier as the key and its current RAM usage in bytes as the value.
      • getUsedMemoryPercentPerModule

        public ej.basictool.map.PackedMap<java.lang.String,​java.lang.Float> getUsedMemoryPercentPerModule()
        Description copied from interface: ResourceMonitoringService
        Retrieves the RAM usage values expressed as a percentage (a value between 0 and 1.0).

        The percentage indicates the ratio between a module's current heap consumption and the total heap.

        Specified by:
        getUsedMemoryPercentPerModule in interface ResourceMonitoringService
        Returns:
        A map where each entry contains the module name as the key and its current RAM usage percentage as the value.