javax.management.monitor
Class GaugeMonitor

java.lang.Object
  |
  +--javax.management.NotificationBroadcasterSupport
        |
        +--javax.management.monitor.Monitor
              |
              +--javax.management.monitor.GaugeMonitor

public class GaugeMonitor
extends Monitor
implements GaugeMonitorMBean

Defines a monitor MBean designed to observe the values of a gauge attribute.

A gauge monitor observes an attribute that is continuously variable with time. A gauge monitor sends notifications as follows:

This provides a hysteresis mechanism to avoid repeated triggering of notifications when the attribute value makes small oscillations around the high or low threshold value.

If the gauge difference mode is used, the value of the derived gauge is calculated as the difference between the observed gauge values for two successive observations.
The derived gauge value (V[t]) is calculated using the following method:

This implementation of the gauge monitor requires the observed attribute to be of the type integer or floating-point (Byte, Integer, Short, Long, Float, Double).


Inner Class Summary
(package private)  class GaugeMonitor.GaugeMonitorThread
           
 
Fields inherited from class javax.management.monitor.Monitor
alreadyNotified, alreadyNotifieds, capacityIncrement, dbgTag, derivedGaugeTimeStamp, elementCount, isActive, logger, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED, OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, OBSERVED_OBJECT_ERROR_NOTIFIED, RESET_FLAGS_ALREADY_NOTIFIED, RUNTIME_ERROR_NOTIFIED, sequenceNumber, server
 
Fields inherited from class javax.management.NotificationBroadcasterSupport
li
 
Constructor Summary
GaugeMonitor()
          Default Constructor.
 
Method Summary
 java.lang.Number getDerivedGauge()
          Deprecated. Replaced by getDerivedGauge(ObjectName)
 java.lang.Number getDerivedGauge(ObjectName object)
          This method gets the derived gauge of the specified object, if this object is contained in the set of observed MBeans, or null otherwise.
 long getDerivedGaugeTimeStamp()
          Deprecated. Replaced by getDerivedGaugeTimeStamp(ObjectName)
 long getDerivedGaugeTimeStamp(ObjectName object)
          This method gets the derived gauge timestamp of the specified object, if this object is contained in the set of observed MBeans, or null otherwise.
 boolean getDifferenceMode()
          This method gets the value of the difference mode common to all observed MBeans.
 java.lang.Number getHighThreshold()
          This method gets the value of high threshold common to all observed MBeans.
 java.lang.Number getLowThreshold()
          This method gets the value of low threshold common to all observed MBeans.
 MBeanNotificationInfo[] getNotificationInfo()
          This method returns a NotificationInfo object containing the name of the Java class of the notification and the notification types sent by the counter monitor.
 boolean getNotifyHigh()
          This method gets the high notification's on/off switch value common to all observed MBeans.
 boolean getNotifyLow()
          This method gets the low notification's on/off switch value common to all observed MBeans.
(package private)  void insertSpecificElementAt(int index)
          This method is called when adding a new observed object in the list.
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Overriding the preRegister() of MBeanRegistration interface to store the ObjectName locally.
(package private)  void removeSpecificElementAt(int index)
          This method is called when removing an observed object from the list.
 void setDifferenceMode(boolean value)
          This method sets the state of difference mode common to all observed MBeans.
 void setNotifyHigh(boolean value)
          This method sets the high notification's on/off switch value common to all observed MBeans.
 void setNotifyLow(boolean value)
          This method sets the low notification's on/off switch value common to all observed MBeans.
 void setThresholds(java.lang.Number highValue, java.lang.Number lowValue)
          This method sets the high threshold and low threshold values.
 void start()
          Starts the Gauge monitor.
 void stop()
          Stops the Gauge Monitor.
 
Methods inherited from class javax.management.monitor.Monitor
addObservedObject, containsObservedObject, getGranularityPeriod, getObservedAttribute, getObservedObject, getObservedObject, getObservedObjects, indexOf, insertElementAt, isActive, isFlagsReset, postDeregister, postRegister, preDeregister, removeElementAt, removeObservedObject, resetAllAlreadyNotifiedFlags, resetAlreadyNotifiedFlag, sendNotification, setAlreadyNotifiedFlag, setGranularityPeriod, setObservedAttribute, setObservedObject, updateDeprecatedAlreadyNotifiedFlag
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GaugeMonitor

public GaugeMonitor()
Default Constructor.
Method Detail

getDerivedGauge

public java.lang.Number getDerivedGauge()
Deprecated. Replaced by getDerivedGauge(ObjectName)

This method gets the value of the derived gauge of the first object in the set of observed MBeans. The derived gauge is either the exact value of the observed attribute, or the difference between the two consecutive observed values of the attribute.
Specified by:
getDerivedGauge in interface GaugeMonitorMBean
Returns:
An instance of java.lang.Number giving the value of the derived gauge.

getDerivedGauge

public java.lang.Number getDerivedGauge(ObjectName object)
This method gets the derived gauge of the specified object, if this object is contained in the set of observed MBeans, or null otherwise.
Specified by:
getDerivedGauge in interface GaugeMonitorMBean
Parameters:
object - the name of the MBean.
Returns:
The derived gauge of the specified object.

getDerivedGaugeTimeStamp

public long getDerivedGaugeTimeStamp()
Deprecated. Replaced by getDerivedGaugeTimeStamp(ObjectName)

This method gets the value of the derived gauge time stamp of the first object in the set of observed MBeans. The derived gauge time stamp is the value(in the nearest miliseconds) when the notification was triggered.
Specified by:
getDerivedGaugeTimeStamp in interface GaugeMonitorMBean
Returns:
long value representing the time the notification was triggered.

getDerivedGaugeTimeStamp

public long getDerivedGaugeTimeStamp(ObjectName object)
This method gets the derived gauge timestamp of the specified object, if this object is contained in the set of observed MBeans, or null otherwise.
Specified by:
getDerivedGaugeTimeStamp in interface GaugeMonitorMBean
Parameters:
object - the name of the MBean.
Returns:
The derived gauge timestamp of the specified object.

getDifferenceMode

public boolean getDifferenceMode()
This method gets the value of the difference mode common to all observed MBeans. If the difference mode is true, the difference mode option is set to calculate the value of the derived gauge.
Specified by:
getDifferenceMode in interface GaugeMonitorMBean
Returns:
boolean value indicating whether the difference mode option is set.
See Also:
setDifferenceMode(boolean)

setDifferenceMode

public void setDifferenceMode(boolean value)
This method sets the state of difference mode common to all observed MBeans.
Specified by:
setDifferenceMode in interface GaugeMonitorMBean
Parameters:
value - boolean value representing the state of the difference mode.
See Also:
getDifferenceMode()

getHighThreshold

public java.lang.Number getHighThreshold()
This method gets the value of high threshold common to all observed MBeans.
Specified by:
getHighThreshold in interface GaugeMonitorMBean
Returns:
An instance of java.lang.Number giving the value of the high threshold.

getLowThreshold

public java.lang.Number getLowThreshold()
This method gets the value of low threshold common to all observed MBeans.
Specified by:
getLowThreshold in interface GaugeMonitorMBean
Returns:
An instance of java.lang.Number giving the value of the low threshold.

setThresholds

public void setThresholds(java.lang.Number highValue,
                          java.lang.Number lowValue)
                   throws java.lang.IllegalArgumentException
This method sets the high threshold and low threshold values.
Specified by:
setThresholds in interface GaugeMonitorMBean
Parameters:
highValue - - The high threshold value.
lowValue - - The low threshold value.
Throws:
java.lang.IllegalArgumentException - - The specified high/low threshold is null or the low threshold is greater than the high threshold or the high threshold and the low threshold are not of the same type.

getNotifyHigh

public boolean getNotifyHigh()
This method gets the high notification's on/off switch value common to all observed MBeans.
Specified by:
getNotifyHigh in interface GaugeMonitorMBean
Returns:
true if the gauge monitor notifies when exceeding the high threshold, false otherwise.
See Also:
setNotifyHigh(boolean)

setNotifyHigh

public void setNotifyHigh(boolean value)
This method sets the high notification's on/off switch value common to all observed MBeans.
Specified by:
setNotifyHigh in interface GaugeMonitorMBean
Parameters:
value - - The high notification's on/off switch value.
See Also:
getNotifyHigh()

getNotifyLow

public boolean getNotifyLow()
This method gets the low notification's on/off switch value common to all observed MBeans.
Specified by:
getNotifyLow in interface GaugeMonitorMBean
Returns:
true if the gauge monitor notifies when exceeding the low threshold, false otherwise.
See Also:
setNotifyLow(boolean)

setNotifyLow

public void setNotifyLow(boolean value)
This method sets the low notification's on/off switch value common to all observed MBeans.
Specified by:
setNotifyLow in interface GaugeMonitorMBean
Parameters:
value - - The low notification's on/off switch value.
See Also:
getNotifyLow()

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws java.lang.Exception
Overriding the preRegister() of MBeanRegistration interface to store the ObjectName locally.
Overrides:
preRegister in class Monitor
Tags copied from class: Monitor
Parameters:
server - - The MBean server in which the monitor MBean will be registered.
name - - The object name of the monitor MBean.
Returns:
The name of the monitor MBean registered.
Throws:
- - java.lang.Exception.

start

public void start()
Starts the Gauge monitor.
Overrides:
start in class Monitor

stop

public void stop()
Stops the Gauge Monitor.
Overrides:
stop in class Monitor

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
This method returns a NotificationInfo object containing the name of the Java class of the notification and the notification types sent by the counter monitor.
Overrides:
getNotificationInfo in class Monitor
Returns:
An Array of MBeanNotificationInfo objects.

insertSpecificElementAt

void insertSpecificElementAt(int index)
This method is called when adding a new observed object in the list. It updates all the gauge specific arrays.
Overrides:
insertSpecificElementAt in class Monitor
Parameters:
index - The index of the observed object.

removeSpecificElementAt

void removeSpecificElementAt(int index)
This method is called when removing an observed object from the list. It updates all the gauge specific arrays.
Overrides:
removeSpecificElementAt in class Monitor
Parameters:
index - The index of the observed object.