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()
ResourceMonitoringServicegetFreeMemory in interface ResourceMonitoringServicepublic long getMaxMemory()
ResourceMonitoringServicegetMaxMemory in interface ResourceMonitoringServicepublic long getTotalMemory()
ResourceMonitoringServicegetTotalMemory in interface ResourceMonitoringServicepublic PackedMap<String,Float> getUsedCpuPercentPerModule()
ResourceMonitoringServicegetUsedCpuPercentPerModule in interface ResourceMonitoringServicepublic PackedMap<String,Float> getUsedMemoryPercentPerModule()
ResourceMonitoringServiceThe percentage indicates the ratio between a module's current heap consumption and the total heap.
getUsedMemoryPercentPerModule in interface ResourceMonitoringServicepublic PackedMap<String,Long> getUsedMemoryPerModule()
ResourceMonitoringServicegetUsedMemoryPerModule in interface ResourceMonitoringServicepublic void start()
public void stateChanged(Feature app, @Nullable Feature.State state)
FeatureStateListenerstateChanged in interface FeatureStateListenerapp - the Feature which state has changedstate - the previous state, null if Feature state is Feature.State.INSTALLEDpublic void stop()