T
- The type for the Resource.public interface ResourceMonitor<T>
ResourceMonitor objects are returned by the
ResourceContext.getMonitor(String)
method.
The ResourceMonitor
object may be used to:
A resource monitor can have a sampling period, a monitored period, or both. For example, for CPU monitoring, the resource monitor implementation can get the CPU usage of the running threads once per minute, and calculate the CPU usage per context in percentages based on the last ten such measurements. This could make a 60 000 milliseconds sampling period, and a 600 000 milliseconds monitored period.
Modifier and Type | Method and Description |
---|---|
void |
delete()
Disable and delete this instance of Resource Monitor.
|
void |
disable()
Disable the monitoring of this resource type for the resource context
associated with this monitor instance.
|
void |
enable()
Enable the monitoring of this resource type for the resource context
associated with this monitor instance.
|
boolean |
equals(Object resourceMonitor)
Checks if resourceMonitor is equals to the current instance.
|
ResourceContext |
getContext()
Returns the resource context that this monitor belongs to
|
long |
getMonitoredPeriod()
Returns the time period for which the usage of this resource type is
monitored.
|
String |
getResourceType()
The name of the resource type that this monitor represents
|
long |
getSamplingPeriod()
Returns the sampling period for this resource type.
|
Comparable<T> |
getUsage()
Returns an object representing the current usage of this resource type by
this resource context.
|
int |
hashCode()
Retrieves the hashCode value of this ResourceMonitor.
|
boolean |
isDeleted()
Returns true if the ResourceMonitor instance has been deleted, that is the
delete() method has been called previously. |
boolean |
isEnabled()
Checks if the monitoring for this resource type is enabled for this
resource context
|
ResourceContext getContext()
ResourceContext
String getResourceType()
void delete() throws ResourceMonitorException
ResourceMonitorException
- For example, when the monitor can't be
removed from the ResourceContext.boolean isEnabled()
true
if monitoring for this resource type is enabled
for this context, false
otherwiseboolean isDeleted()
delete()
method has been called previously.void enable() throws ResourceMonitorException
ResourceMonitorException
- if the ResourceMonitor instance can not
be enabled (for example, some MemoryMonitor implementations
evaluate the memory consumption by tracking memory allocation
operation at runtime. This kind of Monitor can not get
instantaneous memory value. Such Monitor instances need to be
enabled at starting time.). if the ResourceMonitor instance has
been previously deletedvoid disable() throws ResourceMonitorException
ResourceMonitorException
- if the ResourceMonitor instance has been
previously deletedComparable<T> getUsage() throws ResourceMonitorException
ResourceMonitorException
- if the ResourceMonitor instance is not
enabled.long getSamplingPeriod()
-1
if a
sampling period is not relevant for this resource type.long getMonitoredPeriod()
-1
if a
monitored period is not relevant for this resource type.boolean equals(Object resourceMonitor)
Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0