geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r599885 - in /geronimo/sandbox/monitoring: client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/ client/client-war/src/main/webapp/WEB-INF/view/ mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/
Date Fri, 30 Nov 2007 18:01:48 GMT
Author: ecraig
Date: Fri Nov 30 10:01:42 2007
New Revision: 599885

URL: http://svn.apache.org/viewvc?rev=599885&view=rev
Log:
GERONIMO-3659
monitoring client needs to allow the retention period to be configurable
Patch by Viet Nguyen


Modified:
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
    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/MasterRemoteControlRemote.java

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
Fri Nov 30 10:01:42 2007
@@ -627,4 +627,12 @@
     public void setSnapshotDuration(long duration) {
         mrc.setSnapshotDuration(new Long(duration));
     }
+    
+    public long getSnapshotRetention() {
+        return Long.parseLong(mrc.getSnapshotRetention());
+    }
+    
+    public void setSnapshotRetention(int duration) {
+        mrc.setSnapshotRetention( duration );
+    }
 }

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
Fri Nov 30 10:01:42 2007
@@ -241,6 +241,7 @@
             String password2 = actionRequest.getParameter("password2");
             String server_id = actionRequest.getParameter("server_id");
             String snapshot = actionRequest.getParameter("snapshot");
+            String retention = actionRequest.getParameter("retention");
             String message = testConnection(name, ip, username, password);
             actionResponse.setRenderParameter("message", message);
             actionResponse.setRenderParameter("name", name);
@@ -250,6 +251,7 @@
             actionResponse.setRenderParameter("password2", password2);
             actionResponse.setRenderParameter("snapshot", snapshot);
             actionResponse.setRenderParameter("server_id", server_id);
+            actionResponse.setRenderParameter("retention", retention);
         }
     }
 
@@ -538,6 +540,7 @@
                     .setAttribute("server_id", request
                             .getParameter("server_id"));
             request.setAttribute("snapshot", request.getParameter("snapshot"));
+            request.setAttribute("retention", request.getParameter("retention"));
             editServer.include(request, response);
         }
         else if(action.equals("disableEditServer") || action.equals("enableEditServer"))
@@ -668,6 +671,7 @@
         String password = actionRequest.getParameter("password");
         String username = actionRequest.getParameter("username");
         String snapshot = actionRequest.getParameter("snapshot");
+        String retention = actionRequest.getParameter("retention");
         try
         {
             // update the client side db (table = SERVERS)
@@ -703,6 +707,7 @@
             // update the server side db
             (new MRCConnector(ip, username, password)).setSnapshotDuration(Long
                     .parseLong(snapshot) * 1000 * 60);
+            (new MRCConnector(ip, username, password)).setSnapshotRetention(Integer.parseInt(retention));
             // set success message
             actionResponse
                     .setRenderParameter(

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
Fri Nov 30 10:01:42 2007
@@ -75,7 +75,7 @@
 		&& document.addServer.username.value
 		&& document.addServer.password.value ))
 	{
-		alert("Name, Address, and Username and password are all required fields");
+		alert("Name, Address, Username, and Password are all required fields");
 		return false;
 	}
 	if (document.addServer.password.value != document.addServer.password2.value)

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
Fri Nov 30 10:01:42 2007
@@ -1,3 +1,4 @@
+
 <%--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -45,6 +46,7 @@
 String password = (String) request.getAttribute("password");
 String password2 = (String) request.getAttribute("password2");
 String snapshot = (String) request.getAttribute("snapshot");
+String retention = (String) request.getAttribute("retention");
 if(message == null)
     message = "";
 if(name == null)
@@ -59,6 +61,8 @@
     password2 = "";
 if(snapshot == null)
     snapshot = "";
+if(retention == null)
+    retention = "";
 
 DBManager DBase = new DBManager();
 Connection con = DBase.getConnection();
@@ -91,8 +95,8 @@
         mrc = new MRCConnector(ip, username, password);
         // get the snapshot on the first call or any subsequent valid connections
         snapshot = snapshot == "" ?  "" + mrc.getSnapshotDuration() / 1000 / 60 : snapshot;
-      //TODO: Fix update here
-        //rs2.updateTimestamp("last_seen", new Timestamp(System.currentTimeMillis()));
+        // get the retention on the first call or any subsequent valid connection
+        retention = retention == "" ? "" + mrc.getSnapshotRetention() : retention;
     } catch (Exception e) {
         // TODO: 
         // to know if the server is online/offline, we need to give the correct credentials
@@ -203,17 +207,31 @@
       <td align="right"><input type="text" width="5" size="4" name="snapshot" onKeyUp='noAlpha(this)'
onKeyPress='noAlpha(this)' value="<%=snapshot%>"/></td>
       <td> minutes</td>
     </tr>
+    <tr>
+      <td>Snapshot Retention:</td>
+      <td>&nbsp;</td>
+      <td align="right"><input type="text" width="5" size="4" name="retention" onKeyUp='noAlpha(this)'
onKeyPress='noAlpha(this)' value="<%=retention%>"/></td>
+      <td> days</td>
+    </tr>
+
     <%
     }
     else
     {
     %>
         <tr>
-        <td>Snapshot Duration:</td>
-        <td>&nbsp;</td>
-        <td align="right"><input type="text" width="5" size="4" name="snapshot"
onKeyUp='noAlpha(this)' onKeyPress='noAlpha(this)' disabled="disabled" value="unknown"/></td>
+            <td>Snapshot Duration:</td>
+            <td>&nbsp;</td>
+            <td align="right"><input type="text" width="5" size="4" name="snapshot"
onKeyUp='noAlpha(this)' onKeyPress='noAlpha(this)' disabled="disabled" value="unknown"/></td>
         <td> minutes</td>
       </tr>
+      <tr>
+          <td>Snapshot Retention:</td>
+          <td>&nbsp;</td>
+          <td align="right"><input type="text" width="5" size="4" name="retention"
onKeyUp='noAlpha(this)' onKeyPress='noAlpha(this)' value="<%=retention%>"/></td>
+      <td> days</td>
+    </tr>
+
     <%
     }
     %>
@@ -335,4 +353,4 @@
 </table>
 <%
 }
-%>
\ No newline at end of file
+%>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
Fri Nov 30 10:01:42 2007
@@ -88,6 +88,7 @@
     String last_seen = rs.getString("last_seen").substring(0,16);
     String added = rs.getString("added").substring(0,16);
     String modified = rs.getString("modified").substring(0,16);
+    long retention = -1;
     rs.close();
     try {
         mrc = new MRCConnector(ip, username, password);
@@ -100,6 +101,7 @@
         //con.close();
         
         availableBeansMap = mrc.getFreeStatisticsProviderBeanNamesMap();
+        retention = mrc.getSnapshotRetention();
         trackedBeansMap = mrc.getTrackedBeansMap();
         snapshotDuration = (Long)mrc.getSnapshotDuration()/1000/60;
         if (mrc.isSnapshotRunning())
@@ -245,7 +247,20 @@
                                     %>
                                     <td align="right">Unknown</td>
                                     <%} %>
-                </tr>             
+                </tr>
+                <tr>
+                    <th>Snapshot Retention:</th>
+                    <td>&nbsp;</td>
+                          <%if (isOnline)
+                {%>
+                    <td align="right"><%=retention%> days</td>
+                     <%}
+                                else
+                                {
+                                    %>
+                                    <td align="right">Unknown</td>
+                                    <%} %>
+                </tr>
             </table>
             </p>
             <table>

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=599885&r1=599884&r2=599885&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
Fri Nov 30 10:01:42 2007
@@ -91,6 +91,8 @@
     private static final String GERONIMO_DEFAULT_DOMAIN = "geronimo";
     private static final Long DEFAULT_DURATION = new Long(300000);
     private static final int DEFAULT_RETENTION = 30; // 30 days
+    private static final String DURATION = "duration";
+    private static final String RETENTION = "retention";
 
     // mbean server to talk to other components
     private static MBeanServer mbServer = null;
@@ -132,97 +134,11 @@
             mbServer = MBeanServerFactory.createMBeanServer(GERONIMO_DEFAULT_DOMAIN);
         }
         
-        // set up databases
-        setUpDatabases();
-        
         // set up SnaphotDBHelper with the necessary data sources
         SnapshotDBHelper.setDataSources(activeDS, archiveDS);
     }
 
     /**
-     * Sets up the ActiveDB and ArchiveDB
-     */
-    private void setUpDatabases() {
-        setUpDatabase(activeDS, "ActiveMRCDB");
-        setUpDatabase(archiveDS, "ArchiveMRCDB");
-    }
-    
-    /**
-     * Sets up a DB using a given DS
-     * @param ds
-     */
-    private void setUpDatabase(DataSource ds, String databaseName) {
-        Connection conn = null;
-        try {
-            conn = ds.getConnection();
-            Statement stmt = conn.createStatement();
-            try {
-                // fetch all tables in the db
-                ResultSet allTablesResult = stmt.executeQuery("SELECT t.tablename FROM SYS.SYSTABLES
t WHERE t.tablename NOT LIKE 'SYS%'");
-                boolean hasTables = false;
-                // determine if there are any tables in the db
-                while(allTablesResult.next() && !hasTables) {
-                    hasTables = true;
-                }
-                // create the tables if there aren't any tables in the db
-                if( !hasTables ) {
-                    createTables(stmt);
-                }
-            } catch(Exception e) {
-                log.error(e.getMessage(), e);
-            }
-        } catch(SQLException e) {
-            log.error(e.getMessage(), e);
-        } finally {
-            try {
-                if(conn!= null) {
-                    conn.close();
-                }
-            } catch(Exception e) {
-                log.error(e.getMessage(), e);
-            }
-        }
-    }
-
-    /**
-     * Creates a Statistics table in a DB that is associated with the Statement.
-     * @param stmt
-     */
-    private void createTables(Statement stmt) {
-        try {
-            // MBeans
-            // -id
-            // -mbeanName
-            // -statsNameList
-            String tableMBeansCreate      = "CREATE TABLE MBeans(";
-            tableMBeansCreate            +=     "id INT NOT NULL GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),";
-            tableMBeansCreate            +=     "mbeanName VARCHAR(256) NOT NULL,";
-            tableMBeansCreate            +=     "statsNameList VARCHAR(512) NOT NULL,";
-            tableMBeansCreate            +=     "PRIMARY KEY(id)";
-            tableMBeansCreate            +=  ")";            
-            // Statistics
-            // -id
-            // -mbeanId (f.k. references MBeans.id)
-            // snapshot_time
-            // statsValueList
-            String tableStatisticsCreate  = "CREATE TABLE Statistics (";
-                   tableStatisticsCreate +=     "id INT NOT NULL GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),";
-                   tableStatisticsCreate +=     "mbeanId INT NOT NULL,";
-                   tableStatisticsCreate +=     "snapshot_time BIGINT NOT NULL,";
-                   tableStatisticsCreate +=     "statsValueList VARCHAR(512) NOT NULL,";

-                   tableStatisticsCreate +=     "PRIMARY KEY(id),";
-                   tableStatisticsCreate +=     "FOREIGN KEY (mbeanId) REFERENCES MBeans(id)";
-                   tableStatisticsCreate += ")";
-            stmt.executeUpdate(tableMBeansCreate);
-            log.info("MBeans Table Created");
-            stmt.executeUpdate(tableStatisticsCreate);
-            log.info("Statistics Table Created");
-        } catch(Exception e) {
-            log.error(e.getMessage(), e);
-        }
-    }
-
-    /**
      * Retrieves and instance of the MEJB and starts the snapshot process
      */
     @RolesAllowed("mejbuser")
@@ -438,7 +354,6 @@
     @RolesAllowed("mejbuser")
     public Long getSnapshotDuration() {
         // return what is stored in the snapshot-config.xml or default value
-        final String DURATION = "duration";
         try {
             String returnedDuration = SnapshotConfigXMLBuilder.getAttributeValue( DURATION
);
             return Long.parseLong( returnedDuration );
@@ -460,8 +375,18 @@
         saveDuration(snapshotDuration);
     }
     
+    @RolesAllowed("mejbuser")
     public void setSnapshotRetention(int retention) {
         saveRetention(retention);
+    }
+    
+    @RolesAllowed("mejbuser")
+    public String getSnapshotRetention() {
+        try {
+            return SnapshotConfigXMLBuilder.getAttributeValue( RETENTION );
+        } catch(Exception e) {
+            return "" + DEFAULT_RETENTION; // the default
+        }
     }
     
     @RolesAllowed("mejbuser")

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlRemote.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlRemote.java?rev=599885&r1=599884&r2=599885&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlRemote.java
(original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlRemote.java
Fri Nov 30 10:01:42 2007
@@ -72,4 +72,8 @@
     public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot);
     @RolesAllowed("mejbuser")
     public Set<String> getTrackedMBeans();
+    @RolesAllowed("mejbuser")
+    public void setSnapshotRetention(int retention);
+    @RolesAllowed("mejbuser")
+    public String getSnapshotRetention();
 }



Mime
View raw message