Java Reference
In-Depth Information
Table 12.5 The important methods of the CounterMonitor class and their purpose. For each set-
ter method, there is a corresponding getter method.
Method
Purpose
Tells the monitor which method to use (see previous descrip-
tion) to compute its derived gauge
setDifferenceMode( boolean )
Sets the observed counter's maximum value
setModulus( Number )
Tells the MBean whether to send notifications
setNotify( boolean )
Sets the offset value of the monitor
setOffset( Number )
Sets the threshold value of the monitor for comparison to the
observed counter
setThreshold( Number )
The final aspect of the Counter monitor to discuss is its notification types.
CounterMonitor notifications
The CounterMonitor class shares a common notification type with the GaugeMoni-
tor : the type jmx.monitor.error.threshold . This type indicates that the moni-
tor's threshold, offset, or modulus is not the same type as the observed counter
attribute value.
In addition to the common notification types, the CounterMonitor class adds
the notification type jmx.monitor.counter.threshold . This notification type
indicates that the observed counter attribute has reached or exceeded the moni-
tor's threshold value.
12.2 Monitor examples
We have discussed each monitor MBean's behavior and important methods and
examined the StringMonitor , GaugeMonitor , and CounterMonitor classes. Now it
is time to work through some examples.
To test these monitors, you need to create a subject MBean to monitor. You
will use the JMXBookAgent class as your agent to contain your monitors and the
subject MBean. Your monitoring subject MBean will be called ObservableObject ;
it implements the interface ObservableObjectMBean . The following section cre-
ates the MBean and the agent.
You will also create a simple startup program—the MonitoringSetup class—
that uses the RMI connector to create three monitors and to act as a notification
listener for each. In addition, the MonitoringSetup class will add the Observable-
Object to the agent. After you create all the MBeans, you will use the HTML
Search WWH ::




Custom Search