jdk/src/java.management/share/classes/javax/management/monitor/GaugeMonitor.java
changeset 43235 da1786d695b6
parent 25859 3317bb8137f4
equal deleted inserted replaced
43234:cb2a6851b837 43235:da1786d695b6
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    24  */
    24  */
    25 
    25 
    26 package javax.management.monitor;
    26 package javax.management.monitor;
    27 
    27 
    28 import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER;
    28 import static com.sun.jmx.defaults.JmxProperties.MONITOR_LOGGER;
    29 import java.util.logging.Level;
    29 import java.lang.System.Logger.Level;
    30 import javax.management.MBeanNotificationInfo;
    30 import javax.management.MBeanNotificationInfo;
    31 import javax.management.ObjectName;
    31 import javax.management.ObjectName;
    32 import static javax.management.monitor.Monitor.NumericalType.*;
    32 import static javax.management.monitor.Monitor.NumericalType.*;
    33 import static javax.management.monitor.MonitorNotification.*;
    33 import static javax.management.monitor.MonitorNotification.*;
    34 
    34 
   222     /**
   222     /**
   223      * Starts the gauge monitor.
   223      * Starts the gauge monitor.
   224      */
   224      */
   225     public synchronized void start() {
   225     public synchronized void start() {
   226         if (isActive()) {
   226         if (isActive()) {
   227             MONITOR_LOGGER.logp(Level.FINER, GaugeMonitor.class.getName(),
   227             MONITOR_LOGGER.log(Level.TRACE, "the monitor is already active");
   228                     "start", "the monitor is already active");
       
   229             return;
   228             return;
   230         }
   229         }
   231         // Reset values.
   230         // Reset values.
   232         //
   231         //
   233         for (ObservedObject o : observedObjects) {
   232         for (ObservedObject o : observedObjects) {
   662             der = Double.valueOf(((Double)scanGauge).doubleValue() -
   661             der = Double.valueOf(((Double)scanGauge).doubleValue() -
   663                                  ((Double)prev).doubleValue());
   662                                  ((Double)prev).doubleValue());
   664             break;
   663             break;
   665         default:
   664         default:
   666             // Should never occur...
   665             // Should never occur...
   667             MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
   666             MONITOR_LOGGER.log(Level.TRACE,
   668                     "setDerivedGaugeWithDifference",
       
   669                     "the threshold type is invalid");
   667                     "the threshold type is invalid");
   670             return;
   668             return;
   671         }
   669         }
   672         o.setDerivedGauge(der);
   670         o.setDerivedGauge(der);
   673     }
   671     }
   696         case FLOAT:
   694         case FLOAT:
   697         case DOUBLE:
   695         case DOUBLE:
   698             return (greater.doubleValue() >= less.doubleValue());
   696             return (greater.doubleValue() >= less.doubleValue());
   699         default:
   697         default:
   700             // Should never occur...
   698             // Should never occur...
   701             MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
   699             MONITOR_LOGGER.log(Level.TRACE,
   702                     "isFirstGreaterThanLast",
       
   703                     "the threshold type is invalid");
   700                     "the threshold type is invalid");
   704             return false;
   701             return false;
   705         }
   702         }
   706     }
   703     }
   707 
   704 
   731 
   728 
   732             return (greater.doubleValue() > less.doubleValue());
   729             return (greater.doubleValue() > less.doubleValue());
   733         }
   730         }
   734         else {
   731         else {
   735             // Should never occur...
   732             // Should never occur...
   736             MONITOR_LOGGER.logp(Level.FINEST, GaugeMonitor.class.getName(),
   733             MONITOR_LOGGER.log(Level.TRACE,
   737                     "isFirstStrictlyGreaterThanLast",
       
   738                     "the threshold type is invalid");
   734                     "the threshold type is invalid");
   739             return false;
   735             return false;
   740         }
   736         }
   741     }
   737     }
   742 
   738