geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r617721 - in /geronimo/server/trunk/plugins/monitoring: agent-jmx/src/main/java/org/apache/geronimo/monitoring/ agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/ mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/
Date Sat, 02 Feb 2008 00:38:42 GMT
Author: ecraig
Date: Fri Feb  1 16:38:35 2008
New Revision: 617721

URL: http://svn.apache.org/viewvc?rev=617721&view=rev
Log:
GERONIMO-3803

monitoring plugin: agent-jmx does not provide the correct interface for mconsole

Patch by Viet Nguyen


Modified:
    geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
    geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java

Modified: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java?rev=617721&r1=617720&r2=617721&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
Fri Feb  1 16:38:35 2008
@@ -67,9 +67,10 @@
     private static Log log = LogFactory.getLog(MasterRemoteControlJMX.class);
     // constants
     private static final String GERONIMO_DEFAULT_DOMAIN = "geronimo";
-    private static final Long DEFAULT_DURATION = new Long(5000);
+    private static final Long DEFAULT_DURATION = new Long(300000);
     private static final int DEFAULT_RETENTION = 30;
     private static final String RETENTION = "retention";
+    private static final String DURATION = "duration";
 
     // mbean server to talk to other components
     private static MBeanServer mbServer = null;
@@ -173,17 +174,19 @@
     /**
      * Stops the snapshot thread
      */
-    public void stopSnapshot() {
+    public boolean stopSnapshot() {
         if(snapshotThread != null) {
-            if(snapshotThread.getSnapshotDuration() == Long.MAX_VALUE) {
-                saveDuration(DEFAULT_DURATION);
-            } else {
+            if(snapshotThread.getSnapshotDuration() != Long.MAX_VALUE) {
                 saveDuration(snapshotThread.getSnapshotDuration());
+                snapshotThread.setSnapshotDuration(Long.MAX_VALUE);
+                log.info("Snapshot thread stopped.");
+                return true;
+            } else {
+                return false;
             }
-            snapshotThread.setSnapshotDuration(Long.MAX_VALUE);
-            log.info("Snapshot thread stopped.");
         } else {
             log.error("There is not a snapshot thread running. Stopping aborted.");
+            return false;
         }
     }
     
@@ -232,10 +235,10 @@
      * @return Long
      */
     public Long getSnapshotDuration() {
-        if(snapshotThread != null) {
-            return new Long(snapshotThread.getSnapshotDuration());
-        } else {
-            return DEFAULT_DURATION;
+        try {
+            return Long.parseLong(SnapshotConfigXMLBuilder.getAttributeValue(DURATION));
+        } catch(Exception e) {
+            return new Long(DEFAULT_DURATION);
         }
     }
     
@@ -292,7 +295,7 @@
      * @param interval
      */
     public boolean startSnapshot(Long interval, Integer retention) {
-        if((snapshotThread == null || (snapshotThread != null && !snapshotThread.isAlive()))
&& interval.longValue() > 0) {
+        if((snapshotThread == null || (snapshotThread != null && !snapshotThread.isSnapshotRunning()))
&& interval.longValue() > 0) {
             saveDuration(interval.longValue());
             saveRetention(retention.intValue());
             snapshotThread = new SnapshotThread(interval.longValue(), mbServer);
@@ -474,7 +477,11 @@
      */
     public boolean isSnapshotRunning() {
         // TODO: check if the snapshot thread is running 
-        return snapshotThread.isSnapshotRunning();
+        if(snapshotThread == null) {
+            return false;
+        } else {
+            return snapshotThread.isSnapshotRunning();
+        }
     }
 
     public static final GBeanInfo GBEAN_INFO;
@@ -485,7 +492,7 @@
         infoFactory.addOperation("setAttribute", new Class[] {String.class, String.class,
Object.class}, "void");
         infoFactory.addOperation("startSnapshot", new Class[] {Long.class}, "Boolean");
         infoFactory.addOperation("startSnapshot", new Class[] {Long.class, Integer.class},
"Boolean");
-        infoFactory.addOperation("stopSnapshot", new Class[] {}, "void");
+        infoFactory.addOperation("stopSnapshot", new Class[] {}, "Boolean");
         infoFactory.addOperation("fetchSnapshotData", new Class[] {Integer.class, Integer.class},
"ArrayList");
         infoFactory.addOperation("fetchMaxSnapshotData", new Class[] {Integer.class}, "HashMap");
         infoFactory.addOperation("fetchMinSnapshotData", new Class[] {Integer.class}, "HashMap");
@@ -499,6 +506,7 @@
         infoFactory.addOperation("removeMBeanForSnapshot", new Class[] {String.class}, "void");
         infoFactory.addOperation("getSnapshotRetention", new Class[] {}, "Integer");
         infoFactory.addOperation("setSnapshotRetention", new Class[] {Integer.class}, "void");
+        infoFactory.addOperation("isSnapshotRunning", new Class[] {}, "Boolean");
         infoFactory.setConstructor(new String[] {});
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java?rev=617721&r1=617720&r2=617721&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
Fri Feb  1 16:38:35 2008
@@ -34,6 +34,7 @@
 
     private long SNAPSHOT_DURATION;
     private MBeanServer mbServer = null;
+    boolean isDone = false;
     // list of mbean names that we will be taking snapshots of
     private ArrayList<String> mbeanNames;
     
@@ -53,7 +54,7 @@
     }
 
     public boolean isSnapshotRunning() {
-        return SNAPSHOT_DURATION == Long.MAX_VALUE;
+        return !isDone;
     }
     
     /**
@@ -101,6 +102,8 @@
                 e.printStackTrace();
             }
         }
+        // flag turned on to know when the thread stops
+        isDone = true;
     }
 
     /**

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java?rev=617721&r1=617720&r2=617721&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
Fri Feb  1 16:38:35 2008
@@ -487,6 +487,7 @@
                 running = (Boolean) mbServerConn.invoke(new ObjectName(PATH),
                         "isSnapshotRunning", new Object[] {}, new String[] {});
             } catch (Exception e) {
+                e.printStackTrace();
                 return false;
             }
         }
@@ -757,16 +758,16 @@
         }
     }
 
-    public long getSnapshotRetention() {
+    public int getSnapshotRetention() {
         if (Protocol == 1) {
 
-            return Long.parseLong(mrc.getSnapshotRetention());
+            return Integer.parseInt(mrc.getSnapshotRetention());
 
         } else {
             try {
-                return Long.parseLong((String) mbServerConn.invoke(
+                return (Integer)mbServerConn.invoke(
                         new ObjectName(PATH), "getSnapshotRetention",
-                        new Object[] {}, new String[] {}));
+                        new Object[] {}, new String[] {});
             } catch (Exception e) {
                 e.printStackTrace();
             }



Mime
View raw message