geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r600692 - in /geronimo/sandbox/monitoring: client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/ client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/ client/client-war/src/main/webapp/...
Date Mon, 03 Dec 2007 21:16:57 GMT
Author: ecraig
Date: Mon Dec  3 13:16:49 2007
New Revision: 600692

URL: http://svn.apache.org/viewvc?rev=600692&view=rev
Log:
GERONIMO-3666
monitoring plugin to provide for a way to access archive data
Patch by Viet Nguyen.



Removed:
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/SMP.java
Modified:
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
    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/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.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/MasterRemoteControlLocal.java
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlRemote.java
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotDBHelper.java

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
Mon Dec  3 13:16:49 2007
@@ -69,6 +69,7 @@
             String color = rs.getString("color");
             float warninglevel1 = rs.getFloat("warninglevel1");
             String description = rs.getString("description");
+            boolean showArchive = rs.getInt("archive") == 1 ? true : false;
             
             pStmt = con.prepareStatement("SELECT * from servers WHERE enabled=1 AND server_id="
+ server_id);
             rsServer = pStmt.executeQuery();
@@ -127,8 +128,7 @@
                 int skipCount = (int) ((timeFrame / (mrc.getSnapshotDuration() / 60000)))
/ (snapCount - 2);
                 snapCount = snapCount + 2;
                 TreeMap<Long, Long> snapshotList = mrc
-                        .getSpecificStatistics(mBeanName, dataName1, snapCount, skipCount);
-
+                        .getSpecificStatistics(mBeanName, dataName1, snapCount, skipCount,
showArchive);
                 // Check if snapshotList is empty
                 if (snapshotList.size() == 0) {
                     snapshotList.put(System.currentTimeMillis(), new Long(0));

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=600692&r1=600691&r2=600692&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
Mon Dec  3 13:16:49 2007
@@ -305,10 +305,10 @@
 
     @SuppressWarnings("unchecked")
     public TreeMap<Long, Long> getSpecificStatistics(String mbeanName,
-            String statsName, int snapCount, int skipCount) throws Exception
+            String statsName, int snapCount, int skipCount, boolean showArchive) throws Exception
     {
         TreeMap<Long, Long> snapshotList = mrc.getSpecificStatistics(mbeanName,
-                statsName, snapCount, skipCount);
+                statsName, snapCount, skipCount, showArchive);
         // Check if snapshotList is empty
         if (snapshotList.size() == 0)
         {

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=600692&r1=600691&r2=600692&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
Mon Dec  3 13:16:49 2007
@@ -844,6 +844,11 @@
         String dataname1 = actionRequest.getParameter("dataname1");
         String data1operation = actionRequest.getParameter("data1operation");
         String operation = actionRequest.getParameter("operation");
+        int showArchive = 0;
+        if(actionRequest.getParameter("showArchive") != null && actionRequest.getParameter("showArchive").equals("on"))
{
+            showArchive = 1;
+        }
+
         if (operation.equals("other"))
         {
             operation = actionRequest.getParameter("othermath");
@@ -855,7 +860,7 @@
         try
         {
             PreparedStatement pStmt = con
-                    .prepareStatement("INSERT INTO graphs (server_id, name, description,
timeframe, mbean, dataname1, xlabel, ylabel, data1operation, operation, data2operation, dataname2,
warninglevel1, warninglevel2, added, modified, last_seen) VALUES ("
+                    .prepareStatement("INSERT INTO graphs (server_id, name, description,
timeframe, mbean, dataname1, xlabel, ylabel, data1operation, operation, data2operation, dataname2,
warninglevel1, warninglevel2, added, modified, last_seen, archive) VALUES ("
                             + server_id
                             + ",'"
                             + name
@@ -879,7 +884,7 @@
                             + data2operation
                             + "','"
                             + dataname2
-                            + "',0,0,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
+                            + "',0,0,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,"
+ showArchive + ")" );
             pStmt.executeUpdate();
             con.close();
             actionResponse.setRenderParameter("message",
@@ -915,6 +920,11 @@
         String dataname1 = actionRequest.getParameter("dataname1");
         String data1operation = actionRequest.getParameter("data1operation");
         String operation = actionRequest.getParameter("operation");
+        int archive = 0;
+        if(actionRequest.getParameter("showArchive") != null && actionRequest.getParameter("showArchive").equals("on"))
{
+            archive = 1;
+        }
+
         if (operation.equals("other"))
         {
             operation = actionRequest.getParameter("othermath");
@@ -950,7 +960,7 @@
                             + data2operation
                             + "', dataname2='"
                             + dataname2
-                            + "', warninglevel1=0, warninglevel2=0, modified=CURRENT_TIMESTAMP
WHERE graph_id="
+                            + "', warninglevel1=0, warninglevel2=0, modified=CURRENT_TIMESTAMP,
archive=" + archive + " WHERE graph_id="
                             + graph_id);
             pStmt.executeUpdate();
             con.close();

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
Mon Dec  3 13:16:49 2007
@@ -141,6 +141,7 @@
                             + "last_js     LONG VARCHAR DEFAULT NULL,"
                             + "added       TIMESTAMP NOT NULL,"
                             + "modified    TIMESTAMP NOT NULL,"
+                            + "archive     SMALLINT NOT NULL DEFAULT 0,"
                             + "last_seen   TIMESTAMP NOT NULL" + ")");
             pStmt.executeUpdate();
             pStmt = con
@@ -173,7 +174,7 @@
                             + "'time'," + "'Tomcat Web KBytes/Sec Sent',"
                             + "'KBps'," + "500.0," + "1024.0," + "DEFAULT,"
                             + "DEFAULT," + "CURRENT_TIMESTAMP,"
-                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP" + ")");
+                            + "CURRENT_TIMESTAMP,0," + "CURRENT_TIMESTAMP" + ")");
             pStmt.executeUpdate();
             pStmt = con
                     .prepareStatement("INSERT INTO graphs VALUES("
@@ -188,7 +189,7 @@
                             + "'D'," + "'time',"
                             + "'Tomcat Web KBytes/Sec Received'," + "'KBps',"
                             + "500.0," + "1024.0," + "DEFAULT," + "DEFAULT,"
-                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP,"
+                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP,0,"
                             + "CURRENT_TIMESTAMP" + ")");
             pStmt.executeUpdate();
             pStmt = con
@@ -205,7 +206,7 @@
                             + "'Tomcat Request Time/Second',"
                             + "'RequestTime'," + "500.0," + "1024.0,"
                             + "DEFAULT," + "DEFAULT," + "CURRENT_TIMESTAMP,"
-                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP" + ")");
+                            + "CURRENT_TIMESTAMP,0," + "CURRENT_TIMESTAMP" + ")");
             pStmt.executeUpdate();
             pStmt = con
                     .prepareStatement("INSERT INTO graphs VALUES("
@@ -219,7 +220,7 @@
                             + "'D'," + "'Error Count'," + "'/'," + "'D',"
                             + "'time'," + "'Error Count/Sec'," + "'Errors',"
                             + "500.0," + "1024.0," + "DEFAULT," + "DEFAULT,"
-                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP,"
+                            + "CURRENT_TIMESTAMP," + "CURRENT_TIMESTAMP,0,"
                             + "CURRENT_TIMESTAMP" + ")");
             pStmt.executeUpdate();
             pStmt = con.prepareStatement("INSERT INTO views VALUES("

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
Mon Dec  3 13:16:49 2007
@@ -509,6 +509,14 @@
       </td>
       <td></td>
     </tr>
+    <tr>
+        <td></td>
+        <td>&nbsp;</td>
+        <td align="right">
+            <input type="checkbox" name="showArchive">Show Archived</input>
+        </td>
+        <td></td>
+    </tr>
     <tr><td>Graphing: </td><td colspan="2"><strong><span
id="formulaData1operation"></span> <span id="formulaDataname1"></span>
<span id="formulaOperation"></span> <span id="formulaData2operation"></span>
<span id="formulaDataname2"></span></strong></td></tr>
     <tr><td colspan="3"><font size="-2">&nbsp;</font></td></tr>
     <tr>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
Mon Dec  3 13:16:49 2007
@@ -72,6 +72,7 @@
     String added = rs.getString("added").substring(0,16);
     String modified = rs.getString("modified").substring(0,16);
     String last_seen = rs.getString("last_seen").substring(0,16);
+    boolean archive = rs.getInt("archive") == 1 ? true : false;
     rs.close();
 
 pStmt = con.prepareStatement("SELECT * FROM servers WHERE enabled=1");
@@ -572,6 +573,18 @@
       </script>
       </td>
       <td></td>
+    </tr>
+    <tr>
+        <td></td>
+        <td></td>
+        <td>
+            <% if(archive) { %>
+                <input type="checkbox" name="showArchive" checked>Show Archive</input>
+            <% } else { %>
+                <input type="checkbox" name="showArchive">Show Archive</input>
+            <% } %>
+        </td>
+        <td></td>
     </tr>
     <tr><td>Graphing: </td><td colspan="2"><strong><span
id="formulaData1operation"></span> <span id="formulaDataname1"></span>
<span id="formulaOperation"></span> <span id="formulaData2operation"></span>
<span id="formulaDataname2"></span></strong></td></tr>
     <tr><td colspan="3"><font size="-2">&nbsp;</font></td></tr>

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=600692&r1=600691&r2=600692&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
Mon Dec  3 13:16:49 2007
@@ -532,8 +532,12 @@
      * @return HashMap which maps from a snapshot_time --> value of the mbean.statsName
at that time
      */
     @RolesAllowed("mejbuser")
-    public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot) {
-        return SnapshotDBHelper.getSpecificStatistics(mbeanName, statsName, numberOfSnapshots,
everyNthSnapshot);
+    public TreeMap<Long, Long> getSpecificStatistics(   String mbeanName,
+                                                        String statsName, 
+                                                        int numberOfSnapshots, 
+                                                        int everyNthSnapshot,
+                                                        boolean showArchived) {
+        return SnapshotDBHelper.getSpecificStatistics(mbeanName, statsName, numberOfSnapshots,
everyNthSnapshot, showArchived);
     }
     
     /**

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlLocal.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlLocal.java?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlLocal.java
(original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControlLocal.java
Mon Dec  3 13:16:49 2007
@@ -69,7 +69,7 @@
     @RolesAllowed("mejbadmin")
     public Object invoke(ObjectName name, String operationName, Object[] params, String[]
signature);
     @RolesAllowed("mejbuser")
-    public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot);
+    public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot, boolean showArchive);
     @RolesAllowed("mejbuser")
     public Set<String> getTrackedMBeans();
     @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=600692&r1=600691&r2=600692&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
Mon Dec  3 13:16:49 2007
@@ -69,7 +69,7 @@
     @RolesAllowed("mejbadmin")
     public Object invoke(ObjectName name, String operationName, Object[] params, String[]
signature);
     @RolesAllowed("mejbuser")
-    public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot);
+    public TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String statsName,
int numberOfSnapshots, int everyNthSnapshot, boolean showArchive);
     @RolesAllowed("mejbuser")
     public Set<String> getTrackedMBeans();
     @RolesAllowed("mejbuser")

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotDBHelper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotDBHelper.java?rev=600692&r1=600691&r2=600692&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotDBHelper.java
(original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotDBHelper.java
Mon Dec  3 13:16:49 2007
@@ -573,9 +573,15 @@
      * @param everyNthSnapshot
      * @return HashMap which maps from a snapshot_time --> value of the mbean.statsName
at that time
      */
-    public static TreeMap<Long, Long> getSpecificStatistics(String mbeanName, String
statsName, int numberOfSnapshots, int everyNthSnapshot) {
+    public static TreeMap<Long, Long> getSpecificStatistics(    String mbeanName, 
+                                                                String statsName, 
+                                                                int numberOfSnapshots, 
+                                                                int everyNthSnapshot, 
+                                                                boolean showArchived) {
         openActiveConnection();
         TreeMap<Long, Long> stats = new TreeMap<Long, Long>();
+        int nthSnapshot = 0;
+        // attempt to get as many snapshots from the active db as possible
         try {
             Statement stmt = conn.createStatement();
             int mbeanId = getMBeanId(mbeanName);
@@ -584,7 +590,6 @@
             } else {
                 String query = "SELECT DISTINCT snapshot_time, statsValueList, statsNameList
FROM Statistics, MBeans M WHERE mbeanId=" + mbeanId + " AND mbeanId=M.id ORDER BY snapshot_time
DESC";
                 ResultSet rs = stmt.executeQuery(query);
-                int nthSnapshot = 0;
                 // iterate through the table paying attention to those at everyNthSnapshot-th
position
                 while(rs.next()) {
                     // every nth snapshot I save the information into my returning hashmap
@@ -620,6 +625,58 @@
             log.error(e.getMessage(), e);
         } finally {
             closeConnection();
+        }
+
+        nthSnapshot = 0;
+
+        // attempt to get the remaining snapshots requested from the archive DB
+        // iff the showArchive flag is set
+        if(showArchived && numberOfSnapshots != 0) {
+            try {
+                openArchiveConnection();    // connection to the Archive DB
+                Statement stmt = conn.createStatement();
+                int mbeanId = getMBeanId(mbeanName);
+                if(mbeanId == -1) {
+                    log.error(mbeanName + " does not exist in the database.");
+                } else {
+                    String query = "SELECT DISTINCT snapshot_time, statsValueList, statsNameList
FROM Statistics, MBeans M WHERE mbeanId=" + mbeanId + " AND mbeanId=M.id ORDER BY snapshot_time
DESC";
+                    ResultSet rs = stmt.executeQuery(query);
+                    // iterate through the table paying attention to those at everyNthSnapshot-th
position
+                    while(rs.next()) {
+                        // every nth snapshot I save the information into my returning hashmap
+                        if(nthSnapshot % everyNthSnapshot == 0) {
+                            String[] statsValueList = rs.getString(STATSVALUELIST).split(",");
+                            String[] statsNameList = rs.getString(STATSNAMELIST).split(",");
+                            assert(statsValueList.length == statsNameList.length);
+                            Long statsValue = null;
+                            for(int i = 0 ; i < statsNameList.length; i++) {
+                                if(statsNameList[i].equals(statsName)) {
+                                    long value = Long.parseLong(statsValueList[i]);
+                                    statsValue = new Long(value);
+                                }
+                            }
+                            // exit function after error
+                            if(statsValue == null) {
+                                log.warn("Statistics name '" + statsName + "' does not exist");
+                                return stats;
+                            } else {
+                                stats.put(rs.getLong(SNAPSHOT_TIME), statsValue);
+                                numberOfSnapshots--;
+                            }
+                        }
+                        // update counter
+                        nthSnapshot++;
+                        // enough data, end this thing
+                        if(numberOfSnapshots == 0) {
+                            break;
+                        }
+                    }
+                }
+            } catch(Exception e) {
+                log.error(e.getMessage(), e);
+            } finally {
+                closeConnection();
+            }
         }
         return stats;
     }



Mime
View raw message