Package javax.management.monitor

Examples of javax.management.monitor.GaugeMonitor$GaugeMonitorObservedObject


    } catch (Exception e) {
      e.printStackTrace();
    }   
  }
  public void createGaugeMonitor(ObjectName objectName,String serviceName,Long monitoringFrequency,Long thresholdHigh,Long thresholdLow){
    GaugeMonitor gm = new GaugeMonitor();
    gm.addObservedObject(objectName);
    gm.setObservedAttribute("LastResponseTime");
    gm.setGranularityPeriod(monitoringFrequency);
    gm.setNotifyHigh(true);
    gm.setNotifyLow(true);
    gm.setThresholds(thresholdHigh,thresholdLow);
    gm.setDifferenceMode(true);
    gm.addNotificationListener(new GaugeListener(),null,null);
    try {
      ObjectName objectNameG = new ObjectName("XFire:name="+serviceName+"GaugeMonitor,"+"type=management");
      gm.start()
      mbs.registerMBean(gm, objectNameG);
   
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here


    public void DISABLED_testNotificationsJmx() throws Exception {

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

        monitorMBean.setDifferenceMode(false);
        // Setup the monitor: link to the service MBean
        monitorMBean.addObservedObject(serviceName);
        monitorMBean.setObservedAttribute("SimpleCounter");
        // Setup the monitor: a short granularity period
        monitorMBean.setGranularityPeriod(50L);
        // Setup the monitor: register a listener
        MBeanServerConnection connection = connector.getMBeanServerConnection();
        final AtomicBoolean notificationSet = new AtomicBoolean(false);
        //Add a notification listener to the connection - to
        //test for notifications across camel
        connection.addNotificationListener(monitorName, new NotificationListener() {
            public void handleNotification(Notification notification, Object handback) {
                System.out.println("Notification = " + notification);
                synchronized (notificationSet) {
                    notificationSet.set(true);
                    notificationSet.notify();
                }
            }
        }, null, null);
        service.start();
        monitorMBean.start();
        synchronized (notificationSet) {
            if (!notificationSet.get()) {
                notificationSet.wait(5000);
            }
        }
View Full Code Here

      expected.add(MonitorNotification.RUNTIME_ERROR);
      expected.add(MonitorNotification.THRESHOLD_ERROR);
      expected.add(MonitorNotification.THRESHOLD_HIGH_VALUE_EXCEEDED);
      expected.add(MonitorNotification.THRESHOLD_LOW_VALUE_EXCEEDED);

      MBeanNotificationInfo[] mbni = new GaugeMonitor().getNotificationInfo();
      checkNotificationInfo("Gauge", mbni, expected);
   }
View Full Code Here

   private void initGaugeMonitor(boolean notifyHigh, boolean notifyLow,
        Number thresholdHigh, Number thresholdLow, boolean differenceMode)
   {
      try
      {
         GaugeMonitor gaugeMonitor = new GaugeMonitor();
         gaugeMonitor.setNotifyHigh(notifyHigh);
         gaugeMonitor.setNotifyLow(notifyLow);
         gaugeMonitor.setThresholds(thresholdHigh, thresholdLow);
         gaugeMonitor.setDifferenceMode(differenceMode);
         GaugeSupport support = new GaugeSupport();
         monitor = gaugeMonitor;
         monitored = support;
         initMonitor();
      }
View Full Code Here

      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();
   }
View Full Code Here

      expected.add(MonitorNotification.RUNTIME_ERROR);
      expected.add(MonitorNotification.THRESHOLD_ERROR);
      expected.add(MonitorNotification.THRESHOLD_HIGH_VALUE_EXCEEDED);
      expected.add(MonitorNotification.THRESHOLD_LOW_VALUE_EXCEEDED);

      MBeanNotificationInfo[] mbni = new GaugeMonitor().getNotificationInfo();
      checkNotificationInfo("Gauge", mbni, expected);
   }
View Full Code Here

   private void initGaugeMonitor(boolean notifyHigh, boolean notifyLow,
        Number thresholdHigh, Number thresholdLow, boolean differenceMode)
   {
      try
      {
         GaugeMonitor gaugeMonitor = new GaugeMonitor();
         gaugeMonitor.setNotifyHigh(notifyHigh);
         gaugeMonitor.setNotifyLow(notifyLow);
         gaugeMonitor.setThresholds(thresholdHigh, thresholdLow);
         gaugeMonitor.setDifferenceMode(differenceMode);
         GaugeSupport support = new GaugeSupport();
         monitor = gaugeMonitor;
         monitored = support;
         initMonitor();
      }
View Full Code Here

   */
  private void startGaugeService(boolean high, boolean low, boolean differ,
                                 int highValue, int lowValue)
    throws Exception
  {
    installMonitorService(new GaugeMonitor());
    AttributeList attributes = new AttributeList();
    attributes.add(new Attribute("NotifyHigh", new Boolean(high)));
    attributes.add(new Attribute("NotifyLow", new Boolean(low)));
    attributes.add(new Attribute("DifferenceMode", new Boolean(differ)));
    attributes.add(new Attribute("GranularityPeriod", new Long(PERIOD)));
View Full Code Here

{
  /**
   */
  AMXGaugeMonitorImpl()
  {
    super( new GaugeMonitor() );
  }
View Full Code Here

      super(name);
   }

   protected Monitor createMonitor()
   {
      return new GaugeMonitor();
   }
View Full Code Here

TOP

Related Classes of javax.management.monitor.GaugeMonitor$GaugeMonitorObservedObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.