public interface ResourceListener
A ResourceListener is an OSGi service which is notified when a Resource Context violates one of the threshold defined by the listener.
Every ResourceListener is associated to a specific Resource Context and a specific Resource type. It defines two types of thresholds: a lower and a upper. A lower threshold is reached when the resource usage decreases below the threshold. On the contrary, an upper threshold is reached when the resource usage exceeds the threshold.
Both lower or upper threshold are two levels: a warning level and error level. The warning level indicates the resource usage becomes to be critical but are still acceptable. The error level indicates the resource usage is now critical for the overall system and actions should be taken.
A Resource Listener is registered with these two mandatory properties:
RESOURCE_CONTEXT
which defines the ResourceContext associated to
this ListenerRESOURCE_TYPE
which the type of resource
Resource Listeners are associated to a Resource Context and a Resource
Monitor based on the RESOURCE_CONTEXT
property and the
RESOURCE_TYPE
property (both of them are mandatory at registration
time).
Once associated, the ResourceMonitor gets the threshold values through the
service properties (i.e UPPER_WARNING_THRESHOLD
,
UPPER_ERROR_THRESHOLD
, LOWER_WARNING_THRESHOLD
and
LOWER_WARNING_THRESHOLD
) and store them. Once it detects a new
resource consumption, it compares the new resource usage value with the
thresholds provided by the Resource Listener. If the resource usage violates
one of these thresholds, the Resource Monitor notifies the
ResourceListener
through a call to notify(ResourceEvent)
.
A ResourceMonitor tracks threshold value modification by using a
ServiceListener
.
Modifier and Type | Field and Description |
---|---|
static String |
LOWER_ERROR_THRESHOLD
Optional property defining the value of the lower error threshold.
|
static String |
LOWER_WARNING_THRESHOLD
Optional property defining the value of the lower warning threshold.
|
static String |
RESOURCE_CONTEXT
Mandatory property specifying the Resource Context associated with the
listener.
|
static String |
RESOURCE_TYPE
Mandatory property defining the type of Resource (i.e the
ResourceMonitor) associated to this Listener.
|
static String |
UPPER_ERROR_THRESHOLD
Optional property defining the value of the upper error threshold.
|
static String |
UPPER_WARNING_THRESHOLD
Optional property defining the value of the upper warning threshold.
|
Modifier and Type | Method and Description |
---|---|
Comparable |
getLowerErrorThreshold()
Retrieves the lower error threshold value set by the listener.
|
Comparable |
getLowerWarningThreshold()
Retrieves the lower warning threshold value set by the listener.
|
Comparable |
getUpperErrorThreshold()
Retrieves the upper error threshold value set by this listener.
|
Comparable |
getUpperWarningThreshold()
Retrieves the upper warning threshold value set by this listener.
|
void |
notify(ResourceEvent event)
Receives a resource monitoring notification
|
static final String RESOURCE_CONTEXT
static final String RESOURCE_TYPE
static final String UPPER_WARNING_THRESHOLD
static final String UPPER_ERROR_THRESHOLD
static final String LOWER_WARNING_THRESHOLD
static final String LOWER_ERROR_THRESHOLD
void notify(ResourceEvent event)
event
- The ResourceEvent
objectComparable getLowerWarningThreshold()
notify(ResourceEvent)
will be called. The provided ResourceEvent
then indicates the WARNING state is reached.Comparable getLowerErrorThreshold()
notify(ResourceEvent)
will be called. The provided
ResourceEvent
then indicates the ERROR state is reached.Comparable getUpperWarningThreshold()
notify(ResourceEvent)
method will be called. The provided ResourceEvent
then indicates
the WARNING state is reached.Comparable getUpperErrorThreshold()
notify(ResourceEvent)
will be called. The provided ResourceEvent
then indicates the
ERROR state is reached.Copyright © OSGi Alliance (2000, 2015). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0