public class ResourceMonitoringServiceImpl extends Object implements ResourceMonitoringService, FeatureStateListener
Modifier and Type | Class and Description |
---|---|
static class |
ResourceMonitoringServiceImpl.MonitoringTask
This class represents the monitoring task ran at regular interval.
|
Constructor and Description |
---|
ResourceMonitoringServiceImpl(Timer timer,
long intervalMillis,
boolean runGcBeforeCollecting)
Instantiates the resource monitoring service.
|
Modifier and Type | Method and Description |
---|---|
long |
getFreeMemory()
Returns the free memory.
|
long |
getMaxMemory()
Returns the max memory.
|
long |
getTotalMemory()
Returns the total memory.
|
PackedMap<String,Float> |
getUsedCpuPercentPerModule()
Retrieves the CPU usage for each module from the previous monitoring cycle, expressed as a percentage.
|
PackedMap<String,Float> |
getUsedMemoryPercentPerModule()
Retrieves the RAM usage values expressed as a percentage (a value between 0 and 1.0).
|
PackedMap<String,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(Feature app,
Feature.State state)
Called when the state of a Feature has changed.
|
void |
stop()
Stops resource monitoring by disabling monitoring on each module.
|
public ResourceMonitoringServiceImpl(Timer timer, long intervalMillis, boolean runGcBeforeCollecting)
timer
- the timer.intervalMillis
- the timer interval read from the kernel properties.runGcBeforeCollecting
- the boolean read from kernel properties to run GC before collecting monitoring data.public long getFreeMemory()
ResourceMonitoringService
getFreeMemory
in interface ResourceMonitoringService
public long getMaxMemory()
ResourceMonitoringService
getMaxMemory
in interface ResourceMonitoringService
public long getTotalMemory()
ResourceMonitoringService
getTotalMemory
in interface ResourceMonitoringService
public PackedMap<String,Float> getUsedCpuPercentPerModule()
ResourceMonitoringService
getUsedCpuPercentPerModule
in interface ResourceMonitoringService
public PackedMap<String,Float> getUsedMemoryPercentPerModule()
ResourceMonitoringService
The percentage indicates the ratio between a module's current heap consumption and the total heap.
getUsedMemoryPercentPerModule
in interface ResourceMonitoringService
public PackedMap<String,Long> getUsedMemoryPerModule()
ResourceMonitoringService
getUsedMemoryPerModule
in interface ResourceMonitoringService
public void start()
public void stateChanged(Feature app, @Nullable Feature.State state)
FeatureStateListener
stateChanged
in interface FeatureStateListener
app
- the Feature which state has changedstate
- the previous state, null
if Feature state is Feature.State.INSTALLED
public void stop()