Fields Summary |
---|
private List | observedObjectsList of MBeans to which the attribute to observe belongs.
The default value is set to null. |
private String | observedAttributeAttribute to observe.
The default value is set to null. |
private long | granularityPeriodMonitor granularity period (in milliseconds).
The default value is set to 10 seconds. |
protected static final int | capacityIncrementThe amount by which the capacity of the monitor arrays are
automatically incremented when their size becomes greater than
their capacity. |
protected int | elementCountThe number of valid components in the vector of observed objects. |
protected int | alreadyNotifiedMonitor errors that have already been notified. |
protected int[] | alreadyNotifieds Selected monitor errors that have already been notified.
Each element in this array corresponds to an observed object
in the vector. It contains a bit mask of the flags {@link
#OBSERVED_OBJECT_ERROR_NOTIFIED} etc, indicating whether the
corresponding notification has already been sent for the MBean
being monitored. |
protected MBeanServer | serverReference on the MBean server. This reference is null when the
monitor MBean is not registered in an MBean server. This
reference is initialized before the monitor MBean is registered
in the MBean server. |
protected static final int | RESET_FLAGS_ALREADY_NOTIFIEDThis flag is used to reset the {@link #alreadyNotifieds
alreadyNotifieds} monitor attribute. |
protected static final int | OBSERVED_OBJECT_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing
the observed object. This flag is used to check that the new
observed object is registered in the MBean server at the time
of the first notification. |
protected static final int | OBSERVED_ATTRIBUTE_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing
the observed attribute. This flag is used to check that the
new observed attribute belongs to the observed object at the
time of the first notification. |
protected static final int | OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing
the observed object or the observed attribute. This flag is
used to check that the observed attribute type is correct
(depending on the monitor in use) at the time of the first
notification. |
protected static final int | RUNTIME_ERROR_NOTIFIEDFlag denoting that a notification has occurred after changing
the observed object or the observed attribute. This flag is
used to notify any exception (except the cases described above)
when trying to get the value of the observed attribute at the
time of the first notification. |
protected String | dbgTagThis field is retained for compatibility but should not be referenced. |
boolean | isActiveMonitor state.
The default value is set to false . |
long | sequenceNumberMonitor sequence number.
The default value is set to 0. |
Methods Summary |
---|
public synchronized void | addObservedObject(javax.management.ObjectName object)Adds the specified object in the set of observed MBeans, if this object
is not already present.
if (object == null) {
throw new IllegalArgumentException("Null observed object");
}
// Check that the specified object is not already contained
//
if (observedObjects.contains(object)) {
return;
}
// Add the specified object in the list.
//
observedObjects.add(object);
// Update alreadyNotified array.
//
int value = RESET_FLAGS_ALREADY_NOTIFIED;
value &= ~(OBSERVED_OBJECT_ERROR_NOTIFIED |
OBSERVED_ATTRIBUTE_ERROR_NOTIFIED |
OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED);
if (alreadyNotifieds.length >= elementCount)
alreadyNotifieds = expandArray(alreadyNotifieds);
alreadyNotifieds[elementCount] = value;
updateDeprecatedAlreadyNotified();
// Update other specific arrays.
//
insertSpecificElementAt(elementCount);
// Update elementCount.
//
elementCount++;
|
synchronized boolean | alreadyNotified(int index, int mask)
return ((alreadyNotifieds[index] & mask) != 0);
|
public boolean | containsObservedObject(javax.management.ObjectName object)Tests whether the specified object is in the set of observed MBeans.
synchronized(this) {
return observedObjects.contains(object);
}
|
static void | debug(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_MONITOR, clz, func, info);
|
void | debug(java.lang.String func, java.lang.String info)
debug(dbgTag, func, info);
|
int[] | expandArray(int[] array)
int[] newArray = new int[array.length + capacityIncrement];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
|
long[] | expandArray(long[] array)
long[] newArray = new long[array.length + capacityIncrement];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
|
java.lang.Number[] | expandArray(java.lang.Number[] array)
Number[] newArray = new Number[array.length + capacityIncrement];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
|
boolean[] | expandArray(boolean[] array)
boolean[] newArray = new boolean[array.length + capacityIncrement];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
|
java.lang.String[] | expandArray(java.lang.String[] array)
String[] newArray = new String[array.length + capacityIncrement];
System.arraycopy(array, 0, newArray, 0, array.length);
return newArray;
|
public synchronized long | getGranularityPeriod()Gets the granularity period (in milliseconds).
The default value of the granularity period is 10 seconds.
return granularityPeriod;
|
public java.lang.String | getObservedAttribute()Gets the attribute being observed.
The observed attribute is not initialized by default (set to null).
return observedAttribute;
|
public javax.management.ObjectName | getObservedObject()Returns the object name of the first object in the set of observed
MBeans, or null if there is no such object.
synchronized(this) {
if (observedObjects.isEmpty()) {
return null;
} else {
return (ObjectName)observedObjects.get(0);
}
}
|
synchronized javax.management.ObjectName | getObservedObject(int index)Gets the {@link ObjectName} of the object at the specified
index in the list of observed MBeans.
return (ObjectName)observedObjects.get(index);
|
public javax.management.ObjectName[] | getObservedObjects()Returns an array containing the objects being observed.
ObjectName[] objects;
synchronized(this) {
objects = new ObjectName[elementCount];
for (int i=0; i<elementCount; i++) {
objects[i] = (ObjectName)observedObjects.get(i);
}
}
return objects;
|
synchronized int | indexOf(javax.management.ObjectName object)Searches for the first occurence of the given argument, testing
for equality using the equals method.
return observedObjects.indexOf(object);
|
void | insertSpecificElementAt(int index)This method is overridden by the specific monitor classes
(Counter, Gauge and String). It updates all the specific
arrays after adding a new observed object in the list.
The method is not abstract so that this class can be subclassed
by classes outside this package.
|
public synchronized boolean | isActive()Tests whether the monitor MBean is active. A monitor MBean is
marked active when the {@link #start start} method is called.
It becomes inactive when the {@link #stop stop} method is
called.
return isActive;
|
static boolean | isDebugOn()
return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_MONITOR);
|
static boolean | isTraceOn()
// TRACES & DEBUG
//---------------
return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MONITOR);
|
public void | postDeregister()Allows the monitor MBean to perform any operations needed after
having been unregistered by the MBean server.
Not used in this context.
|
public void | postRegister(java.lang.Boolean registrationDone)Allows the monitor MBean to perform any operations needed after
having been registered in the MBean server or after the
registration has failed.
Not used in this context.
|
public void | preDeregister()Allows the monitor MBean to perform any operations it needs
before being unregistered by the MBean server.
Stops the monitor.
if (isTraceOn()) {
trace("preDeregister", "stop the monitor");
}
// Stop the Monitor.
//
stop();
|
public javax.management.ObjectName | preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)Allows the monitor MBean to perform any operations it needs
before being registered in the MBean server.
Initializes the reference to the MBean server.
if (isTraceOn()) {
trace("preRegister",
"initialize the reference on the MBean server");
}
this.server = server;
return name;
|
synchronized void | removeElementAt(int[] array, int index)Removes the component at the specified index from the specified
int array.
if (index < 0 || index >= elementCount)
return;
int j = elementCount - index - 1;
if (j > 0) {
System.arraycopy(array, index + 1, array, index, j);
}
|
synchronized void | removeElementAt(long[] array, int index)Removes the component at the specified index from the specified
long array.
if (index < 0 || index >= elementCount)
return;
int j = elementCount - index - 1;
if (j > 0) {
System.arraycopy(array, index + 1, array, index, j);
}
|
synchronized void | removeElementAt(boolean[] array, int index)Removes the component at the specified index from the specified
boolean array.
if (index < 0 || index >= elementCount)
return;
int j = elementCount - index - 1;
if (j > 0) {
System.arraycopy(array, index + 1, array, index, j);
}
|
synchronized void | removeElementAt(java.lang.Object[] array, int index)Removes the component at the specified index from the specified
Number array.
if (index < 0 || index >= elementCount)
return;
int j = elementCount - index - 1;
if (j > 0) {
System.arraycopy(array, index + 1, array, index, j);
}
array[elementCount - 1] = null;
|
public void | removeObservedObject(javax.management.ObjectName object)Removes the specified object from the set of observed MBeans.
synchronized(this) {
int index = observedObjects.indexOf(object);
if (index >= 0) {
observedObjects.remove(index);
// Update alreadyNotifieds array.
//
removeElementAt(alreadyNotifieds, index);
updateDeprecatedAlreadyNotified();
// Update other specific arrays.
//
removeSpecificElementAt(index);
// Update elementCount.
//
elementCount--;
}
}
|
void | removeSpecificElementAt(int index)This method is overridden by the specific monitor classes
(Counter, Gauge and String). It updates all the specific
arrays after removing an observed object from the vector.
The method is not abstract so that this class can be subclassed
by classes outside this package.
|
synchronized void | resetAllAlreadyNotified(int index)Reset all bits in the given element of {@link #alreadyNotifieds}.
Ensure the deprecated {@link #alreadyNotified} field is updated
if appropriate.
alreadyNotifieds[index] = 0;
if (index == 0)
updateDeprecatedAlreadyNotified();
|
synchronized void | resetAlreadyNotified(int index, int mask)Reset the given bits in the given element of {@link #alreadyNotifieds}.
Ensure the deprecated {@link #alreadyNotified} field is updated
if appropriate.
alreadyNotifieds[index] &= ~mask;
if (index == 0)
updateDeprecatedAlreadyNotified();
|
void | sendNotification(java.lang.String type, long timeStamp, java.lang.String msg, java.lang.Object derGauge, java.lang.Object trigger, int index)This method is used by the monitor MBean create and send a
monitor notification to all the listeners registered for this
kind of notification.
if (isTraceOn()) {
trace("sendNotification", "send notification:" +
"\n\tNotification observed object = " +
getObservedObject(index) +
"\n\tNotification observed attribute = " +
observedAttribute +
"\n\tNotification derived gauge = " +
derGauge);
}
long seqno;
synchronized (this) {
seqno = sequenceNumber++;
}
sendNotification(new MonitorNotification(type,
this,
seqno,
timeStamp,
msg,
getObservedObject(index),
observedAttribute,
derGauge,
trigger));
|
synchronized void | setAlreadyNotified(int index, int mask)Set the given bits in the given element of {@link #alreadyNotifieds}.
Ensure the deprecated {@link #alreadyNotified} field is updated
if appropriate.
alreadyNotifieds[index] |= mask;
if (index == 0)
updateDeprecatedAlreadyNotified();
|
public synchronized void | setGranularityPeriod(long period)Sets the granularity period (in milliseconds).
The default value of the granularity period is 10 seconds.
if (period <= 0) {
throw new IllegalArgumentException("Nonpositive granularity " +
"period");
}
granularityPeriod = period;
|
public void | setObservedAttribute(java.lang.String attribute)Sets the attribute to observe.
The observed attribute is not initialized by default (set to null).
if (attribute == null) {
throw new IllegalArgumentException("Null observed attribute");
}
// Update alreadyNotified array.
//
synchronized(this) {
observedAttribute = attribute;
for (int i = 0; i < elementCount; i++) {
resetAlreadyNotified(i,
OBSERVED_ATTRIBUTE_ERROR_NOTIFIED |
OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED);
}
}
|
public synchronized void | setObservedObject(javax.management.ObjectName object)Removes all objects from the set of observed objects, and then adds the
specified object.
while (!observedObjects.isEmpty()) {
removeObservedObject((ObjectName)observedObjects.get(0));
}
addObservedObject(object);
|
public abstract void | start()Starts the monitor.
|
public abstract void | stop()Stops the monitor.
|
static void | trace(java.lang.String clz, java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MONITOR, clz, func, info);
|
void | trace(java.lang.String func, java.lang.String info)
trace(dbgTag, func, info);
|
synchronized void | updateDeprecatedAlreadyNotified()Update the deprecated {@link #alreadyNotified} field.
if (elementCount > 0)
alreadyNotified = alreadyNotifieds[0];
else
alreadyNotified = 0;
|