The javax.management.monitor package provides a set of monitoring services that JMX-based management applications can use to monitor MBeans registered with the MBeanServer. Each of these services is packaged as an MBean. Management applications create and manipulate monitors via the MBeanServer just like they do other MBeans. 6.1.1 The Monitoring Package StructureThe monitoring package is composed of four interfaces and five classes. Figure 6.1 illustrates their interrelationships. Figure 6.1. Static Structure of the javax.management.monitor Package
The abstract Monitor class is the core of the package. It extends NotificationBroadcasterSupport so that its instances can send JMX notifications when they detect conditions of interest to management applications. Because each of its concrete subclasses will be MBeans, Monitor also implements the MonitorMBean interface, which captures the common aspects of a monitor's management interface. Finally, Monitor implements MBeanRegistration , which provides a means for the concrete Monitor subclass instances to get a reference to their MBeanServer. The javax.management.monitor package defines three concrete monitor types: StringMonitor , CounterMonitor , and GaugeMonitor . Each of these monitor types extends Monitor , reusing the common behavior it defines, and defining a distinct MBean type by implementing its own management interface. We will treat each of these concrete monitor types in detail later in this chapter. The MonitorNotification class extends the base JMX Notification class with additional monitor- related information. 6.1.2 The Monitor MBeanThe Monitor MBean defines three read/write attributes, one read-only attribute, and two operations that are shared by all of the JMX monitor MBeans. Tables 6.1 and 6.2 describe these aspects of the Monitor MBean. The GranularityPeriod attribute defaults to 10 seconds, 10,000 milliseconds . Attempting to set it to a value less than or equal to zero results in an IllegalArgumentException . Both ObservedAttribute and ObservedObject default to null . The monitor does not attempt to validate either of these values until its start() method is invoked. If either value is invalid ”for example, null , meaning nonexistent MBean or attribute ”the monitor sends a MonitorNotification instance whose type indicates the nature of the error. We'll say more about MonitorNotification in a moment. Table 6.1. Common Monitor Management Interface Attributes
Table 6.2. Common Monitor Management Interface Operations
Each JMX monitor also provides a derived gauge attribute. It doesn't show up in the MonitorMBean interface because its type is not the same in each of the monitors. The concept, however, is the same in each case. A monitor's derived gauge is the value that the monitor derives from the value of ObservedAttribute . The value may be either the exact value of ObservedAttribute or the difference between two successive ObservedAttribute values. The start() and stop() operations are idempotent. That is, invoking start() on an active monitor has no effect, and the same is true for invocations of stop() on an inactive monitor. 6.1.3 MonitorNotificationMonitors are responsible for alerting the management applications that use them to specific conditions. In JMX the obvious mechanism to use for that purpose is a notification; that is, the monitor sends a JMX notification when the derived gauge for an observed attribute satisfies the condition. Rather than sending an instance of the standard JMX Notification class, the javax.management.monitor package provides the MonitorNotification class, which extends Notification . In addition to the information provided by Notification , MonitorNotification includes four other values:
The monitoring services also define a set of notification types that are associated with the monitor notifications they send. Figure 6.2 shows the MonitorNotification type hierarchy. Figure 6.2. The Hierarchy of MonitorNotification Types
The "error" types are common to all monitors, so we will describe them here (see Table 6.3). The other types will be covered in our discussions of the monitors that send them. Table 6.3. Common Monitor Error Notification Types
|