geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r618493 - in /geronimo/server/branches/2.1/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/monitorin...
Date Mon, 04 Feb 2008 23:46:37 GMT
Author: ecraig
Date: Mon Feb  4 15:46:26 2008
New Revision: 618493

URL: http://svn.apache.org/viewvc?rev=618493&view=rev
Log:
Changed monitoring agent-jmx and mconsole such that while the thread shutdown is pending,
the user is aware of it

Modified:
    geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
    geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
    geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
    geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
    geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
    geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp

Modified: geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/MasterRemoteControlJMX.java
Mon Feb  4 15:46:26 2008
@@ -295,7 +295,7 @@
      * @param interval
      */
     public boolean startSnapshot(Long interval, Integer retention) {
-        if((snapshotThread == null || (snapshotThread != null && !snapshotThread.isSnapshotRunning()))
&& interval.longValue() > 0) {
+        if((snapshotThread == null || (snapshotThread != null && (snapshotThread.SnapshotStatus()
== 0))) && interval.longValue() > 0) {
             saveDuration(interval.longValue());
             saveRetention(retention.intValue());
             snapshotThread = new SnapshotThread(interval.longValue(), mbServer);
@@ -356,7 +356,7 @@
      * Executes when the GBean stops. Also stops the snapshot thread.
      */
     public void doStop() {
-        if(isSnapshotRunning()) {
+        if(SnapshotStatus() == 1) {
             stopSnapshot();
         }
     }
@@ -475,12 +475,12 @@
     /**
      * @return Returns true if snapshot is running.
      */
-    public boolean isSnapshotRunning() {
+    public Integer SnapshotStatus() {
         // TODO: check if the snapshot thread is running 
         if(snapshotThread == null) {
-            return false;
+            return 0;
         } else {
-            return snapshotThread.isSnapshotRunning();
+            return snapshotThread.SnapshotStatus();
         }
     }
 
@@ -506,7 +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.addOperation("SnapshotStatus", new Class[] {}, "Integer");
         infoFactory.addOperation("getSpecificStatistics", new Class[] {String.class, String.class,
Integer.class, Integer.class, Boolean.class}, "TreeMap");
         infoFactory.addOperation("getTrackedMBeans", new Class[] {}, "Set");
         infoFactory.setConstructor(new String[] {});

Modified: geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/agent-jmx/src/main/java/org/apache/geronimo/monitoring/snapshot/SnapshotThread.java
Mon Feb  4 15:46:26 2008
@@ -34,16 +34,16 @@
 
     private long SNAPSHOT_DURATION;
     private MBeanServer mbServer = null;
-    boolean isDone = false;
+    int threadStatus = 1;
     // list of mbean names that we will be taking snapshots of
     private ArrayList<String> mbeanNames;
-    
+
     public SnapshotThread(long snapshot_length, MBeanServer mbServer) {
         SNAPSHOT_DURATION = snapshot_length;
         this.mbServer = mbServer;
         mbeanNames = new ArrayList<String>();
     }
-    
+
     /**
      * Gets the elapsed time in milliseconds between each snapshot.
      * 
@@ -53,13 +53,15 @@
         return SNAPSHOT_DURATION;
     }
 
-    public boolean isSnapshotRunning() {
-        return !isDone;
+    public Integer SnapshotStatus() {
+        return threadStatus;
+
     }
-    
+
     /**
      * Adds the mbean name to list in memory. To update the snapshot-config.xml
      * coder must use SnapshotConfigXMLBuilder class.
+     * 
      * @param mbeanName
      */
     public void addMBeanForSnapshot(String mbeanName) {
@@ -67,14 +69,15 @@
     }
 
     /**
-     * Removes the mbean name to list in memory. To update the snapshot-config.xml
-     * coder must use SnapshotConfigXMLBuilder class.
+     * Removes the mbean name to list in memory. To update the
+     * snapshot-config.xml coder must use SnapshotConfigXMLBuilder class.
+     * 
      * @param mbeanName
      */
     public void removeMBeanForSnapshot(String mbeanName) {
         mbeanNames.remove(mbeanName);
     }
-    
+
     /**
      * Sets the elapsed time in milliseconds between each snapshot.
      * 
@@ -82,42 +85,46 @@
      */
     public void setSnapshotDuration(long snapshot_length) {
         SNAPSHOT_DURATION = snapshot_length;
+        if (snapshot_length == Long.MAX_VALUE)
+            threadStatus = -1;
     }
 
     public void run() {
         // get any saved mbean names from snapshot-config.xml
         mbeanNames = SnapshotConfigXMLBuilder.getMBeanNames();
         // in the case where nothing is present, grab a set of default mbeans
-        if(mbeanNames.size() <= 0) {
+        if (mbeanNames.size() <= 0) {
             mbeanNames = getDefaultMBeanList();
         }
         // pause the thread from running every SNAPSHOT_DURATION seconds
-        while(true && SNAPSHOT_DURATION != Long.MAX_VALUE) {
+        while (true && SNAPSHOT_DURATION != Long.MAX_VALUE) {
             try {
                 // store the data
                 SnapshotProcessor.takeSnapshot();
                 // wait for next snapshot
                 Thread.sleep(SNAPSHOT_DURATION);
-            } catch(Exception e) {
+            } catch (Exception e) {
                 e.printStackTrace();
             }
         }
         // flag turned on to know when the thread stops
-        isDone = true;
+        threadStatus = 0;
     }
 
     /**
-     * @return A list of all default mbeans; namely, all connector or container mbean names
-     * Prereq: in order to be a connector or container mbean the name must contain "Connector"/"Container"

-     * and "Tomcat"/"Jetty"
+     * @return A list of all default mbeans; namely, all connector or container
+     *         mbean names Prereq: in order to be a connector or container mbean
+     *         the name must contain "Connector"/"Container" and
+     *         "Tomcat"/"Jetty"
      */
     private ArrayList<String> getDefaultMBeanList() {
-        Set<String> mbeans = (new MasterRemoteControlJMX()).getStatisticsProviderMBeanNames();
+        Set<String> mbeans = (new MasterRemoteControlJMX())
+                .getStatisticsProviderMBeanNames();
         ArrayList<String> retval = new ArrayList<String>();
-        for(Iterator it = mbeans.iterator(); it.hasNext(); ) {
-            String name = (String)it.next();
-            if((name.contains("Connector") || name.contains("Container")) &&
-                    (name.contains("Jetty") || name.contains("Tomcat"))) {
+        for (Iterator it = mbeans.iterator(); it.hasNext();) {
+            String name = (String) it.next();
+            if ((name.contains("Connector") || name.contains("Container"))
+                    && (name.contains("Jetty") || name.contains("Tomcat"))) {
                 // this is a connector, so add to the list
                 retval.add(name);
                 // update the snapshot-config.xml to include these

Modified: geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
Mon Feb  4 15:46:26 2008
@@ -472,23 +472,24 @@
         }
     }
 
-    public boolean isSnapshotRunning() {
-        boolean running = false;
+    public int isSnapshotRunning() {
+        Integer running = 0;
         if (Protocol == 1) {
 
             try {
-                running = mrc.isSnapshotRunning();
+                if (mrc.isSnapshotRunning())
+                    running = 1;
             } catch (Exception e) {
-                return false;
+                return 0;
             }
 
         } else {
             try {
-                running = (Boolean) mbServerConn.invoke(new ObjectName(PATH),
-                        "isSnapshotRunning", new Object[] {}, new String[] {});
+                running = (Integer) mbServerConn.invoke(new ObjectName(PATH),
+                        "SnapshotStatus", new Object[] {}, new String[] {});
             } catch (Exception e) {
                 e.printStackTrace();
-                return false;
+                return 0;
             }
         }
         return running;
@@ -765,9 +766,9 @@
 
         } else {
             try {
-                return (Integer)mbServerConn.invoke(
-                        new ObjectName(PATH), "getSnapshotRetention",
-                        new Object[] {}, new String[] {});
+                return (Integer) mbServerConn.invoke(new ObjectName(PATH),
+                        "getSnapshotRetention", new Object[] {},
+                        new String[] {});
             } catch (Exception e) {
                 e.printStackTrace();
             }

Modified: geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
Mon Feb  4 15:46:26 2008
@@ -128,7 +128,7 @@
      boolean enabled = serverInfos.get(i).enabled;
      String name = serverInfos.get(i).name;
      boolean online = false;
-     boolean collecting = false;
+     Integer collecting = 0;
      MRCConnector mrc = null;
      Long snapshotDuration = new Long(0);
      if (enabled) {
@@ -140,12 +140,9 @@
 	     }
 	     try {
 	         snapshotDuration = mrc.getSnapshotDuration();
-	         if (mrc.isSnapshotRunning())
-	             collecting = true;
-	         else
-	             collecting = false;
+	         collecting = mrc.isSnapshotRunning();
 	     } catch (Exception e) {
-	         collecting = false;
+	         collecting = 0;
 	         online = false;
 	     }
      }
@@ -186,7 +183,7 @@
        <td class="${backgroundClass}" width="15%" align="center"><font color="red">Disabled</font></td>
      <%
      }
-if (!collecting) {  // not collecting statistics
+if (collecting == 0) {  // not collecting statistics
 %>
     <td class="${backgroundClass}" width="15%" align="center"><font color="red">(stopped)</font></td>
 <%
@@ -196,13 +193,31 @@
 <%
     } else {        // do not provide links
 %>
-        <td class="${backgroundClass}" width="10%" align="center">Enable Query</td>
+        <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/max-b.png">Enable Query</td>
 <%
     }
 %>
   <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
 <%
-} else {            // collecting statistics
+}
+else if (collecting == -1) {  // not collecting statistics
+    %>
+        <td class="${backgroundClass}" width="15%" align="center"><font color="red">Stopping...</font></td>
+    <%
+        if(enabled) {   // enable the links
+    %>
+            <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/close-b.png">Disable Query</td>
+    <%
+        } else {        // do not provide links
+    %>
+            <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/close-b.png">Disable Query</td>
+    <%
+        }
+    %>
+      <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
+    <%
+    }
+else {            // collecting statistics
     if (enabled)
     {
 %>
@@ -215,7 +230,7 @@
     {
         %>
         <td class="${backgroundClass}" width="15%" align="center">Stopped</td>
-        <td class="${backgroundClass}" width="10%" align="center">Disable Query</td>
+        <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/close-b.png">Disable Query</td>
         <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
       <%        
     }

Modified: geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
Mon Feb  4 15:46:26 2008
@@ -93,7 +93,7 @@
      boolean enabled = serverInfos.get(i).enabled;
      String name = serverInfos.get(i).name;
      boolean online = false;
-     boolean collecting = false;
+     Integer collecting = 0;
      MRCConnector mrc = null;
      Long snapshotDuration = new Long(0);
      if (enabled) {
@@ -105,12 +105,9 @@
 	     }
 	     try {
 	         snapshotDuration = mrc.getSnapshotDuration();
-	         if (mrc.isSnapshotRunning())
-	             collecting = true;
-	         else
-	             collecting = false;
+	         collecting = mrc.isSnapshotRunning();
 	     } catch (Exception e) {
-	         collecting = false;
+	         collecting = 0;
 	         online = false;
 	     }
      }
@@ -151,7 +148,7 @@
        <td class="${backgroundClass}" width="15%" align="center"><font color="red">Disabled</font></td>
      <%
      }
-if (!collecting) {  // not collecting statistics
+if (collecting == 0) {  // not collecting statistics
 %>
     <td class="${backgroundClass}" width="15%" align="center"><font color="red">(stopped)</font></td>
 <%
@@ -161,13 +158,31 @@
 <%
     } else {        // do not provide links
 %>
-        <td class="${backgroundClass}" width="10%" align="center">Enable Query</td>
+        <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/max-b.png">Enable Query</td>
 <%
     }
 %>
   <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
 <%
-} else {            // collecting statistics
+} 
+else if (collecting == -1) {  // not collecting statistics
+    %>
+        <td class="${backgroundClass}" width="15%" align="center"><font color="red">Stopping...</font></td>
+    <%
+        if(enabled) {   // enable the links
+    %>
+            <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/close-b.png">Disable Query</td>
+    <%
+        } else {        // do not provide links
+    %>
+            <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/max-b.png">Enable Query</td>
+    <%
+        }
+    %>
+      <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
+    <%
+    }
+else {            // collecting statistics
     if (enabled)
     {
 %>
@@ -180,7 +195,7 @@
     {
         %>
         <td class="${backgroundClass}" width="15%" align="center">Stopped</td>
-        <td class="${backgroundClass}" width="10%" align="center">Disable Query</td>
+        <td class="${backgroundClass}" width="10%" align="center"><img border=0
src="/monitoring/images/close-b.png">Disable Query</td>
         <td class="${backgroundClass}" width="10%" align="center"><a href="<portlet:actionURL
portletMode="edit"><portlet:param name="action" value="showEditServer" /><portlet:param
name="server_id" value="<%=server_id%>" /></portlet:actionURL>"><img
border=0 src="/monitoring/images/edit-b.png">Edit</a></td>
       <%        
     }

Modified: geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp?rev=618493&r1=618492&r2=618493&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
(original)
+++ geronimo/server/branches/2.1/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
Mon Feb  4 15:46:26 2008
@@ -46,7 +46,7 @@
 MRCConnector mrc = null;
 
 boolean isOnline = true;
-boolean collecting = false;
+Integer collecting = 0;
 Long snapshotDuration = new Long(0);
 
 if (message == null)
@@ -77,13 +77,10 @@
         retention = mrc.getSnapshotRetention();
         trackedBeansMap = mrc.getTrackedBeansMap();
         snapshotDuration = (Long)mrc.getSnapshotDuration()/1000/60;
-        if (mrc.isSnapshotRunning())
-            collecting = true;
-        else
-            collecting = false;
+        collecting = mrc.isSnapshotRunning();
     } catch (Exception e) {
         isOnline = false;
-        collecting = false;
+        collecting = 0;
         message = message + "<br><font color='red'><strong><li>Server
is offline</li></strong></font>";
     }
     
@@ -138,7 +135,7 @@
                     <th align="left">Snapshot Thread:</th>
                     <td>&nbsp;</td>
                     <td align="right">
-                                <%if (isOnline && collecting)
+                                <%if (isOnline && collecting == 1)
                 {%>
                     Running
                    <%}
@@ -292,15 +289,20 @@
                         <li><a href="<portlet:actionURL portletMode="edit"><portlet:param
name="action" value="disableServer" /><portlet:param name="server_id" value="<%=server_id%>"
/></portlet:actionURL>">Disable this server</a></li>
                         <li><a href="<portlet:actionURL portletMode="edit"><portlet:param
name="action" value="showAddServer" /></portlet:actionURL>">Add a new server</a></li>
                         <%
-                        if(collecting) {
+                        if(collecting == 1) {
                         %>
                             <li><a href="<portlet:actionURL portletMode="view"><portlet:param
name="action" value="disableServerViewQuery" /><portlet:param name="server_id" value="<%=server_id%>"
/></portlet:actionURL>">Disable Query</a></li>
                         <%
-                        } else {
+                        } else if (collecting == 0){
                         %>
                             <li><a href="<portlet:actionURL portletMode="view"><portlet:param
name="action" value="enableServerViewQuery" /><portlet:param name="server_id" value="<%=server_id%>"
/><portlet:param name="snapshotDuration" value="<%= "" + (snapshotDuration * 1000
* 60) %>" /></portlet:actionURL>">Enable Query</a></li>
                         <%
                         }
+                        else if (collecting == -1){
+                            %>
+                                <li>Stopping Thread...</li>
+                            <%
+                            }
                         %>
                         </ul>
                         &nbsp;<br />



Mime
View raw message