geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r598785 - in /geronimo/sandbox/monitoring/client/client-war/src/main: java/org/apache/geronimo/plugins/monitoring/client/ webapp/WEB-INF/view/
Date Tue, 27 Nov 2007 22:20:52 GMT
Author: ecraig
Date: Tue Nov 27 14:20:51 2007
New Revision: 598785

URL: http://svn.apache.org/viewvc?rev=598785&view=rev
Log:
geronimo-3637 from Viet applied after some additional changes
to dynamically determine how many points to graph based on snapshot 
duration (without this there is a possibility of a divide-by-zero error)



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/webapp/WEB-INF/view/monitoringPage.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp

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=598785&r1=598784&r2=598785&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
Tue Nov 27 14:20:51 2007
@@ -41,7 +41,7 @@
 
     }
 
-    public StatsGraph buildOneDB(int snapcount, int graph_id) throws Exception
+    public StatsGraph buildOneDB(int graph_id) throws Exception
     {
         PreparedStatement pStmt = null;
         ResultSet rsServer = null;
@@ -63,8 +63,6 @@
 
                 MRCConnection = new MRCConnector(ServerIP, rsServer
                         .getString("username"), rsServer.getString("password"));
-                // DataNameList = MRCConnection.getDataNameList();
-
             }
             else
                 return null;
@@ -76,7 +74,10 @@
             String graphName2 = rs.getString("dataname2");
             timeFrame = rs.getInt("timeframe");
 
-            snapCount = snapcount;
+            snapCount = timeFrame
+                    / java.lang.Integer
+                            .valueOf(java.lang.Long.toString((MRCConnector
+                                    .getSnapshotDuration() / new Long(60000))));
             HashMap<String, Vector<Object>> DataList = new HashMap<String,
Vector<Object>>();
 
             DataList.put(graphName1, new Vector<Object>());
@@ -85,7 +86,7 @@
             {
                 DataList.put(graphName2, new Vector<Object>());
             }
-            if ((timeFrame / 1440 == 30))
+            if ((timeFrame / 1440 >= 30))
                 snapCount = 17;
             else
             {
@@ -94,8 +95,6 @@
                 {
                     if ((timeFrame / 1440) == 7)
                         snapCount = 16;
-                    else
-                        snapCount = 12;
                 }
             }
 
@@ -120,9 +119,16 @@
             int skipCount = (int) ((timeFrame / (MRCConnector
                     .getSnapshotDuration() / 60000)))
                     / (snapCount - 2);
+            snapCount = snapCount + 2;
+            System.out.println("timeFrame is: " + timeFrame);
+            System.out.println("snapcount is: " + snapCount);
+            System.out.println("skipCount is: " + skipCount);
+            System.out.println("SnapshotDuration is: "
+                    + MRCConnector.getSnapshotDuration() / 60000);
             TreeMap<Long, Long> snapshotList = MRCConnection
                     .getSpecificStatistics(mBeanName, dataName1, snapCount,
                             skipCount);
+
             // 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/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=598785&r1=598784&r2=598785&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
Tue Nov 27 14:20:51 2007
@@ -35,7 +35,6 @@
 public class MRCConnector
 {
 
-    private static Long                      SnapshotDuration = new Long(0);
     private static MasterRemoteControlRemote mrc              = null;
 
     MRCConnector()
@@ -76,12 +75,7 @@
      */
     public static Long getSnapshotDuration() throws Exception
     {
-        if (SnapshotDuration == 0)
-        {
-            SnapshotDuration = mrc.getSnapshotDuration();
-        }
-        return SnapshotDuration;
-
+        return mrc.getSnapshotDuration();
     }
 
     /**
@@ -607,5 +601,8 @@
     {
         return mrc.getStats(MBean);
     }
-
+    
+    public static void setSnapshotDuration(long duration) {
+        mrc.setSnapshotDuration(new Long(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=598785&r1=598784&r2=598785&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
Tue Nov 27 14:20:51 2007
@@ -862,8 +862,7 @@
     }
 
     private void updateServer(ActionRequest actionRequest,
-            ActionResponse actionResponse)
-    {
+            ActionResponse actionResponse) {
         String server_id = actionRequest.getParameter("server_id");
         actionResponse.setRenderParameter("server_id", server_id);
         DBManager DBase = new DBManager();
@@ -872,12 +871,11 @@
         String ip = actionRequest.getParameter("ip");
         String password = actionRequest.getParameter("password");
         String username = actionRequest.getParameter("username");
-        try
-        {
-            if (password.equals(""))
-            {
-                PreparedStatement pStmt = con
-                        .prepareStatement("UPDATE servers SET name='"
+        String snapshot = actionRequest.getParameter("snapshot");
+        try {
+            // update the client side db (table = SERVERS)
+            if (password.equals("")) {
+                PreparedStatement pStmt = con.prepareStatement("UPDATE servers SET name='"
                                 + name
                                 + "', ip='"
                                 + ip
@@ -886,11 +884,8 @@
                                 + "', modified=CURRENT_TIMESTAMP, last_seen=CURRENT_TIMESTAMP
WHERE server_id="
                                 + server_id);
                 pStmt.executeUpdate();
-            }
-            else
-            {
-                PreparedStatement pStmt = con
-                        .prepareStatement("UPDATE servers SET name='"
+            } else {
+                PreparedStatement pStmt = con.prepareStatement("UPDATE servers SET name='"
                                 + name
                                 + "', ip='"
                                 + ip
@@ -903,19 +898,17 @@
                 pStmt.executeUpdate();
             }
             con.close();
-            actionResponse
-                    .setRenderParameter(
+            // update the server side db
+            MRCConnector.setSnapshotDuration(Long.parseLong(snapshot) * 1000 * 60);
+            // set success message
+            actionResponse.setRenderParameter(
                             "message",
                             "<font color=\"green\"><strong><li>Server has
been updated</li></strong></font>");
-            return;
-
-        }
-        catch (Exception e)
-        {
-            actionResponse.setRenderParameter("message",
+        } catch (Exception e) {
+            actionResponse.setRenderParameter(
+                    "message",
                     "<font color=\"red\"><strong><li>Error updating server</li></strong></font>"
                             + e.getMessage());
-            return;
         }
     }
 

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp?rev=598785&r1=598784&r2=598785&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
(original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp
Tue Nov 27 14:20:51 2007
@@ -49,7 +49,7 @@
     Vector <StatsGraph> graphs = new Vector<StatsGraph>();
     while (rs2.next()) {
         try {
-            StatsGraph graph = run.buildOneDB(14, rs2.getInt("graph_id"));
+            StatsGraph graph = run.buildOneDB(rs2.getInt("graph_id"));
             if(graph != null) {
                 graphs.add( graph );
             }

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=598785&r1=598784&r2=598785&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
Tue Nov 27 14:20:51 2007
@@ -62,7 +62,7 @@
 {
     try
     {
-        GraphVector.add(run.buildOneDB(14, rs.getInt("GRAPH_ID")));
+        GraphVector.add(run.buildOneDB(rs.getInt("GRAPH_ID")));
     }
  
     catch (Exception e)



Mime
View raw message