geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r818737 - /geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java
Date Fri, 25 Sep 2009 06:35:06 GMT
Author: rwonly
Date: Fri Sep 25 06:35:06 2009
New Revision: 818737

URL: http://svn.apache.org/viewvc?rev=818737&view=rev
Log:
GERONIMO-4822 Monitoring server via JMX cannot be restarted. (Patch from Siqi Du)

Modified:
    geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java

Modified: geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java?rev=818737&r1=818736&r2=818737&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/jmx/snapshot/SnapshotThread.java
Fri Sep 25 06:35:06 2009
@@ -31,7 +31,7 @@
  */
 public class SnapshotThread extends Thread {
 
-    private long SNAPSHOT_DURATION;
+    volatile private long SNAPSHOT_DURATION;
     private MBeanServer mbServer = null;
     int threadStatus = 1;
     // list of mbean names that we will be taking snapshots of
@@ -83,9 +83,9 @@
      * @param snapshotDuration
      */
     public void setSnapshotDuration(long snapshot_length) {
-        SNAPSHOT_DURATION = snapshot_length;
         if (snapshot_length == Long.MAX_VALUE)
             threadStatus = -1;
+        SNAPSHOT_DURATION = snapshot_length;
     }
 
     public void run() {
@@ -96,13 +96,19 @@
             mbeanNames = getDefaultMBeanList();
         }
         // pause the thread from running every SNAPSHOT_DURATION seconds
-        while (true && SNAPSHOT_DURATION != Long.MAX_VALUE) {
+        loop:while (true) {
             try {
                 // store the data
                 SnapshotProcessor.takeSnapshot();
                 // wait for next snapshot
-                Thread.sleep(SNAPSHOT_DURATION);
-            } catch (Exception e) {
+                for(long nSleep = SNAPSHOT_DURATION/1000; nSleep>0; nSleep--)
+                {
+                   Thread.sleep(1000);
+                   if(SNAPSHOT_DURATION == Long.MAX_VALUE)
+                       break loop;
+                }
+                
+            } catch (InterruptedException e) {
                 e.printStackTrace();
             }
         }



Mime
View raw message