use of javax.management.monitor.MonitorNotification in project jdk8u_jdk by JetBrains.
the class ReflectionExceptionTest method handleNotification.
// Notification handler
public void handleNotification(Notification notification, Object handback) {
echo(">>> Received notification: " + notification);
if (notification instanceof MonitorNotification) {
String type = notification.getType();
if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
MonitorNotification mn = (MonitorNotification) notification;
echo("\tType: " + mn.getType());
echo("\tTimeStamp: " + mn.getTimeStamp());
echo("\tObservedObject: " + mn.getObservedObject());
echo("\tObservedAttribute: " + mn.getObservedAttribute());
echo("\tDerivedGauge: " + mn.getDerivedGauge());
echo("\tTrigger: " + mn.getTrigger());
synchronized (this) {
messageReceived = true;
notifyAll();
}
}
}
}
use of javax.management.monitor.MonitorNotification in project jdk8u_jdk by JetBrains.
the class RuntimeExceptionTest method handleNotification.
// Notification handler
public void handleNotification(Notification notification, Object handback) {
echo(">>> Received notification: " + notification);
if (notification instanceof MonitorNotification) {
String type = notification.getType();
if (type.equals(MonitorNotification.RUNTIME_ERROR)) {
MonitorNotification mn = (MonitorNotification) notification;
echo("\tType: " + mn.getType());
echo("\tTimeStamp: " + mn.getTimeStamp());
echo("\tObservedObject: " + mn.getObservedObject());
echo("\tObservedAttribute: " + mn.getObservedAttribute());
echo("\tDerivedGauge: " + mn.getDerivedGauge());
echo("\tTrigger: " + mn.getTrigger());
synchronized (this) {
messageReceived = true;
notifyAll();
}
}
}
}
use of javax.management.monitor.MonitorNotification in project jdk8u_jdk by JetBrains.
the class CounterMonitor method buildAlarmNotification.
@Override
synchronized MonitorNotification buildAlarmNotification(ObjectName object, String attribute, Comparable<?> value) {
final CounterMonitorObservedObject o = (CounterMonitorObservedObject) getObservedObject(object);
if (o == null)
return null;
// Notify the listeners and update the threshold if
// the updated derived gauge value is valid.
//
final MonitorNotification alarm;
if (o.getDerivedGaugeValid()) {
alarm = updateNotifications(o);
updateThreshold(o);
} else {
alarm = null;
}
return alarm;
}
use of javax.management.monitor.MonitorNotification in project jdk8u_jdk by JetBrains.
the class CounterMonitor method updateNotifications.
/**
* Updates the notification attribute of the observed object
* and notifies the listeners only once if the notify flag
* is set to <CODE>true</CODE>.
* @param o The observed object.
*/
private synchronized MonitorNotification updateNotifications(CounterMonitorObservedObject o) {
MonitorNotification n = null;
//
if (!o.getEventAlreadyNotified()) {
if (((Number) o.getDerivedGauge()).longValue() >= o.getThreshold().longValue()) {
if (notify) {
n = new MonitorNotification(THRESHOLD_VALUE_EXCEEDED, this, 0, 0, "", null, null, null, o.getThreshold());
}
if (!differenceMode) {
o.setEventAlreadyNotified(true);
}
}
} else {
if (MONITOR_LOGGER.isLoggable(Level.FINER)) {
final StringBuilder strb = new StringBuilder().append("The notification:").append("\n\tNotification observed object = ").append(o.getObservedObject()).append("\n\tNotification observed attribute = ").append(getObservedAttribute()).append("\n\tNotification threshold level = ").append(o.getThreshold()).append("\n\tNotification derived gauge = ").append(o.getDerivedGauge()).append("\nhas already been sent");
MONITOR_LOGGER.logp(Level.FINER, CounterMonitor.class.getName(), "updateNotifications", strb.toString());
}
}
return n;
}
use of javax.management.monitor.MonitorNotification in project jdk8u_jdk by JetBrains.
the class Monitor method sendNotification.
/*
* ------------------------------------------
* PRIVATE METHODS
* ------------------------------------------
*/
/**
* 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.
*
* @param type The notification type.
* @param timeStamp The notification emission date.
* @param msg The notification message.
* @param derGauge The derived gauge.
* @param trigger The threshold/string (depending on the monitor
* type) that triggered off the notification.
* @param object The ObjectName of the observed object that triggered
* off the notification.
* @param onError Flag indicating if this monitor notification is
* an error notification or an alarm notification.
*/
private void sendNotification(String type, long timeStamp, String msg, Object derGauge, Object trigger, ObjectName object, boolean onError) {
if (!isActive())
return;
if (MONITOR_LOGGER.isLoggable(Level.FINER)) {
MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), "sendNotification", "send notification: " + "\n\tNotification observed object = " + object + "\n\tNotification observed attribute = " + observedAttribute + "\n\tNotification derived gauge = " + derGauge);
}
long seqno = sequenceNumber.getAndIncrement();
MonitorNotification mn = new MonitorNotification(type, this, seqno, timeStamp, msg, object, observedAttribute, derGauge, trigger);
if (onError)
onErrorNotification(mn);
sendNotification(mn);
}
Aggregations