javax.management.monitor
Class CounterMonitor

java.lang.Object
  |
  +--javax.management.NotificationBroadcasterSupport
        |
        +--javax.management.monitor.Monitor
              |
              +--javax.management.monitor.CounterMonitor
All Implemented Interfaces:
CounterMonitorMBean, MBeanRegistration, MonitorMBean, NotificationBroadcaster, NotificationEmitter

public class CounterMonitor
extends Monitor
implements CounterMonitorMBean

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

A counter monitor sends a threshold notification when the value of the counter reaches or exceeds a threshold known as the comparison level. The notify flag must be set to true.
In addition, an offset mechanism enables particular counting intervals to be detected.

If the offset value is not zero, whenever the threshold is triggered by the counter value reaching a comparison level, that comparison level is incremented by the offset value. This is regarded as taking place instantaneously, that is before the count is incremented. Thus, for each level, the threshold triggers an event notification every time the count increases by an interval equal to the offset value.

If the counter can wrap around its maximum value, the modulus needs to be specified. The modulus is the value at which the counter is reset to zero.

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

This implementation of the counter monitor requires the observed attribute to be of the type integer (Byte, Integer, Short, Long).

Author:
Young Yang

Fields inherited from class javax.management.monitor.Monitor
observedObjects
 
Constructor Summary
CounterMonitor()
           
 
Method Summary
 void addObservedObject(ObjectName objectName)
          Adds the specified object in the set of observed MBeans.
protected  void doMonitor(ObjectName observedObject, java.lang.Object value)
           
 java.lang.Number getDerivedGauge(ObjectName observedObjectName)
          Gets the derived gauge for the specified MBean.
 long getDerivedGaugeTimeStamp(ObjectName observedObjectName)
          Gets the derived gauge timestamp for the specified MBean.
 boolean getDifferenceMode()
          Gets the difference mode flag value.
 java.lang.Number getInitThreshold()
          Gets the initial threshold value common to all observed objects.
 java.lang.Number getModulus()
          Gets the modulus value.
 MBeanNotificationInfo[] getNotificationInfo()
          Returns a NotificationInfo object contaning the name of the Java class of the notification and the notification types sent.
 boolean getNotify()
          Gets the notification's on/off switch value.
 java.lang.Number getOffset()
          Gets the offset value.
 java.lang.Number getThreshold(ObjectName observedObjectName)
          Gets the threshold value for the specified MBean.
 void setDifferenceMode(boolean value)
          Sets the difference mode flag value.
 void setInitThreshold(java.lang.Number value)
          Sets the initial threshold value common to all observed MBeans.
 void setModulus(java.lang.Number value)
          Sets the modulus value.
 void setNotify(boolean value)
          Sets the notification's on/off switch value.
 void setOffset(java.lang.Number value)
          Sets the offset value.
 void start()
           
 void stop()
           
 
Methods inherited from class javax.management.monitor.Monitor
_start, _stop, containsObservedObject, getGranularityPeriod, getMonitorData, getObservedAttribute, getObservedObjects, isActive, postDeregister, postRegister, preDeregister, preRegister, removeObservedObject, sendNotification, setGranularityPeriod, setObservedAttribute
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.management.monitor.MonitorMBean
containsObservedObject, getGranularityPeriod, getObservedAttribute, getObservedObjects, isActive, removeObservedObject, setGranularityPeriod, setObservedAttribute
 

Constructor Detail

CounterMonitor

public CounterMonitor()
Method Detail

start

public void start()
Overrides:
start in class Monitor

stop

public void stop()
Overrides:
stop in class Monitor

getDerivedGauge

public java.lang.Number getDerivedGauge(ObjectName observedObjectName)
Description copied from interface: CounterMonitorMBean
Gets the derived gauge for the specified MBean.
Specified by:
getDerivedGauge in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
object - the MBean for which the derived gauge is to be returned
Returns:
The derived gauge for the specified MBean if this MBean is in the set of observed MBeans, or null otherwise.

getDerivedGaugeTimeStamp

public long getDerivedGaugeTimeStamp(ObjectName observedObjectName)
Description copied from interface: CounterMonitorMBean
Gets the derived gauge timestamp for the specified MBean.
Specified by:
getDerivedGaugeTimeStamp in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
object - the MBean for which the derived gauge timestamp is to be returned
Returns:
The derived gauge timestamp for the specified MBean if this MBean is in the set of observed MBeans, or null otherwise.

getThreshold

public java.lang.Number getThreshold(ObjectName observedObjectName)
Description copied from interface: CounterMonitorMBean
Gets the threshold value for the specified MBean.
Specified by:
getThreshold in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
object - the MBean for which the threashold value is to be returned
Returns:
The threshold value for the specified MBean if this MBean is in the set of observed MBeans, or null otherwise.

getInitThreshold

public java.lang.Number getInitThreshold()
Description copied from interface: CounterMonitorMBean
Gets the initial threshold value common to all observed objects.
Specified by:
getInitThreshold in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Returns:
The initial threshold value.
See Also:
CounterMonitorMBean.setInitThreshold(java.lang.Number)

setInitThreshold

public void setInitThreshold(java.lang.Number value)
                      throws java.lang.IllegalArgumentException
Description copied from interface: CounterMonitorMBean
Sets the initial threshold value common to all observed MBeans.
Specified by:
setInitThreshold in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
value - The initial threshold value.
Throws:
java.lang.IllegalArgumentException - The specified threshold is null or the threshold value is less than zero.
See Also:
CounterMonitorMBean.getInitThreshold()

getOffset

public java.lang.Number getOffset()
Description copied from interface: CounterMonitorMBean
Gets the offset value.
Specified by:
getOffset in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Returns:
The offset value.
See Also:
CounterMonitorMBean.setOffset(Number)

setOffset

public void setOffset(java.lang.Number value)
               throws java.lang.IllegalArgumentException
Description copied from interface: CounterMonitorMBean
Sets the offset value.
Specified by:
setOffset in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
value - The offset value.
Throws:
java.lang.IllegalArgumentException - The specified offset is null or the offset value is less than zero.
See Also:
CounterMonitorMBean.getOffset()

getModulus

public java.lang.Number getModulus()
Description copied from interface: CounterMonitorMBean
Gets the modulus value.
Specified by:
getModulus in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Returns:
The modulus value.
See Also:
CounterMonitorMBean.setModulus(java.lang.Number)

setModulus

public void setModulus(java.lang.Number value)
                throws java.lang.IllegalArgumentException
Description copied from interface: CounterMonitorMBean
Sets the modulus value.
Specified by:
setModulus in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
value - The modulus value.
Throws:
java.lang.IllegalArgumentException - The specified modulus is null or the modulus value is less than zero.
See Also:
CounterMonitorMBean.getModulus()

getNotify

public boolean getNotify()
Description copied from interface: CounterMonitorMBean
Gets the notification's on/off switch value.
Specified by:
getNotify in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Returns:
true if the counter monitor notifies when exceeding the threshold, false otherwise.
See Also:
CounterMonitorMBean.setNotify(boolean)

setNotify

public void setNotify(boolean value)
Description copied from interface: CounterMonitorMBean
Sets the notification's on/off switch value.
Specified by:
setNotify in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
value - The notification's on/off switch value.
See Also:
CounterMonitorMBean.getNotify()

getDifferenceMode

public boolean getDifferenceMode()
Description copied from interface: CounterMonitorMBean
Gets the difference mode flag value.
Specified by:
getDifferenceMode in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Returns:
true if the difference mode is used, false otherwise.
See Also:
CounterMonitorMBean.setDifferenceMode(boolean)

setDifferenceMode

public void setDifferenceMode(boolean value)
Description copied from interface: CounterMonitorMBean
Sets the difference mode flag value.
Specified by:
setDifferenceMode in interface CounterMonitorMBean
Following copied from interface: javax.management.monitor.CounterMonitorMBean
Parameters:
value - The difference mode flag value.
See Also:
CounterMonitorMBean.getDifferenceMode()

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Description copied from class: NotificationBroadcasterSupport
Returns a NotificationInfo object contaning the name of the Java class of the notification and the notification types sent.
Overrides:
getNotificationInfo in class NotificationBroadcasterSupport

doMonitor

protected void doMonitor(ObjectName observedObject,
                         java.lang.Object value)
Overrides:
doMonitor in class Monitor

addObservedObject

public void addObservedObject(ObjectName objectName)
                       throws java.lang.IllegalArgumentException
Description copied from interface: MonitorMBean
Adds the specified object in the set of observed MBeans.
Specified by:
addObservedObject in interface MonitorMBean
Overrides:
addObservedObject in class Monitor
Following copied from interface: javax.management.monitor.MonitorMBean
Parameters:
object - The object to observe.
Throws:
java.lang.IllegalArgumentException - the specified object is null.