geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r581706 - in /geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor: MasterRemoteControl.java snapshot/SnapshotThread.java
Date Wed, 03 Oct 2007 19:47:48 GMT
Author: akulshreshtha
Date: Wed Oct  3 12:47:47 2007
New Revision: 581706

URL: http://svn.apache.org/viewvc?rev=581706&view=rev
Log:
GERONIMO-3493 Monitoring Patch by Viet

Modified:
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotThread.java

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java?rev=581706&r1=581705&r2=581706&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
(original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
Wed Oct  3 12:47:47 2007
@@ -142,6 +142,15 @@
     }
     
     /**
+     * Returns the handle of an MEJB.
+     * 
+     * @return Handle of an MEJB
+     */
+    public static MEJB getMEJB() {
+        return mejb;
+    }
+    
+    /**
      * Changes the objectName's attrName's value to attrValue
      * 
      * @param objectName

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotThread.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotThread.java?rev=581706&r1=581705&r2=581706&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotThread.java
(original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotThread.java
Wed Oct  3 12:47:47 2007
@@ -23,8 +23,10 @@
 import java.util.Set;
 
 import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
+import org.apache.geronimo.j2ee.mejb.MEJB;
 import org.apache.geronimo.monitor.snapshot.SnapshotXMLBuilder;
 import org.apache.geronimo.monitor.MasterRemoteControl;
 
@@ -93,6 +95,8 @@
         if(mbeanNames.size() <= 0) {
             mbeanNames = getDefaultMBeanList();
         }
+        // turn on all stats in the list
+        setStatsOn(mbeanNames);
         // pause the thread from running every SNAPSHOT_DURATION seconds
         while(true && SNAPSHOT_DURATION != Long.MAX_VALUE) {
             try {
@@ -127,6 +131,33 @@
                 Thread.sleep(SNAPSHOT_DURATION);
             } catch(Exception e) {
                 e.printStackTrace();
+            }
+        }
+    }
+    
+    /**
+     * Turns all statistics on for each mbean in the list.
+     * 
+     * @param mbeanList
+     */
+    private void setStatsOn(ArrayList<String> mbeanList) {
+        MEJB mejb = MasterRemoteControl.getMEJB();
+        // for each mbean name in the list
+        for(int i = 0; i < mbeanList.size(); i++) {
+            // turn the statistics collection on
+            String methodName = "setStatsOn";
+            Object[] params = new Object[] { Boolean.TRUE };
+            String[] signatures = new String[] { "java.lang.Boolean" };
+            try {
+                ObjectName objName = new ObjectName(mbeanList.get(i));
+                mejb.invoke(objName, methodName, params, signatures);
+                System.out.println("Stats for " + mbeanList.get(i) + " was turned on.");
+            } catch(MalformedObjectNameException e) {
+                e.printStackTrace();
+            } catch(Exception e) {
+                // an exception will be thrown if the methodName is not found for this class,
+                // which is very possible.
+                System.out.println("Could not turn on stats for " + mbeanList.get(i));
             }
         }
     }



Mime
View raw message