本文整理汇总了Java中javax.management.monitor.GaugeMonitor.stop方法的典型用法代码示例。如果您正苦于以下问题:Java GaugeMonitor.stop方法的具体用法?Java GaugeMonitor.stop怎么用?Java GaugeMonitor.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.monitor.GaugeMonitor
的用法示例。
在下文中一共展示了GaugeMonitor.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gaugeMonitorNotification
import javax.management.monitor.GaugeMonitor; //导入方法依赖的package包/类
/**
* Update the gauge and check for notifications
*/
public int gaugeMonitorNotification() throws Exception {
GaugeMonitor gaugeMonitor = new GaugeMonitor();
try {
// Create a new GaugeMonitor MBean and add it to the MBeanServer.
//
echo(">>> CREATE a new GaugeMonitor MBean");
ObjectName gaugeMonitorName = new ObjectName(
domain + ":type=" + GaugeMonitor.class.getName());
server.registerMBean(gaugeMonitor, gaugeMonitorName);
echo(">>> ADD a listener to the GaugeMonitor");
gaugeMonitor.addNotificationListener(this, null, null);
//
// MANAGEMENT OF A STANDARD MBEAN
//
echo(">>> SET the attributes of the GaugeMonitor:");
gaugeMonitor.addObservedObject(obsObjName);
echo("\tATTRIBUTE \"ObservedObject\" = " + obsObjName);
gaugeMonitor.setObservedAttribute("IntegerAttribute");
echo("\tATTRIBUTE \"ObservedAttribute\" = IntegerAttribute");
gaugeMonitor.setNotifyLow(false);
gaugeMonitor.setNotifyHigh(false);
echo("\tATTRIBUTE \"Notify Low Flag\" = false");
echo("\tATTRIBUTE \"Notify High Flag\" = false");
Integer highThreshold = 3, lowThreshold = 2;
gaugeMonitor.setThresholds(highThreshold, lowThreshold);
echo("\tATTRIBUTE \"Low Threshold\" = " + lowThreshold);
echo("\tATTRIBUTE \"High Threshold\" = " + highThreshold);
int granularityperiod = 500;
gaugeMonitor.setGranularityPeriod(granularityperiod);
echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);
echo(">>> START the GaugeMonitor");
gaugeMonitor.start();
// Check if notification was received
//
doWait();
if (messageReceived) {
echo("\tOK: GaugeMonitor got RUNTIME_ERROR notification!");
} else {
echo("\tKO: GaugeMonitor did not get " +
"RUNTIME_ERROR notification!");
return 1;
}
} finally {
messageReceived = false;
if (gaugeMonitor != null)
gaugeMonitor.stop();
}
return 0;
}
示例2: gaugeMonitorNotification
import javax.management.monitor.GaugeMonitor; //导入方法依赖的package包/类
/**
* Update the gauge and check for notifications
*/
public int gaugeMonitorNotification() throws Exception {
GaugeMonitor gaugeMonitor = new GaugeMonitor();
try {
// Create a new GaugeMonitor MBean and add it to the MBeanServer.
//
echo(">>> CREATE a new GaugeMonitor MBean");
ObjectName gaugeMonitorName = new ObjectName(
domain + ":type=" + GaugeMonitor.class.getName());
server.registerMBean(gaugeMonitor, gaugeMonitorName);
echo(">>> ADD a listener to the GaugeMonitor");
gaugeMonitor.addNotificationListener(this, null, null);
//
// MANAGEMENT OF A STANDARD MBEAN
//
echo(">>> SET the attributes of the GaugeMonitor:");
gaugeMonitor.addObservedObject(obsObjName);
echo("\tATTRIBUTE \"ObservedObject\" = " + obsObjName);
gaugeMonitor.setObservedAttribute("IntegerAttribute");
echo("\tATTRIBUTE \"ObservedAttribute\" = IntegerAttribute");
gaugeMonitor.setNotifyLow(false);
gaugeMonitor.setNotifyHigh(false);
echo("\tATTRIBUTE \"Notify Low Flag\" = false");
echo("\tATTRIBUTE \"Notify High Flag\" = false");
Integer highThreshold = 3, lowThreshold = 2;
gaugeMonitor.setThresholds(highThreshold, lowThreshold);
echo("\tATTRIBUTE \"Low Threshold\" = " + lowThreshold);
echo("\tATTRIBUTE \"High Threshold\" = " + highThreshold);
int granularityperiod = 500;
gaugeMonitor.setGranularityPeriod(granularityperiod);
echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);
echo(">>> START the GaugeMonitor");
gaugeMonitor.start();
// Wait for granularity period (multiplied by 2 for sure)
//
Thread.sleep(granularityperiod * 2);
// Check if notification was received
//
if (messageReceived) {
echo("\tOK: GaugeMonitor got RUNTIME_ERROR notification!");
} else {
echo("\tKO: GaugeMonitor did not get " +
"RUNTIME_ERROR notification!");
return 1;
}
} finally {
messageReceived = false;
if (gaugeMonitor != null)
gaugeMonitor.stop();
}
return 0;
}