当前位置: 首页>>代码示例>>Java>>正文


Java GaugeMonitor.stop方法代码示例

本文整理汇总了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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:65,代码来源:RuntimeExceptionTest.java

示例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;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:68,代码来源:RuntimeExceptionTest.java


注:本文中的javax.management.monitor.GaugeMonitor.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。