Top Description Inners Fields Constructors Methods
javax.management.monitor

public abstract Class Monitor

extends NotificationBroadcasterSupport
implements MonitorMBean, MBeanRegistration
Class Inheritance
All Implemented Interfaces
javax.management.MBeanRegistration, javax.management.monitor.MonitorMBean
Known Direct Subclasses
javax.management.monitor.StringMonitor, javax.management.monitor.CounterMonitor, javax.management.monitor.GaugeMonitor
Static Imports
com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER, javax.management.monitor.MonitorNotification.*

Defines the part common to all monitor MBeans. A monitor MBean monitors values of an attribute common to a set of observed MBeans. The observed attribute is monitored at intervals specified by the granularity period. A gauge value (derived gauge) is derived from the values of the observed attribute.
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Monitor.DaemonThreadFactory

Daemon thread factory used by the monitor executors.

private class
Monitor.MonitorTask

MonitorTask nested class: This class implements the Runnable interface.

pack-priv static enum
Monitor.NumericalType

Enumeration used to keep trace of the derived gauge type in counter and gauge monitors.

pack-priv static class
private class
Monitor.SchedulerTask

SchedulerTask nested class: This class implements the Runnable interface.

Field Summary

Modifier and TypeField and Description
private volatile AccessControlContext
acc

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
protected int
alreadyNotified

Deprecated equivalent to alreadyNotifieds[0].
Monitor errors that have already been notified.
protected int[]
alreadyNotifieds

Selected monitor errors that have already been notified.

protected static final int
capacityIncrement

The amount by which the capacity of the monitor arrays are automatically incremented when their size becomes greater than their capacity.

protected String
dbgTag

Deprecated No replacement.
This field is retained for compatibility but should not be referenced.
protected int
elementCount

The number of valid components in the vector of observed objects.

private static final Map<ThreadPoolExecutor, Void>
executors

Map containing the thread pool executor per thread group.

private static final Object
executorsLock

Lock for executors map.

private String
firstAttribute

First attribute name extracted from complex type attribute name.

private long
granularityPeriod

Monitor granularity period (in milliseconds).

pack-priv static final Integer
INTEGER_ZERO

Constant used to initialize all the numeric values.

private boolean
isActive

Monitor state.

private boolean
isComplexTypeAttribute

Complex type attribute flag.

private static final int
maximumPoolSize

Maximum Pool Size

private Future<?>
monitorFuture

Future associated to the current monitor task.

private static final AccessControlContext
noPermissionsACC

References Deprecated AccessControlContext is deprecated or references (maybe indirectly) at least one deprecated element.
protected static final int
OBSERVED_ATTRIBUTE_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed attribute.

protected static final int
OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object or the observed attribute.

protected static final int
OBSERVED_OBJECT_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object.

private String
observedAttribute

Attribute to observe.

pack-priv final List<Monitor.ObservedObject>
observedObjects

List of ObservedObjects to which the attribute to observe belongs.

private final List<String>
remainingAttributes

Remaining attribute names extracted from complex type attribute name.

protected static final int
RESET_FLAGS_ALREADY_NOTIFIED

This flag is used to reset the alreadyNotifieds monitor attribute.

protected static final int
RUNTIME_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the observed object or the observed attribute.

private static final ScheduledExecutorService
scheduler

Scheduler Service.

private ScheduledFuture<?>
schedulerFuture

ScheduledFuture associated to the current scheduler task.

private final Monitor.SchedulerTask
schedulerTask

Scheduler task to be executed by the Scheduler Service.

private final AtomicLong
sequenceNumber

Monitor sequence number.

protected MBeanServer
server

Reference to the MBean server.

private volatile Subject
subject

Subject and possibly AccessControlContext of the Monitor.start() caller.

pack-priv static final int
THRESHOLD_ERROR_NOTIFIED

Flag denoting that a notification has occurred after changing the threshold.

Constructor Summary

AccessConstructor and Description
public
Monitor()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
addObservedObject(ObjectName
The object to observe.
object
)

Implements javax.management.monitor.MonitorMBean.addObservedObject.

Adds the specified object in the set of observed MBeans, if this object is not already present.

pack-priv MonitorNotification
buildAlarmNotification(ObjectName object, String attribute, Comparable<?> value)

pack-priv String
buildErrorNotification(ObjectName object, String attribute, Comparable<?> value)

pack-priv static Class<? extends Number>
private synchronized void
cleanupFutures()

Cleanup the scheduler and monitor tasks futures.

private synchronized void
cleanupIsComplexTypeAttribute()

Cleanup the "is complex type attribute" info.

pack-priv synchronized int
computeAlreadyNotifiedIndex(Monitor.ObservedObject o, int index, int[] an)

Check if the alreadyNotifieds array has been modified.

public synchronized boolean

Returns:

true if the specified object is present, false otherwise.
containsObservedObject
(ObjectName
The object to check.
object
)

Implements javax.management.monitor.MonitorMBean.containsObservedObject.

Tests whether the specified object is in the set of observed MBeans.

pack-priv synchronized void
createAlreadyNotified()

Create the alreadyNotified array from the ObservedObject array list.

pack-priv Monitor.ObservedObject
createObservedObject(ObjectName object)

Factory method for ObservedObject creation.

pack-priv void
doStart()

Starts the monitor.

pack-priv void
doStop()

Stops the monitor.

pack-priv Object
pack-priv Comparable<?>
pack-priv synchronized Object

Returns:

The derived gauge of the specified object.
getDerivedGauge
(ObjectName
the name of the object whose derived gauge is to be returned.
object
)

Gets the derived gauge of the specified object, if this object is contained in the set of observed MBeans, or null otherwise.

pack-priv Comparable<?>
pack-priv synchronized long

Returns:

The derived gauge timestamp of the specified object.
getDerivedGaugeTimeStamp
(ObjectName
the name of the object whose derived gauge timestamp is to be returned.
object
)

Gets the derived gauge timestamp of the specified object, if this object is contained in the set of observed MBeans, or 0 otherwise.

public synchronized long

Returns:

The granularity period value.
getGranularityPeriod
()

Implements javax.management.monitor.MonitorMBean.getGranularityPeriod.

Gets the granularity period (in milliseconds).

public synchronized String

Returns:

The attribute being observed.
getObservedAttribute
()

Implements javax.management.monitor.MonitorMBean.getObservedAttribute.

Gets the attribute being observed.

public synchronized ObjectName

Returns:

The object being observed.
getObservedObject
()

Implements javax.management.monitor.MonitorMBean.getObservedObject.

Deprecated As of JMX 1.2, replaced by getObservedObjects

Returns the object name of the first object in the set of observed MBeans, or null if there is no such object.

pack-priv synchronized Monitor.ObservedObject

Returns:

The ObservedObject associated to the supplied ObjectName.
getObservedObject
(ObjectName
the name of the ObservedObject to retrieve.
object
)

Get the specified ObservedObject if this object is contained in the set of observed MBeans, or null otherwise.

public synchronized ObjectName[]

Returns:

The objects being observed.
getObservedObjects
()

Implements javax.management.monitor.MonitorMBean.getObservedObjects.

Returns an array containing the objects being observed.

public synchronized boolean

Returns:

true if the monitor MBean is active, false otherwise.
isActive
()

Implements javax.management.monitor.MonitorMBean.isActive.

Tests whether the monitor MBean is active.

pack-priv synchronized boolean
isAlreadyNotified(Monitor.ObservedObject o, int mask)

Check if the given bits in the given element of alreadyNotifieds are set.

pack-priv boolean
isComparableTypeValid(ObjectName object, String attribute, Comparable<?> value)

pack-priv boolean
isThresholdTypeValid(ObjectName object, String attribute, Comparable<?> value)

pack-priv static boolean
isValidForType(Object value, Class<? extends Number> c)

private void
monitor(Monitor.ObservedObject
The observed object.
o
,
int index, int[] an)

This method is called by the monitor each time the granularity period has been exceeded.

pack-priv void
public void
postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Allows the monitor MBean to perform any operations needed after having been unregistered by the MBean server.

public void
postRegister(Boolean
Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.
registrationDone
)

Implements javax.management.MBeanRegistration.postRegister.

Allows the monitor MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

public void
preDeregister()

Implements javax.management.MBeanRegistration.preDeregister.

Allows the monitor MBean to perform any operations it needs before being unregistered by the MBean server.

public ObjectName

Returns:

The name of the monitor MBean registered.
preRegister
(MBeanServer
The MBean server in which the monitor MBean will be registered.
server
,
ObjectName
The object name of the monitor MBean.
name
)

Implements javax.management.MBeanRegistration.preRegister.

Allows the monitor MBean to perform any operations it needs before being registered in the MBean server.

public synchronized void
removeObservedObject(ObjectName
The object to remove.
object
)

Implements javax.management.monitor.MonitorMBean.removeObservedObject.

Removes the specified object from the set of observed MBeans.

pack-priv synchronized void
resetAllAlreadyNotified(Monitor.ObservedObject o, int index, int[] an)

Reset all bits in the given element of alreadyNotifieds.

pack-priv synchronized void
resetAlreadyNotified(Monitor.ObservedObject o, int index, int mask)

Reset the given bits in the given element of alreadyNotifieds.

private void
sendNotification(String
The notification type.
type
,
long
The notification emission date.
timeStamp
,
String
The notification message.
msg
,
Object
The derived gauge.
derGauge
,
Object
The threshold/string (depending on the monitor type) that triggered off the notification.
trigger
,
ObjectName
The ObjectName of the observed object that triggered off the notification.
object
,
boolean
Flag indicating if this monitor notification is an error notification or an alarm notification.
onError
)

This method is used by the monitor MBean to create and send a monitor notification to all the listeners registered for this kind of notification.

pack-priv synchronized void
setAlreadyNotified(Monitor.ObservedObject o, int index, int mask, int[] an)

Set the given bits in the given element of alreadyNotifieds.

public synchronized void
setGranularityPeriod(long
The granularity period value.
period
)

Implements javax.management.monitor.MonitorMBean.setGranularityPeriod.

Sets the granularity period (in milliseconds).

public void
setObservedAttribute(String
The attribute to observe.
attribute
)

Implements javax.management.monitor.MonitorMBean.setObservedAttribute.

Sets the attribute to observe.

public synchronized void
setObservedObject(ObjectName
The object to observe.
object
)

Implements javax.management.monitor.MonitorMBean.setObservedObject.

Deprecated As of JMX 1.2, replaced by addObservedObject

Removes all objects from the set of observed objects, and then adds the specified object.

public abstract void
start()

Redeclares javax.management.monitor.MonitorMBean.start.

Starts the monitor.

public abstract void
stop()

Redeclares javax.management.monitor.MonitorMBean.stop.

Stops the monitor.

pack-priv synchronized void
updateAlreadyNotified(Monitor.ObservedObject o, int index)

Update the alreadyNotifieds array element at the given index with the already notified flag in the given ObservedObject.

pack-priv synchronized void
updateDeprecatedAlreadyNotified()

Update the deprecated alreadyNotified field.

Inherited from javax.management.NotificationBroadcasterSupport:
addNotificationListenergetNotificationInfohandleNotificationremoveNotificationListenerremoveNotificationListenersendNotification