Methods Summary |
---|
com.sun.appserv.management.event.StatisticMonitorNotification | buildAlarmNotification(javax.management.ObjectName object, java.lang.String attribute, java.lang.Comparable value)
int index = indexOf(object);
// Notify the listeners if the updated derived
// gauge value is valid.
//
StatisticMonitorNotification alarm = null;
if (derivedGaugeValid[index])
alarm = updateNotifications(index);
return alarm;
|
public synchronized java.lang.Number | getDerivedGauge(javax.management.ObjectName object)Gets the derived gauge of the specified object, if this object is
contained in the set of observed MBeans, or null otherwise.
return (Number) super.getDerivedGauge(object);
|
public synchronized java.lang.Number | getDerivedGauge()Returns the derived gauge of the first object in the set of
observed MBeans.
return (Number) derivedGauge[0];
|
java.lang.Comparable | getDerivedGaugeFromComparable(javax.management.ObjectName object, java.lang.String attribute, java.lang.Comparable value)
int index = indexOf(object);
// Update the derived gauge attributes and check the
// validity of the new value. The derived gauge value
// is invalid when the differenceMode flag is set to
// true and it is the first notification, i.e. we
// haven't got 2 consecutive values to update the
// derived gauge.
//
derivedGaugeValid[index] = updateDerivedGauge(value, index);
return (Comparable<?>) derivedGauge[index];
|
public synchronized long | getDerivedGaugeTimeStamp(javax.management.ObjectName object)Gets the derived gauge timestamp of the specified object, if
this object is contained in the set of observed MBeans, or
null otherwise.
return super.getDerivedGaugeTimeStamp(object);
|
public synchronized long | getDerivedGaugeTimeStamp()Gets the derived gauge timestamp of the first object in the set
of observed MBeans.
return derivedGaugeTimestamp[0];
|
public synchronized boolean | getDifferenceMode()Gets the difference mode flag value common to all observed MBeans.
return differenceMode;
|
public synchronized java.lang.Number | getHighThreshold()Gets the high threshold value common to all observed MBeans.
return highThreshold;
|
public synchronized java.lang.Number | getLowThreshold()Gets the low threshold value common to all observed MBeans.
return lowThreshold;
|
public javax.management.MBeanNotificationInfo[] | getNotificationInfo()Returns a NotificationInfo object containing the
name of the Java class of the notification and the notification
types sent by the gauge monitor.
return notifsInfo.clone();
|
public synchronized boolean | getNotifyHigh()Gets the high notification's on/off switch value common to all
observed MBeans.
return notifyHigh;
|
public synchronized boolean | getNotifyLow()Gets the low notification's on/off switch value common to all
observed MBeans.
return notifyLow;
|
synchronized void | insertSpecificElementAt(int index)This method is called when adding a new observed object in the vector.
It updates all the gauge specific arrays.
// Update previousScanGauge, status, type and derivedGaugeValid arrays.
//
if (elementCount >= previousScanGauge.length) {
previousScanGauge = expandArray(previousScanGauge);
status = expandArray(status);
type = expandArray(type);
derivedGaugeValid = expandArray(derivedGaugeValid);
}
previousScanGauge[index] = null;
status[index] = RISING_OR_FALLING;
type[index] = INTEGER;
derivedGaugeValid[index] = false;
|
boolean | isComparableTypeValid(javax.management.ObjectName object, java.lang.String attribute, java.lang.Comparable value)This method globally sets the derived gauge type for the given
"object" and "attribute" after checking that the type of the
supplied observed attribute value is one of the value types
supported by this monitor.
int index = indexOf(object);
// Check that the observed attribute is either of type
// "Integer" or "Float".
//
if (value instanceof Integer) {
type[index] = INTEGER;
} else if (value instanceof Byte) {
type[index] = BYTE;
} else if (value instanceof Short) {
type[index] = SHORT;
} else if (value instanceof Long) {
type[index] = LONG;
} else if (value instanceof Float) {
type[index] = FLOAT;
} else if (value instanceof Double) {
type[index] = DOUBLE;
} else {
return false;
}
return true;
|
private boolean | isFirstGreaterThanLast(java.lang.Number greater, java.lang.Number less, NumericalType type)Tests if the first specified Number is greater than or equal to
the last. Both integer and floating-point types are allowed.
switch(type) {
case INTEGER:
case BYTE:
case SHORT:
case LONG:
return (greater.longValue() >= less.longValue());
case FLOAT:
case DOUBLE:
return (greater.doubleValue() >= less.doubleValue());
default:
// Should never occur...
if ( _logger.isLoggable(Level.WARNING) )
_logger.log(Level.WARNING,"The threshold type is invalid");
return false;
}
|
private boolean | isFirstStrictlyGreaterThanLast(java.lang.Number greater, java.lang.Number less, java.lang.String className)Tests if the first specified Number is strictly greater than the last.
Both integer and floating-point types are allowed.
if (className.equals("java.lang.Integer") ||
className.equals("java.lang.Byte") ||
className.equals("java.lang.Short") ||
className.equals("java.lang.Long")) {
return (greater.longValue() > less.longValue());
}
else if (className.equals("java.lang.Float") ||
className.equals("java.lang.Double")) {
return (greater.doubleValue() > less.doubleValue());
}
else {
// Should never occur...
if ( _logger.isLoggable(Level.WARNING) )
_logger.log(Level.WARNING,"The threshold type is invalid");
return false;
}
|
synchronized boolean | isThresholdTypeValid(javax.management.ObjectName object, java.lang.String attribute, java.lang.Comparable value)Tests if the threshold high and threshold low are both of the
same type as the gauge. Both integer and floating-point types
are allowed.
Note:
If the optional lowThreshold or highThreshold have not been
initialized, their default value is an Integer object with
a value equal to zero.
int index = indexOf(object);
Class<? extends Number> c = classForType(type[index]);
return (isValidForType(highThreshold, c) &&
isValidForType(lowThreshold, c));
|
void | onErrorNotification(com.sun.appserv.management.event.StatisticMonitorNotification notification)
int index = indexOf(notification.getObservedObject());
synchronized(this) {
// Reset values.
//
status[index] = RISING_OR_FALLING;
previousScanGauge[index] = null;
}
|
synchronized void | removeSpecificElementAt(int index)This method is called when removing an observed object from the vector.
It updates all the gauge specific arrays.
// Update previousScanGauge, status, type and derivedGaugeValid arrays.
//
removeElementAt(previousScanGauge, index);
removeElementAt(status, index);
removeElementAt(type, index);
removeElementAt(derivedGaugeValid, index);
|
private synchronized void | setDerivedGaugeWithDifference(java.lang.Number scanGauge, int index)Sets the derived gauge when the differenceMode flag is set to
true . Both integer and floating-point types are
allowed.
Number prev = previousScanGauge[index];
Number der;
switch (type[index]) {
case INTEGER:
der = new Integer(((Integer)scanGauge).intValue() -
((Integer)prev).intValue());
break;
case BYTE:
der = new Byte((byte)(((Byte)scanGauge).byteValue() -
((Byte)prev).byteValue()));
break;
case SHORT:
der = new Short((short)(((Short)scanGauge).shortValue() -
((Short)prev).shortValue()));
break;
case LONG:
der = new Long(((Long)scanGauge).longValue() -
((Long)prev).longValue());
break;
case FLOAT:
der = new Float(((Float)scanGauge).floatValue() -
((Float)prev).floatValue());
break;
case DOUBLE:
der = new Double(((Double)scanGauge).doubleValue() -
((Double)prev).doubleValue());
break;
default:
// Should never occur...
if ( _logger.isLoggable(Level.WARNING) )
_logger.log(Level.WARNING,"The threshold type is invalid");
return;
}
derivedGauge[index] = der;
|
public synchronized void | setDifferenceMode(boolean value)Sets the difference mode flag value common to all observed MBeans.
differenceMode = value;
// Reset values.
//
for (int i = 0; i < elementCount; i++) {
status[i] = RISING_OR_FALLING;
previousScanGauge[i] = null;
}
|
public synchronized void | setNotifyHigh(boolean value)Sets the high notification's on/off switch value common to all
observed MBeans.
notifyHigh = value;
|
public synchronized void | setNotifyLow(boolean value)Sets the low notification's on/off switch value common to all
observed MBeans.
notifyLow = value;
|
public synchronized void | setThresholds(java.lang.Number highValue, java.lang.Number lowValue)Sets the high and the low threshold values common to all
observed MBeans.
if ((highValue == null) || (lowValue == null)) {
throw new IllegalArgumentException("Null threshold value");
}
if (highValue.getClass() != lowValue.getClass()) {
throw new IllegalArgumentException("Different type " +
"threshold values");
}
if (isFirstStrictlyGreaterThanLast(lowValue, highValue,
highValue.getClass().getName())) {
throw new IllegalArgumentException("High threshold less than " +
"low threshold");
}
highThreshold = highValue;
lowThreshold = lowValue;
for (int i = 0; i < elementCount; i++) {
resetAlreadyNotified(i, THRESHOLD_ERROR_NOTIFIED);
// Reset values.
//
status[i] = RISING_OR_FALLING;
}
|
public synchronized void | start()Starts the gauge statistic monitor.
// Reset values.
//
for (int i = 0; i < elementCount; i++) {
status[i] = RISING_OR_FALLING;
previousScanGauge[i] = null;
}
doStart();
|
public synchronized void | stop()Stops the gauge statistic monitor.
doStop();
|
private synchronized boolean | updateDerivedGauge(java.lang.Object scanGauge, int index)Updates the derived gauge attribute of the observed object at
the specified index.
boolean is_derived_gauge_valid;
// The gauge difference mode is used.
//
if (differenceMode) {
// The previous scan gauge has been initialized.
//
if (previousScanGauge[index] != null) {
setDerivedGaugeWithDifference((Number)scanGauge, index);
is_derived_gauge_valid = true;
}
// The previous scan gauge has not been initialized.
// We cannot update the derived gauge...
//
else {
is_derived_gauge_valid = false;
}
previousScanGauge[index] = (Number)scanGauge;
}
// The gauge difference mode is not used.
//
else {
derivedGauge[index] = (Number)scanGauge;
is_derived_gauge_valid = true;
}
return is_derived_gauge_valid;
|
private com.sun.appserv.management.event.StatisticMonitorNotification | updateNotifications(int index)Updates the notification attribute of the observed object at the
specified index and notifies the listeners only once if the notify flag
is set to true .
StatisticMonitorNotification n = null;
// Send high notification if notifyHigh is true.
// Send low notification if notifyLow is true.
//
synchronized(this) {
if (status[index] == RISING_OR_FALLING) {
if (isFirstGreaterThanLast((Number)derivedGauge[index],
highThreshold,
type[index])) {
if (notifyHigh) {
n = new StatisticMonitorNotification(
THRESHOLD_HIGH_VALUE_EXCEEDED,
this,
0,
0,
"",
null,
null,
null,
highThreshold);
}
status[index] = FALLING;
} else if (isFirstGreaterThanLast(lowThreshold,
(Number)derivedGauge[index],
type[index])) {
if (notifyLow) {
n = new StatisticMonitorNotification(
THRESHOLD_LOW_VALUE_EXCEEDED,
this,
0,
0,
"",
null,
null,
null,
lowThreshold);
}
status[index] = RISING;
}
} else {
if (status[index] == RISING) {
if (isFirstGreaterThanLast((Number)derivedGauge[index],
highThreshold,
type[index])) {
if (notifyHigh) {
n = new StatisticMonitorNotification(
THRESHOLD_HIGH_VALUE_EXCEEDED,
this,
0,
0,
"",
null,
null,
null,
highThreshold);
}
status[index] = FALLING;
}
} else if (status[index] == FALLING) {
if (isFirstGreaterThanLast(lowThreshold,
(Number)derivedGauge[index],
type[index])) {
if (notifyLow) {
n = new StatisticMonitorNotification(
THRESHOLD_LOW_VALUE_EXCEEDED,
this,
0,
0,
"",
null,
null,
null,
lowThreshold);
}
status[index] = RISING;
}
}
}
}
return n;
|