Top Description Methods
org.osgi.service.resourcemonitoring

public Interface ResourceMonitor<T>

Known Direct Subinterfaces
org.osgi.service.resourcemonitoring.monitor.CPUMonitor, org.osgi.service.resourcemonitoring.monitor.DiskStorageMonitor, org.osgi.service.resourcemonitoring.monitor.MemoryMonitor, org.osgi.service.resourcemonitoring.monitor.SocketMonitor, org.osgi.service.resourcemonitoring.monitor.ThreadMonitor
Type Parameters
<T>
The type for the Resource.

Representation of the state of a resource for a resource context.

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.

Author
$Id: a14e7778bc89b62e0054d0d8ea801452a7270389 $
Version
1.0

Method Summary

Modifier and TypeMethod and Description
public void
delete()

Disable and delete this instance of Resource Monitor.

public void
disable()

Disable the monitoring of this resource type for the resource context associated with this monitor instance.

public void
enable()

Enable the monitoring of this resource type for the resource context associated with this monitor instance.

public boolean

Returns:

true if the current instance is equals to the provided resourceMonitor
equals
(Object resourceMonitor)

Checks if resourceMonitor is equals to the current instance.

public ResourceContext

Returns:

The associated ResourceContext
getContext
()

Returns the resource context that this monitor belongs to

public long

Returns:

The monitored period in milliseconds, or -1 if a monitored period is not relevant for this resource type.
getMonitoredPeriod
()

Returns the time period for which the usage of this resource type is monitored.

public String

Returns:

The name of the monitored resource type
getResourceType
()

The name of the resource type that this monitor represents

public long

Returns:

The sampling period in milliseconds, or -1 if a sampling period is not relevant for this resource type.
getSamplingPeriod
()

Returns the sampling period for this resource type.

public Comparable<T>

Returns:

The current usage of this resource type.
getUsage
()

Returns an object representing the current usage of this resource type by this resource context.

public int

Returns:

hashcode
hashCode
()

Retrieves the hashCode value of this ResourceMonitor.

public boolean

Returns:

true if deleted.
isDeleted
()

Returns true if the ResourceMonitor instance has been deleted, that is the delete() method has been called previously.

public boolean

Returns:

true if monitoring for this resource type is enabled for this context, false otherwise
isEnabled
()

Checks if the monitoring for this resource type is enabled for this resource context

Method Detail

deleteback to summary
public void delete() throws ResourceMonitorException

Disable and delete this instance of Resource Monitor. This method MUST update the list of ResourceMonitor instances hold by the Resource Context (getContext().removeMonitor(this)).

Exceptions
ResourceMonitorException:
For example, when the monitor can't be removed from the ResourceContext.
disableback to summary
public void disable() throws ResourceMonitorException

Disable the monitoring of this resource type for the resource context associated with this monitor instance. The resource usage is not available until it is enabled again.

Exceptions
ResourceMonitorException:
if the ResourceMonitor instance has been previously deleted
enableback to summary
public void enable() throws ResourceMonitorException

Enable the monitoring of this resource type for the resource context associated with this monitor instance. This method SHOULD also update the current resource consumption value (to take into account all previous resource allocations and releases occurred during the time the monitor was disabled).

Exceptions
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 deleted
equalsback to summary
public boolean equals(Object resourceMonitor)

Checks if resourceMonitor is equals to the current instance. A ResourceMonitor rm1 is equals to a ResourceMonitor rm2 if rm1.getContext().equals(rm2.getContext()) and r1.getType().equals(rm2.getType()).

Returns:boolean

true if the current instance is equals to the provided resourceMonitor

Annotations
@Override
getContextback to summary
public ResourceContext getContext()

Returns the resource context that this monitor belongs to

Returns:ResourceContext

The associated ResourceContext

getMonitoredPeriodback to summary
public long getMonitoredPeriod()

Returns the time period for which the usage of this resource type is monitored.

Returns:long

The monitored period in milliseconds, or -1 if a monitored period is not relevant for this resource type.

getResourceTypeback to summary
public String getResourceType()

The name of the resource type that this monitor represents

Returns:String

The name of the monitored resource type

getSamplingPeriodback to summary
public long getSamplingPeriod()

Returns the sampling period for this resource type.

Returns:long

The sampling period in milliseconds, or -1 if a sampling period is not relevant for this resource type.

getUsageback to summary
public Comparable<T> getUsage() throws ResourceMonitorException

Returns an object representing the current usage of this resource type by this resource context.

Returns:Comparable<T>

The current usage of this resource type.

Exceptions
ResourceMonitorException:
if the ResourceMonitor instance is not enabled.
hashCodeback to summary
public int hashCode()

Retrieves the hashCode value of this ResourceMonitor. The hashCode value is based on the hashCode value of the associated ResourceContext and the hashCode value of the type.

Returns:int

hashcode

Annotations
@Override
isDeletedback to summary
public boolean isDeleted()

Returns true if the ResourceMonitor instance has been deleted, that is the delete() method has been called previously.

Returns:boolean

true if deleted.

isEnabledback to summary
public boolean isEnabled()

Checks if the monitoring for this resource type is enabled for this resource context

Returns:boolean

true if monitoring for this resource type is enabled for this context, false otherwise