test/javax/management/monitor/CounterMonitorTest.java

Print this page

        

*** 41,53 **** private Number threshold = new Integer(2); // modulus number private Number modulus = new Integer(7); - // offset number - private int offset = 0; - // difference mode flag private boolean differenceModeFlag = true; // notify flag private boolean notifyFlag = true; --- 41,50 ----
*** 56,68 **** private int granularityperiod = 500; // counter values private int[] values = new int[] {4, 6, 9, 11}; - // time to wait for notification (in seconds) - private int timeout = 5; - // flag to notify that a message has been received private volatile boolean messageReceived = false; // MBean class public class StdObservedObject implements StdObservedObjectMBean { --- 53,62 ----
*** 90,101 **** try { if (type.equals(MonitorNotification.THRESHOLD_VALUE_EXCEEDED)) { echo("\t\t" + n.getObservedAttribute() + " has reached or exceeded the threshold"); echo("\t\tDerived Gauge = " + n.getDerivedGauge()); ! messageReceived = true; synchronized (this) { notifyAll(); } } else { echo("\t\tSkipping notification of type: " + type); } --- 84,96 ---- try { if (type.equals(MonitorNotification.THRESHOLD_VALUE_EXCEEDED)) { echo("\t\t" + n.getObservedAttribute() + " has reached or exceeded the threshold"); echo("\t\tDerived Gauge = " + n.getDerivedGauge()); ! synchronized (this) { + messageReceived = true; notifyAll(); } } else { echo("\t\tSkipping notification of type: " + type); }
*** 203,227 **** echo(">>> Bye! Bye!"); } /* ! * Wait until timeout reached */ ! void doWait() { ! for (int i = 0; i < timeout; i++) { ! echo("\tdoWait: Waiting for " + timeout + " seconds. " + ! "i = " + i + ", messageReceived = " + messageReceived); ! if (messageReceived) { ! break; ! } try { ! synchronized (this) { ! wait(1000); ! } } catch (InterruptedException e) { ! // OK: Ignore... } } } /* --- 198,217 ---- echo(">>> Bye! Bye!"); } /* ! * Wait messageReceived to be true */ ! synchronized void doWait() { ! while (!messageReceived) { try { ! wait(); } catch (InterruptedException e) { ! System.err.println("Got unexpected exception: " + e); ! e.printStackTrace(); ! break; } } } /*