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


Java GaugeMonitor.addObservedObject方法代码示例

本文整理汇总了Java中javax.management.monitor.GaugeMonitor.addObservedObject方法的典型用法代码示例。如果您正苦于以下问题:Java GaugeMonitor.addObservedObject方法的具体用法?Java GaugeMonitor.addObservedObject怎么用?Java GaugeMonitor.addObservedObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.monitor.GaugeMonitor的用法示例。


在下文中一共展示了GaugeMonitor.addObservedObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import javax.management.monitor.GaugeMonitor; //导入方法依赖的package包/类
public void setUp() {
    try {
        server = MBeanServerFactory.createMBeanServer();
        monitor = new GaugeMonitor();
        sensor = new Impulse(100, 100, testedClass[0], testedClass[1]);

        server.registerMBean(monitor, new ObjectName(
                "org.apache.harmony.test.func.api.javax.management.monitor."
                        + "countermonitor:type=CounterMonitor,id=1"));
        sensorName = new ObjectName(Impulse.SENSOR_NAME_TEMPLATE + "1");
        server.registerMBean(sensor, sensorName);

        monitor.addNotificationListener(nListener, null, "handback");

        /* setup monitor */
        monitor.addObservedObject(sensorName);
        monitor.setObservedAttribute("Value");
        monitor.setGranularityPeriod(50);
        monitor.setNotifyHigh(true);
        monitor.setNotifyLow(true);

        Thread sensorThread = new Thread(sensor);
        sensorThread.setDaemon(true);
        sensorThread.start();

    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:30,代码来源:BoundaryTest.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();

        // 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

示例3: main

import javax.management.monitor.GaugeMonitor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
   // Let's create the MBeanServer
   MBeanServer server = MBeanServerFactory.newMBeanServer();

   // Let's create a dynamic MBean and register it
   DynamicService serviceMBean = new DynamicService();
   ObjectName serviceName = new ObjectName("examples", "mbean", "dynamic");
   server.registerMBean(serviceMBean, serviceName);

   // Now let's register a Monitor
   // We would like to know if we have peaks in activity, so we can use JMX's
   // GaugeMonitor
   GaugeMonitor monitorMBean = new GaugeMonitor();
   ObjectName monitorName = new ObjectName("examples", "monitor", "gauge");
   server.registerMBean(monitorMBean, monitorName);

   // Setup the monitor: we want to be notified if we have too many clients or too less
   monitorMBean.setThresholds(new Integer(8), new Integer(4));
   // Setup the monitor: we want to know if a threshold is exceeded
   monitorMBean.setNotifyHigh(true);
   monitorMBean.setNotifyLow(true);
   // Setup the monitor: we're interested in absolute values of the number of clients
   monitorMBean.setDifferenceMode(false);
   // Setup the monitor: link to the service MBean
   monitorMBean.addObservedObject(serviceName);
   monitorMBean.setObservedAttribute("ConcurrentClients");
   // Setup the monitor: a short granularity period
   monitorMBean.setGranularityPeriod(50L);
   // Setup the monitor: register a listener
   monitorMBean.addNotificationListener(new NotificationListener()
   {
      public void handleNotification(Notification notification, Object handback)
      {
         System.out.println(notification);
      }
   }, null, null);
   // Setup the monitor: start it
   monitorMBean.start();

   // Now start also the service
   serviceMBean.start();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:44,代码来源:DynamicMBeanExample.java

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