geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r583038 [1/2] - in /geronimo/sandbox/monitoring/client: client-ear/src/main/resources/ client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/ client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/ clie...
Date Tue, 09 Oct 2007 03:27:26 GMT
Author: akulshreshtha
Date: Mon Oct  8 20:27:25 2007
New Revision: 583038

URL: http://svn.apache.org/viewvc?rev=583038&view=rev
Log:
GERONIMO-3517 Monitoring Client Patch by Eric B. Craig

Added:
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEdit.jsp   (with props)
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp   (with props)
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringPage.jsp   (with props)
Modified:
    geronimo/sandbox/monitoring/client/client-ear/src/main/resources/MonitoringClientDB.sql
    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/StatsGraph.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/geronimo-web.xml
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/portlet.xml
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringHelp.jsp

Modified: geronimo/sandbox/monitoring/client/client-ear/src/main/resources/MonitoringClientDB.sql
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-ear/src/main/resources/MonitoringClientDB.sql?rev=583038&r1=583037&r2=583038&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-ear/src/main/resources/MonitoringClientDB.sql (original)
+++ geronimo/sandbox/monitoring/client/client-ear/src/main/resources/MonitoringClientDB.sql Mon Oct  8 20:27:25 2007
@@ -1,11 +1,196 @@
-CREATE TABLE mrc_servers(
-    server_id   INTEGER PRIMARY KEY,
-    server_ip   VARCHAR(15),
-    username    VARCHAR(128),
-    password    VARCHAR(1024)
-);
-
-INSERT INTO mrc_servers VALUES('0', '127.0.0.1', 'system', 'manager');
-INSERT INTO mrc_servers VALUES('1', '127.0.0.2', 'system', 'manager');
-INSERT INTO mrc_servers VALUES('2', '127.0.0.3', 'system', 'manager');
+/*
+ * server_id        ID number for server - auto generated
+ * enabled          Enable/disable this server - defaults to 1
+ * name             Name for this server - alphanum
+ * ip               IP address of this server
+ * username         username to use for connecting
+ * password         password to use for connecting
+ * added            Timestamp when this server was added
+ * modified         Timestamp when this record was changed
+ * last_seen        Timestamp when this server was last seen
+ */
+CREATE TABLE servers(
+    server_id   INTEGER PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),
+    enabled SMALLINT DEFAULT 1 NOT NULL,
+    name VARCHAR(128) DEFAULT NULL,
+    ip   VARCHAR(15) UNIQUE NOT NULL,
+    username    VARCHAR(128) NOT NULL,
+    password    VARCHAR(1024) NOT NULL,
+    added       TIMESTAMP NOT NULL,
+    modified    TIMESTAMP NOT NULL,
+    last_seen   TIMESTAMP NOT NULL
+);
+/*
+ * graph_id         Id number for graph - auto generated
+ * enabled          Enable/disable display of graph defaults 1
+ * server_id        server id graph is associated with
+ * name             name for graph - alphanumeric for js.
+ * description      Description for the graph
+ * timeframe        Timeframe for graph in minutes, defaults to 60
+ * mbean            Mbean for graph
+ * data1operation   Operation to be performed on data 1
+ *                  D indicates delta (subtracts i-1 from i)
+ * dataname1        Stats name for data1
+ * operation        Operation between data1 and 2 done in JS
+ *                  Simple math.. for example.. /10/ would divide data1 by 10, then divide result by data2
+ *                  Simply / would divide data1 by data2
+ * data2operation   Operation to be performed on data 2
+ *                  D indicates delta (subtracts i-1 from i)
+ * dataname2        Name for data2
+ * xlabel           xLabel at the bottom of the graph
+ * ylabel           yLabel on the side of the graph
+ * warninglevel1    Level at which graph turns to yellow (float)
+ * warninglevel2    Level at which graph turns to red (float)
+ * color            Default color of the graph
+ * last_js          Most recently generated JS source
+ * added            Timestamp when this graph was added
+ * modified         Timestamp when this graph was last changed
+ * last_seen        Timestamp when this graph was last generated
+ */
+CREATE TABLE graphs(
+    graph_id    INTEGER PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),
+    enabled     SMALLINT NOT NULL DEFAULT 1,
+    server_id   INTEGER NOT NULL DEFAULT 0,
+    name        VARCHAR(64) UNIQUE NOT NULL,
+    description LONG VARCHAR DEFAULT NULL,
+    timeframe   INTEGER NOT NULL DEFAULT 60,
+    mbean       VARCHAR(512) NOT NULL,
+    data1operation  CHAR DEFAULT NULL,
+    dataname1   VARCHAR(128) NOT NULL,
+    operation   VARCHAR(128) DEFAULT NULL,
+    data2operation  CHAR DEFAULT NULL,
+    dataname2   VARCHAR(128) DEFAULT NULL,
+    xlabel      VARCHAR(128) DEFAULT NULL,
+    ylabel      VARCHAR(128) DEFAULT NULL,
+    warninglevel1   FLOAT DEFAULT NULL,
+    warninglevel2   FLOAT DEFAULT NULL,
+    color       VARCHAR(6) NOT NULL DEFAULT '1176c2',
+    last_js     LONG VARCHAR DEFAULT NULL,
+    added       TIMESTAMP NOT NULL,
+    modified    TIMESTAMP NOT NULL,
+    last_seen   TIMESTAMP NOT NULL
+);
+/*
+ * view_id          ID number for the view, auto generated
+ * enabled          Enable or disable of showing this view defaults 1
+ * name             Name for this view
+ * description      Longer description for this view
+ * graph_count      Number of graphs in this view
+ * graph_ids        Id numbers for graphs in this view
+ * added            Timestamp when this was created
+ * modified         Timestamp when this was last changed
+ */
+CREATE TABLE views(
+    view_id     INTEGER PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),
+    enabled     SMALLINT NOT NULL DEFAULT 1,
+    name        VARCHAR(128) NOT NULL,
+    description LONG VARCHAR DEFAULT NULL,
+    graph_count INTEGER NOT NULL DEFAULT 0,
+    graph_ids   LONG VARCHAR NOT NULL,
+    added       TIMESTAMP NOT NULL,
+    modified    TIMESTAMP NOT NULL
+);
+INSERT INTO servers VALUES(DEFAULT, DEFAULT, 'localhost', '127.0.0.1', 'system', 'manager', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
+INSERT INTO graphs VALUES(  
+    DEFAULT,
+    DEFAULT,
+    DEFAULT,
+    'TomcatWebBytesSentSecond60Min',
+    'KiloBytes sent per second from the Tomcat Web Connector',
+    DEFAULT,
+    'geronimo:J2EEServer=geronimo,ServiceModule=org.apache.geronimo.configs/tomcat6/2.1-SNAPSHOT/car,j2eeType=GBean,name=TomcatWebConnector',
+    'D',
+    'BytesSent',
+    '/1024/',
+    'D',
+    'time',
+    'Tomcat Web KBytes/Sec Sent',
+    'KBps',
+    500.0,
+    1024.0,
+    DEFAULT,
+    DEFAULT,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP
+);
+INSERT INTO graphs VALUES(  
+    DEFAULT,
+    DEFAULT,
+    DEFAULT,
+    'TomcatWebBytesReceivedSecond60Min',
+    'KiloBytes received per second from the Tomcat Web Connector',
+    DEFAULT,
+    'geronimo:J2EEServer=geronimo,ServiceModule=org.apache.geronimo.configs/tomcat6/2.1-SNAPSHOT/car,j2eeType=GBean,name=TomcatWebConnector',
+    'D',
+    'BytesReceived',
+    '/1024/',
+    'D',
+    'time',
+    'Tomcat Web KBytes/Sec Received',
+    'KBps',
+    500.0,
+    1024.0,
+    DEFAULT,
+    DEFAULT,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP
+);
+INSERT INTO graphs VALUES(  
+    DEFAULT,
+    DEFAULT,
+    DEFAULT,
+    'TomcatWebRequestTimeSecond60Min',
+    'Request processing time over time from the Tomcat Web Connector',
+    DEFAULT,
+    'geronimo:J2EEServer=geronimo,ServiceModule=org.apache.geronimo.configs/tomcat6/2.1-SNAPSHOT/car,j2eeType=GBean,name=TomcatWebConnector',
+    'D',
+    'RequestTimeCurrentTime',
+    '/',
+    'D',
+    'time',
+    'Tomcat Request Time/Second',
+    'RequestTime',
+    500.0,
+    1024.0,
+    DEFAULT,
+    DEFAULT,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP
+);
+INSERT INTO graphs VALUES(  
+    DEFAULT,
+    DEFAULT,
+    DEFAULT,
+    'TomcatWebErrorCountSecond60Min',
+    'Error count over time from the Tomcat Web Connector',
+    DEFAULT,
+    'geronimo:J2EEServer=geronimo,ServiceModule=org.apache.geronimo.configs/tomcat6/2.1-SNAPSHOT/car,j2eeType=GBean,name=TomcatWebConnector',
+    'D',
+    'ErrorCount',
+    '/',
+    'D',
+    'time',
+    'Error Count/Sec',
+    'Errors',
+    500.0,
+    1024.0,
+    DEFAULT,
+    DEFAULT,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP
+);
+INSERT INTO views VALUES(
+    DEFAULT,
+    DEFAULT,
+    'Tomcat Web Connector 60 mins',
+    'Tomcat Web Connector 60 minute graphs',
+    4,
+    '0,1,2,3,',
+    CURRENT_TIMESTAMP,
+    CURRENT_TIMESTAMP
+);
 

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=583038&r1=583037&r2=583038&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 Oct  8 20:27:25 2007
@@ -16,562 +16,304 @@
  */
 package org.apache.geronimo.plugins.monitoring.client;
 
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.text.DecimalFormat;
 import java.text.Format;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Vector;
 import java.util.Set;
-import java.util.HashSet;
-import org.apache.geronimo.plugins.monitoring.client.StatsGraph;
+import java.util.Vector;
 
-public class GraphsBuilder {
+public class GraphsBuilder
+{
 
-    private String ServerIP = new String();
-    private HashMap<String, ArrayList<String>> DataNameList = new HashMap<String, ArrayList<String>>();
-    private int timeFrame;
-    private int snapCount;
-    private MRCConnector MRCConnection = new MRCConnector();
+    private String                                   ServerIP      = new String();
+    private final HashMap<String, ArrayList<String>> DataNameList  = new HashMap<String, ArrayList<String>>();
+    private int                                      timeFrame;
+    private int                                      snapCount;
+    private MRCConnector                             MRCConnection = new MRCConnector();
+    private final Connection                         Con;
 
     // constructor
-    GraphsBuilder(int serverID) {
-        // TODO: Database pull stuff may go here... based on server ID...
-        String username = "system";
-        String password = "manager";
-        ServerIP = "127.0.0.1";
-
-        try {
-
-            MRCConnection = new MRCConnector(ServerIP, username, password);
-            // TODO: Read config file to pull stuff we want graphed
-            DataNameList = MRCConnection.getDataNameList();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+    public GraphsBuilder(Connection con)
+    {
+        // TODO: Database pull stuff may go here... based on server ID...\
+        Con = con;
 
     }
 
-    /**
-     * @param mbServerConn:
-     *            mbean connection to Geronimo instance
-     * @param snapCount:
-     *            Number of points to graph from
-     * @param timeFrame:
-     *            Duration (in minutes) to be represented with the snapCount
-     * @return List of strings to be dumped to page
-     * @throws Exception
-     */
-    public Vector<StatsGraph> BuildAllOnTimeFrame(int snapcount, int timeframe)
-    throws Exception {
-
-        timeFrame = timeframe;
-        snapCount = snapcount;
-        HashMap<String, Vector<Object>> DataList = new HashMap<String, Vector<Object>>();
+    public StatsGraph buildOneDB(int snapcount, int graph_id) throws Exception
+    {
+        PreparedStatement pStmt = null;
+        ResultSet rsServer = null;
 
-        // Run through the mbeans
-        for (Iterator<String> it = DataNameList.keySet().iterator(); it
-            .hasNext();) {
-            // get the mbean name
-            String mbeanName = (String) it.next();
-            ArrayList<String> stats = null;
-            // Verify that it's not times
-            if (!mbeanName.equals("times")) {
-                stats = DataNameList.get(mbeanName);
-                for (Iterator<String> itt = stats.iterator(); itt.hasNext();) {
-                    String key = (String) itt.next();
-                    // Place elements into the DataList
-                    DataList.put(mbeanName + "+" + key, new Vector<Object>());
-                }
-            }
-        }
+        pStmt = Con
+                .prepareStatement("SELECT * from graphs WHERE enabled=1 AND graph_id="
+                        + graph_id);
+        ResultSet rs = pStmt.executeQuery();
+
+        if (rs.next())
+        {
+            pStmt = Con
+                    .prepareStatement("SELECT * from servers WHERE enabled=1 AND server_id="
+                            + rs.getInt("server_id"));
+            rsServer = pStmt.executeQuery();
+
+            if (rsServer.next())
+            {
+                ServerIP = rsServer.getString("ip");
+
+                MRCConnection = new MRCConnector(ServerIP, rsServer
+                        .getString("username"), rsServer.getString("password"));
+                // DataNameList = MRCConnection.getDataNameList();
 
-        if ((timeFrame / 1440 == 30))
-            snapCount = 17;
-        else {
-            if (((timeFrame / 1440) <= 7) && ((timeFrame / 60) > 24)
-                && snapCount >= 14) {
-                if ((timeFrame / 1440) == 7)
-                    snapCount = 16;
-                else
-                    snapCount = 12;
             }
-        }
-
-        Vector<Object> snapshot_date = new Vector<Object>();
-        Vector<Object> snapshot_time = new Vector<Object>();
-        ;
-        Vector<Object> PrettyTime = new Vector<Object>();
-
-        String prettyTimeFrame = new String();
-        DecimalFormat fmt = new DecimalFormat("0.##");
-        if (timeFrame / 60 > 24)
-            prettyTimeFrame = fmt.format((float) (timeFrame / 1440)) + " day";
-        else {
-            if (timeFrame > 60)
-                prettyTimeFrame = fmt.format((float) timeFrame / 60) + " hour";
             else
-                prettyTimeFrame = fmt.format(timeFrame) + " minute";
-        }
+                return null;
 
-        try {
-            int skipCount = (int) ((timeFrame / (MRCConnector
-                                                 .getSnapshotDuration() / 60000)))
-                            / (snapCount - 2);
-            // TODO: Call the fetching thing here
-            ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList = MRCConnection
-                                                                               .getSnapshots(snapCount, skipCount);
-
-            /*
-             * If there are not enough snapshots available to fill the requested
-             * number, insert some with values of 0 and the proper times.
-             */
-            while (snapshotList.size() < snapCount) {
-                // Temporary, always is first element (oldest)
-                HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                                                      .get(0);
-
-                // Temporary map, used to generate blank data to be added to the
-                // list at position 0
-                HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
-
-                // Temporary submap, used to store 0 elements to be added to the
-                // tempmap
-                HashMap<String, Object> subMap = new HashMap<String, Object>();
-
-                // Calculate appropriate time, add it to the submap, then add
-                // that to the tempMap
-                subMap.put("snapshot_time", (Long)((Long)mapTimeFix.get("times").get("snapshot_time") - (MRCConnector.getSnapshotDuration() * skipCount)));
-                Format formatter = null;
-                formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                Date date = new Date((Long) subMap.get("snapshot_time"));
-                subMap.put("snapshot_date", formatter.format(date));
-                // Add the submap back to the tempmap
-                tempMap.put("times", new HashMap<String, Object>(subMap));
-
-                // Clear out the subMap for use again
-                subMap.clear();
-
-                // Run through the mbeans
-                for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
-                    .hasNext();) {
-                    // get the mbean name
-                    String mbeanName = (String) it.next();
-                    HashMap<String, Object> stats = null;
-                    // Verify that it's not times
-
-                    if (mbeanName.equals(new String("times"))) {
+            String mBeanName = rs.getString("mbean");
+            String dataName = rs.getString("dataname1");
+            String graphName = rs.getString("name");
+            timeFrame = rs.getInt("timeframe");
 
-                    } else {
-                        stats = mapTimeFix.get(mbeanName);
-                        // Run through the stats elements for the particular
-                        // mbean
-                        for (Iterator<String> itt = stats.keySet().iterator(); itt
-                            .hasNext();) {
-                            String key = (String) itt.next();
-                            // Place faux data into the submap
-                            subMap.put(key, new Long(0));
-                        }
-                        // Add the submap to the tempmap, and clear it
-                        tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
-                    }
-                }
-                snapshotList.add(0, new HashMap<String, HashMap<String, Object>>(tempMap));
-            }
+            snapCount = snapcount;
+            HashMap<String, Vector<Object>> DataList = new HashMap<String, Vector<Object>>();
 
-            /*
-             * This is where we will be inserting data to fill 'gaps' in the
-             * snapshots The initial for-loop will travel from the most recent
-             * snapshot to the oldest, checking that the snapshot_time along the
-             * way all align with what they should be
-             */
-            for (int i = snapshotList.size() - 1; i > 0; i--) {
-                if (i > 0) {
-                    HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                                                          .get(i);
-                    HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
-                                                                           .get(i - 1);
-                    // here is where we will in missing data
-                    while (((((Long) mapTimeFix.get("times").get(
-                                                                "snapshot_time") / 1000) / 60)
-                            - (((Long) mapTimeFix2.get("times").get(
-                                                                   "snapshot_time") / 1000) / 60) > (((MRCConnector
-                                                                                                       .getSnapshotDuration() / 1000) / 60) * skipCount))) {
-                        HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
-                        HashMap<String, Object> subMap = new HashMap<String, Object>();
-
-                        for (Iterator<String> it = mapTimeFix.keySet()
-                             .iterator(); it.hasNext();) {
-                            // get the mbean name
-                            String mbeanName = (String) it.next();
-                            HashMap<String, Object> stats = null;
-                            // Verify that it's not times
-                            if (!mbeanName.equals("times")) {
-                                stats = mapTimeFix.get(mbeanName);
-                                // Run through the stats elements for the
-                                // particular
-                                // mbean
-                                for (Iterator<String> itt = stats.keySet()
-                                     .iterator(); itt.hasNext();) {
-                                    String key = (String) itt.next();
-                                    // Place faux data into the submap
-                                    subMap.put(key, new Long(0));
-                                }
-                                // Add the submap to the tempmap, and clear it
-                                tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
-                                subMap.clear();
-                            }
-                        }
+            DataList.put(graphName, new Vector<Object>());
 
-                        subMap.put("snapshot_time",new Long((Long) mapTimeFix.get("times").get("snapshot_time")- (MRCConnector.getSnapshotDuration() * skipCount)));
-                        Format formatter = null;
-                        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                        Date date = new Date((Long) subMap.get("snapshot_time"));
-                        subMap.put("snapshot_date", formatter.format(date));
-                        tempMap.put("times", new HashMap<String, Object>(subMap));
-                        subMap.clear();
-                        snapshotList.add(i, new HashMap<String, HashMap<String, Object>>(tempMap));
-                        snapshotList.remove(0);
-                        mapTimeFix = tempMap;
-                        mapTimeFix2 = snapshotList.get(i - 1);
-                    }
+            if ((timeFrame / 1440 == 30))
+                snapCount = 17;
+            else
+            {
+                if (((timeFrame / 1440) <= 7) && ((timeFrame / 60) > 24)
+                        && snapCount >= 14)
+                {
+                    if ((timeFrame / 1440) == 7)
+                        snapCount = 16;
+                    else
+                        snapCount = 12;
                 }
             }
 
-            for (int i = 0; i < snapshotList.size(); i++) {
-                HashMap<String, HashMap<String, Object>> map = snapshotList
-                                                               .get(i);
-                snapshot_date.add((String) map.get("times")
-                                  .get("snapshot_date"));
-                snapshot_time.add((Long) map.get("times").get("snapshot_time"));
-
-                for (Iterator<String> it = DataNameList.keySet().iterator(); it
-                    .hasNext();) {
-                    // get the mbean name
-                    String mbeanName = (String) it.next();
-                    ArrayList<String> stats = null;
-
-                    // Verify that it's not times
-                    if (!mbeanName.equals("times")) {
-                        stats = DataNameList.get(mbeanName);
-                        for (Iterator<String> itt = stats.iterator(); itt
-                            .hasNext();) {
-                            String key = (String) itt.next();
-                            Vector<Object> vectorTemp = DataList.get(mbeanName
-                                                                     + "+" + key);
-                            vectorTemp.add(map.get(mbeanName).get(key));
-                            // Place elements into the DataList
-                            DataList.put(mbeanName + "+" + key, vectorTemp);
-                        }
-                    }
-                }
-                PrettyTime.add((Long) map.get("times").get("snapshot_time") / 1000);
+            Vector<Object> snapshot_date = new Vector<Object>();
+            Vector<Object> snapshot_time = new Vector<Object>();
+            ;
+            Vector<Object> PrettyTime = new Vector<Object>();
+
+            String prettyTimeFrame = new String();
+            DecimalFormat fmt = new DecimalFormat("0.##");
+            if (timeFrame / 60 > 24)
+                prettyTimeFrame = fmt.format((float) (timeFrame / 1440))
+                        + " day";
+            else
+            {
+                if (timeFrame > 60)
+                    prettyTimeFrame = fmt.format((float) timeFrame / 60)
+                            + " hour";
+                else
+                    prettyTimeFrame = fmt.format(timeFrame) + " minute";
             }
 
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+            try
+            {
+                int skipCount = (int) ((timeFrame / (MRCConnector
+                        .getSnapshotDuration() / 60000)))
+                        / (snapCount - 2);
+                // TODO: Call the fetching thing here
+                ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList = MRCConnection
+                        .getSnapshots(snapCount, skipCount);
+
+                // Check if snapshotList is 0
+                // TODO: Return a buncha null datas
+                if (snapshotList.size() == 0)
+                {
+                    HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
+                    HashMap<String, Object> subMap = new HashMap<String, Object>();
+                    subMap.put(dataName, new Long(0));
+                    tempMap.put(mBeanName, new HashMap<String, Object>(subMap));
+                    subMap.clear();
+                    subMap.put("snapshot_time", System.currentTimeMillis());
+                    Format formatter = null;
+                    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    Date date = new Date((Long) subMap.get("snapshot_time"));
+                    subMap.put("snapshot_date", formatter.format(date));
+                    tempMap.put("times", new HashMap<String, Object>(subMap));
+
+                    snapshotList
+                            .add(new HashMap<String, HashMap<String, Object>>(
+                                    tempMap));
+                }
+                /*
+                 * If there are not enough snapshots available to fill the requested
+                 * number, insert some with values of 0 and the proper times.
+                 */
+                while (snapshotList.size() < snapCount)
+                {
+                    // Temporary, always is first element (oldest)
+                    HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
+                            .get(0);
 
-        Vector<StatsGraph> GraphVector = new Vector<StatsGraph>();
+                    // Temporary map, used to generate blank data to be added to
+                    // the
+                    // list at position 0
+                    HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
+
+                    // Temporary submap, used to store 0 elements to be added to
+                    // the
+                    // tempmap
+                    HashMap<String, Object> subMap = new HashMap<String, Object>();
+
+                    // Calculate appropriate time, add it to the submap, then
+                    // add
+                    // that to the tempMap
+                    subMap.put("snapshot_time", ((Long) mapTimeFix.get("times")
+                            .get("snapshot_time") - (MRCConnector
+                            .getSnapshotDuration() * skipCount)));
+                    Format formatter = null;
+                    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    Date date = new Date((Long) subMap.get("snapshot_time"));
+                    subMap.put("snapshot_date", formatter.format(date));
 
-        for (Iterator<String> it = DataNameList.keySet().iterator(); it
-            .hasNext();) {
-            // get the mbean name
-            String mbeanName = (String) it.next();
-            ArrayList<String> stats = null;
-
-            // Verify that it's not times
-            if (!mbeanName.equals("times")) {
-                stats = DataNameList.get(mbeanName);
-                for (Iterator<String> itt = stats.iterator(); itt.hasNext();) {
-                    String key = (String) itt.next();
-                    String[] titleTest = mbeanName.split("=");
-                    if (!(key.contains("Max") || key.contains("Min") || key
-                          .contains("Current"))) {
-
-
-                        GraphVector.add(new StatsGraph(titleTest[titleTest.length-1]+key, "127.0.0.1" + " - "
-                                                       + titleTest[titleTest.length-1]+key + "/second - " + prettyTimeFrame, "", "",
-                                                       DataList.get(mbeanName + "+" + key), '/',
-                                                       PrettyTime, snapshot_time, (int) (MRCConnector
-                                                                                         .getSnapshotDuration() / 1000),
-                                                       timeFrame, "1176c2"));
-                    }
-                    if (key.contains("Current")) {
-                        GraphVector.add(new StatsGraph(titleTest[titleTest.length-1]+key, "127.0.0.1" + " - "
-                                                       + titleTest[titleTest.length-1]+key + " - " + prettyTimeFrame, "", "",
-                                                       DataList.get(mbeanName + "+" + key),
-                                                       snapshot_time, (int) (MRCConnector
-                                                                             .getSnapshotDuration() / 1000),
-                                                       timeFrame, "1176c2"));
+                    // Add the submap back to the tempmap
+                    tempMap.put("times", new HashMap<String, Object>(subMap));
 
-                    }
-                }
-            }
-        }
+                    // Clear out the subMap for use again
+                    subMap.clear();
 
-        return GraphVector;
-    }
+                    // Run through the mbeans
+                    // Verify that it's not times
+                    // Run through the stats elements for the particular
+                    // mbean
 
-    public Vector<StatsGraph> BuildOnMbean(int snapcount, int timeframe, String MBeanName)
-    throws Exception {
+                    // Place faux data into the submap
+                    subMap.put(dataName, new Long(0));
 
-        timeFrame = timeframe;
-        snapCount = snapcount;
-        HashMap<String, Vector<Object>> DataList = new HashMap<String, Vector<Object>>();
+                    // Add the submap to the tempmap, and clear it
+                    tempMap.put(mBeanName, new HashMap<String, Object>(subMap));
 
-// Run through the mbeans
-        for (Iterator<String> it = DataNameList.keySet().iterator(); it
-            .hasNext();) {
-            // get the mbean name
-            String mbeanName = (String) it.next();
-            ArrayList<String> stats = null;
-            // Verify that it's not times
-            if (mbeanName.contains(MBeanName)) {
-                stats = DataNameList.get(mbeanName);
-                for (Iterator<String> itt = stats.iterator(); itt.hasNext();) {
-                    String key = (String) itt.next();
-                    // Place elements into the DataList
-                    DataList.put(mbeanName + "+" + key, new Vector<Object>());
+                    snapshotList.add(0,
+                            new HashMap<String, HashMap<String, Object>>(
+                                    tempMap));
                 }
-            }
-        }
-
-        if ((timeFrame / 1440 == 30))
-            snapCount = 17;
-        else {
-            if (((timeFrame / 1440) <= 7) && ((timeFrame / 60) > 24)
-                && snapCount >= 14) {
-                if ((timeFrame / 1440) == 7)
-                    snapCount = 16;
-                else
-                    snapCount = 12;
-            }
-        }
 
-        Vector<Object> snapshot_date = new Vector<Object>();
-        Vector<Object> snapshot_time = new Vector<Object>();
-        ;
-        Vector<Object> PrettyTime = new Vector<Object>();
-
-        String prettyTimeFrame = new String();
-        DecimalFormat fmt = new DecimalFormat("0.##");
-        if (timeFrame / 60 > 24)
-            prettyTimeFrame = fmt.format((float) (timeFrame / 1440)) + " day";
-        else {
-            if (timeFrame > 60)
-                prettyTimeFrame = fmt.format((float) timeFrame / 60) + " hour";
-            else
-                prettyTimeFrame = fmt.format(timeFrame) + " minute";
-        }
+                /*
+                 * This is where we will be inserting data to fill 'gaps' in the
+                 * snapshots The initial for-loop will travel from the most recent
+                 * snapshot to the oldest, checking that the snapshot_time along the
+                 * way all align with what they should be
+                 */
+                for (int i = snapshotList.size() - 1; i > 0; i--)
+                {
+                    if (i > 0)
+                    {
+                        HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
+                                .get(i);
+                        HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
+                                .get(i - 1);
+                        // here is where we will in missing data
+                        while (((((Long) mapTimeFix.get("times").get(
+                                "snapshot_time") / 1000) / 60)
+                                - (((Long) mapTimeFix2.get("times").get(
+                                        "snapshot_time") / 1000) / 60) > (((MRCConnector
+                                .getSnapshotDuration() / 1000) / 60) * skipCount)))
+                        {
+                            HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
+                            HashMap<String, Object> subMap = new HashMap<String, Object>();
 
-        try {
-            int skipCount = (int) ((timeFrame / (MRCConnector
-                                                 .getSnapshotDuration() / 60000)))
-                            / (snapCount - 2);
-            // TODO: Call the fetching thing here
-            ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList = MRCConnection
-                                                                               .getSnapshots(snapCount, skipCount);
-
-            /*
-             * If there are not enough snapshots available to fill the requested
-             * number, insert some with values of 0 and the proper times.
-             */
-            while (snapshotList.size() < snapCount) {
-                // Temporary, always is first element (oldest)
-                HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                                                      .get(0);
-
-                // Temporary map, used to generate blank data to be added to the
-                // list at position 0
-                HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
-
-                // Temporary submap, used to store 0 elements to be added to the
-                // tempmap
-                HashMap<String, Object> subMap = new HashMap<String, Object>();
-
-                // Calculate appropriate time, add it to the submap, then add
-                // that to the tempMap
-                subMap.put("snapshot_time", (Long)((Long)mapTimeFix.get("times").get("snapshot_time") - (MRCConnector.getSnapshotDuration() * skipCount)));
-                Format formatter = null;
-                formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                Date date = new Date((Long) subMap.get("snapshot_time"));
-                subMap.put("snapshot_date", formatter.format(date));
-                // Add the submap back to the tempmap
-                tempMap.put("times", new HashMap<String, Object>(subMap));
-
-                // Clear out the subMap for use again
-                subMap.clear();
-
-                // Run through the mbeans
-                for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
-                    .hasNext();) {
-                    // get the mbean name
-                    String mbeanName = (String) it.next();
-                    HashMap<String, Object> stats = null;
-                    // Verify that it's not times
+                            // Verify that it's not times
+                            // Run through the stats elements for the
+                            // particular
 
-                    if (mbeanName.contains(MBeanName)) {
-                        stats = mapTimeFix.get(mbeanName);
-                        // Run through the stats elements for the particular
-                        // mbean
-                        for (Iterator<String> itt = stats.keySet().iterator(); itt
-                            .hasNext();) {
-                            String key = (String) itt.next();
                             // Place faux data into the submap
-                            subMap.put(key, new Long(0));
-                        }
-                        // Add the submap to the tempmap, and clear it
-                        tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
-                    }
-                }
-                snapshotList.add(0, new HashMap<String, HashMap<String, Object>>(tempMap));
-            }
+                            subMap.put(dataName, new Long(0));
 
-            /*
-             * This is where we will be inserting data to fill 'gaps' in the
-             * snapshots The initial for-loop will travel from the most recent
-             * snapshot to the oldest, checking that the snapshot_time along the
-             * way all align with what they should be
-             */
-            for (int i = snapshotList.size() - 1; i > 0; i--) {
-                if (i > 0) {
-                    HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
-                                                                          .get(i);
-                    HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
-                                                                           .get(i - 1);
-                    // here is where we will in missing data
-                    while (((((Long) mapTimeFix.get("times").get(
-                                                                "snapshot_time") / 1000) / 60)
-                            - (((Long) mapTimeFix2.get("times").get(
-                                                                   "snapshot_time") / 1000) / 60) > (((MRCConnector
-                                                                                                       .getSnapshotDuration() / 1000) / 60) * skipCount))) {
-                        HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
-                        HashMap<String, Object> subMap = new HashMap<String, Object>();
-
-                        for (Iterator<String> it = mapTimeFix.keySet()
-                             .iterator(); it.hasNext();) {
-                            // get the mbean name
-                            String mbeanName = (String) it.next();
-                            HashMap<String, Object> stats = null;
-                            // Verify that it's not times
-                            if (mbeanName.contains(MBeanName)) {
-                                stats = mapTimeFix.get(mbeanName);
-                                // Run through the stats elements for the
-                                // particular
-                                // mbean
-                                for (Iterator<String> itt = stats.keySet()
-                                     .iterator(); itt.hasNext();) {
-                                    String key = (String) itt.next();
-                                    // Place faux data into the submap
-                                    subMap.put(key, new Long(0));
-                                }
-                                // Add the submap to the tempmap, and clear it
-                                tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
-                                subMap.clear();
-                            }
+                            // Add the submap to the tempmap, and clear it
+                            tempMap.put(mBeanName, new HashMap<String, Object>(
+                                    subMap));
+                            subMap.clear();
+
+                            subMap
+                                    .put(
+                                            "snapshot_time",
+                                            new Long(
+                                                    (Long) mapTimeFix.get(
+                                                            "times").get(
+                                                            "snapshot_time")
+                                                            - (MRCConnector
+                                                                    .getSnapshotDuration() * skipCount)));
+                            Format formatter = null;
+                            formatter = new SimpleDateFormat(
+                                    "yyyy-MM-dd HH:mm:ss");
+                            Date date = new Date((Long) subMap
+                                    .get("snapshot_time"));
+                            subMap.put("snapshot_date", formatter.format(date));
+                            tempMap.put("times", new HashMap<String, Object>(
+                                    subMap));
+                            subMap.clear();
+                            snapshotList
+                                    .add(
+                                            i,
+                                            new HashMap<String, HashMap<String, Object>>(
+                                                    tempMap));
+                            snapshotList.remove(0);
+                            mapTimeFix = tempMap;
+                            mapTimeFix2 = snapshotList.get(i - 1);
                         }
-
-                        subMap.put("snapshot_time",new Long((Long) mapTimeFix.get("times").get("snapshot_time")- (MRCConnector.getSnapshotDuration() * skipCount)));
-                        Format formatter = null;
-                        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                        Date date = new Date((Long) subMap.get("snapshot_time"));
-                        subMap.put("snapshot_date", formatter.format(date));
-                        tempMap.put("times", new HashMap<String, Object>(subMap));
-                        subMap.clear();
-                        snapshotList.add(i, new HashMap<String, HashMap<String, Object>>(tempMap));
-                        snapshotList.remove(0);
-                        mapTimeFix = tempMap;
-                        mapTimeFix2 = snapshotList.get(i - 1);
                     }
                 }
-            }
-
-            for (int i = 0; i < snapshotList.size(); i++) {
-                HashMap<String, HashMap<String, Object>> map = snapshotList
-                                                               .get(i);
-                snapshot_date.add((String) map.get("times")
-                                  .get("snapshot_date"));
-                snapshot_time.add((Long) map.get("times").get("snapshot_time"));
-
-                for (Iterator<String> it = DataNameList.keySet().iterator(); it
-                    .hasNext();) {
-                    // get the mbean name
-                    String mbeanName = (String) it.next();
-                    ArrayList<String> stats = null;
 
-                    // Verify that it's not times
-                    if (mbeanName.contains(MBeanName)) {
-                        stats = DataNameList.get(mbeanName);
-                        for (Iterator<String> itt = stats.iterator(); itt
-                            .hasNext();) {
-                            String key = (String) itt.next();
-                            Vector<Object> vectorTemp = DataList.get(mbeanName
-                                                                     + "+" + key);
-                            vectorTemp.add(map.get(mbeanName).get(key));
-                            // Place elements into the DataList
-                            DataList.put(mbeanName + "+" + key, vectorTemp);
-                        }
-                    }
+                for (int i = 0; i < snapshotList.size(); i++)
+                {
+                    HashMap<String, HashMap<String, Object>> map = snapshotList
+                            .get(i);
+                    snapshot_date.add(map.get("times").get("snapshot_date"));
+                    snapshot_time.add(map.get("times").get("snapshot_time"));
+                    Vector<Object> vectorTemp = DataList.get(graphName);
+                    vectorTemp.add(map.get(mBeanName).get(dataName));
+                    DataList.put(graphName, vectorTemp);
+                    PrettyTime
+                            .add((Long) map.get("times").get("snapshot_time") / 1000);
                 }
-                PrettyTime.add((Long) map.get("times").get("snapshot_time") / 1000);
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        Vector<StatsGraph> GraphVector = new Vector<StatsGraph>();
-
-        for (Iterator<String> it = DataNameList.keySet().iterator(); it
-            .hasNext();) {
-            // get the mbean name
-            String mbeanName = (String) it.next();
-            ArrayList<String> stats = null;
-
-            // Verify that it's not times
-            if (mbeanName.contains(MBeanName)) {
-                stats = DataNameList.get(mbeanName);
-                for (Iterator<String> itt = stats.iterator(); itt.hasNext();) {
-                    String key = (String) itt.next();
-                    String[] titleTest = mbeanName.split("=");
-                    if (!(key.contains("Max") || key.contains("Min") || key
-                          .contains("Current"))) {
-
-
-                        GraphVector.add(new StatsGraph(titleTest[titleTest.length-1]+key, "127.0.0.1" + " - "
-                                                       + titleTest[titleTest.length-1]+key + "/second - " + prettyTimeFrame, "", "",
-                                                       DataList.get(mbeanName + "+" + key), '/',
-                                                       PrettyTime, snapshot_time, (int) (MRCConnector
-                                                                                         .getSnapshotDuration() / 1000),
-                                                       timeFrame, "1176c2"));
-                    }
-                    if (key.contains("Current")) {
-                        GraphVector.add(new StatsGraph(titleTest[titleTest.length-1]+key, "127.0.0.1" + " - "
-                                                       + titleTest[titleTest.length-1]+key + " - " + prettyTimeFrame, "", "",
-                                                       DataList.get(mbeanName + "+" + key),
-                                                       snapshot_time, (int) (MRCConnector
-                                                                             .getSnapshotDuration() / 1000),
-                                                       timeFrame, "1176c2"));
 
-                    }
-                }
             }
-        }
 
-        return GraphVector;
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+
+            return (new StatsGraph(graph_id, graphName, rs
+                    .getString("description"), ServerIP + " - "
+                    + rs.getString("xlabel") + " - " + prettyTimeFrame, rs
+                    .getString("ylabel"), rs.getString("data1operation")
+                    .charAt(0), DataList.get(graphName), rs
+                    .getString("operation"), rs.getString("data2operation")
+                    .charAt(0), PrettyTime, snapshot_time, (int) (MRCConnector
+                    .getSnapshotDuration() / 1000), timeFrame, rs
+                    .getString("color"), rs.getFloat("warninglevel1"), rs
+                    .getFloat("warninglevel1")));
+        }
+        else
+            return null;
     }
 
     public Set<String> GetTrackedBeansPretty()
     {
         Set<String> trackedBeans = new HashSet<String>();
-        for (Iterator<String> it = DataNameList.keySet().iterator(); it.hasNext();) {
+        for (Iterator<String> it = DataNameList.keySet().iterator(); it
+                .hasNext();)
+        {
             String mbeanName = it.next();
-            if (!mbeanName.equals("times")) {
+            if (!mbeanName.equals("times"))
+            {
                 String[] beanTemp = mbeanName.split("=");
-                trackedBeans.add(beanTemp[beanTemp.length-1]);
+                trackedBeans.add(beanTemp[beanTemp.length - 1]);
             }
         }
         return trackedBeans;

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=583038&r1=583037&r2=583038&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 Oct  8 20:27:25 2007
@@ -27,27 +27,35 @@
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
-public class MRCConnector {
+public class MRCConnector
+{
 
-    private static final String PATH = "geronimo:ServiceModule=org.apache.geronimo.monitor/MRC/1.0/car,J2EEServer=geronimo,name=MasterRemoteControl,j2eeType=GBean";
+    private static final String          PATH             = "geronimo:ServiceModule=org.apache.geronimo.monitor/MRC/1.0/car,J2EEServer=geronimo,name=MasterRemoteControl,j2eeType=GBean";
     private static MBeanServerConnection mbServerConn;
-    private static Long SnapshotDuration = new Long(0);
-    MRCConnector() {
+    private static Long                  SnapshotDuration = new Long(0);
+
+    MRCConnector()
+    {
 
     }
 
     /**
-     * @param ServerIP - IP address of mrc-server to connect to
-     * @param userName - Username for JMX connection to the host
-     * @param password - Password for JMX connection to the host
-     * @throws Exception - If the connection to mrc-server fails
+     * @param ServerIP -
+     *            IP address of mrc-server to connect to
+     * @param userName -
+     *            Username for JMX connection to the host
+     * @param password -
+     *            Password for JMX connection to the host
+     * @throws Exception -
+     *             If the connection to mrc-server fails
      */
     MRCConnector(String ServerIP, String userName, String password)
-    throws Exception {
+            throws Exception
+    {
         JMXServiceURL serviceURL = new JMXServiceURL(
-                                                    "service:jmx:rmi:///jndi/rmi://" + ServerIP
-                                                    + ":1099/JMXConnector");
-        Hashtable<String,Object> env = new Hashtable<String,Object>();
+                "service:jmx:rmi:///jndi/rmi://" + ServerIP
+                        + ":1099/JMXConnector");
+        Hashtable<String, Object> env = new Hashtable<String, Object>();
         String[] credentials = new String[2];
         credentials[0] = userName;
         credentials[1] = password;
@@ -57,16 +65,23 @@
     }
 
     /**
-     * @return - Returns an Long representing the current snapshot duration set on the server side
-     * @throws Exception - If the connection to the MRC-Server fails
+     * @return - Returns an Long representing the current snapshot duration set
+     *         on the server side
+     * @throws Exception -
+     *             If the connection to the MRC-Server fails
      */
-    public static Long getSnapshotDuration() throws Exception {
-        if (SnapshotDuration == 0) {
-            try {
+    public static Long getSnapshotDuration() throws Exception
+    {
+        if (SnapshotDuration == 0)
+        {
+            try
+            {
                 SnapshotDuration = (Long) mbServerConn.invoke(new ObjectName(
-                                                                            PATH), "getSnapshotDuration", new Object[] {},
-                                                              new String[] {});
-            } catch (Exception e) {
+                        PATH), "getSnapshotDuration", new Object[] {},
+                        new String[] {});
+            }
+            catch (Exception e)
+            {
                 e.printStackTrace();
             }
         }
@@ -74,22 +89,32 @@
     }
 
     /**
-     * @return - Returns an ArrayList of String objects containing a listing of all statistics values being collected
-     * @throws Exception - If the connection to the MRC-Server fails
+     * @return - Returns an ArrayList of String objects containing a listing of
+     *         all statistics values being collected
+     * @throws Exception -
+     *             If the connection to the MRC-Server fails
      */
-    public HashMap<String, ArrayList<String>> getDataNameList() throws Exception {
+    @SuppressWarnings("unchecked")
+    public HashMap<String, ArrayList<String>> getDataNameList()
+            throws Exception
+    {
 
         HashMap<String, ArrayList<String>> DataNameList = new HashMap<String, ArrayList<String>>();
-        try {
-            DataNameList = (HashMap<String, ArrayList<String>>) mbServerConn.invoke(
-                                                                                   new ObjectName(PATH), "getAllSnapshotStatAttributes",
-                                                                                   new Object[] {}, new String[] {});
-        } catch (Exception e) {
+        try
+        {
+            DataNameList = (HashMap<String, ArrayList<String>>) mbServerConn
+                    .invoke(new ObjectName(PATH),
+                            "getAllSnapshotStatAttributes", new Object[] {},
+                            new String[] {});
+        }
+        catch (Exception e)
+        {
             e.printStackTrace();
         }
-        //Strip out snapshot_date and snapshot_time, we know these exist
+        // Strip out snapshot_date and snapshot_time, we know these exist
         for (Iterator<String> it = DataNameList.keySet().iterator(); it
-            .hasNext();) {
+                .hasNext();)
+        {
             String mbeanName = it.next();
             DataNameList.get(mbeanName).remove("snapshot_date");
             DataNameList.get(mbeanName).remove("snapshot_time");
@@ -98,17 +123,23 @@
     }
 
     /**
-     * @param snapCount - Number of snapshots to request from the server
-     * @param skipCount - Every nth snapshot. A value of 1 will be every 1. A value of 2 will be every other.
+     * @param snapCount -
+     *            Number of snapshots to request from the server
+     * @param skipCount -
+     *            Every nth snapshot. A value of 1 will be every 1. A value of 2
+     *            will be every other.
      * @return - Returns an ArrayList of Map objects.
-     * @throws Exception - If the connection to the MRC-Server fails
+     * @throws Exception -
+     *             If the connection to the MRC-Server fails
      */
-    public ArrayList<HashMap<String, HashMap<String,Object>>> getSnapshots(int snapCount, int skipCount)
-    throws Exception {
-        ArrayList<HashMap<String, HashMap<String,Object>>> list = (ArrayList<HashMap<String, HashMap<String,Object>>>) mbServerConn.invoke(
-                                                                                                                                          new ObjectName(PATH), "fetchSnapshotData", new Object[] {
-                                                                                                                                              snapCount, skipCount}, new String[] {
-                                                                                                                                              "java.lang.Integer", "java.lang.Integer"});
+    @SuppressWarnings("unchecked")
+    public ArrayList<HashMap<String, HashMap<String, Object>>> getSnapshots(
+            int snapCount, int skipCount) throws Exception
+    {
+        ArrayList<HashMap<String, HashMap<String, Object>>> list = (ArrayList<HashMap<String, HashMap<String, Object>>>) mbServerConn
+                .invoke(new ObjectName(PATH), "fetchSnapshotData",
+                        new Object[] { snapCount, skipCount }, new String[] {
+                                "java.lang.Integer", "java.lang.Integer" });
         return list;
     }
 }

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=583038&r1=583037&r2=583038&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 Oct  8 20:27:25 2007
@@ -17,12 +17,6 @@
 package org.apache.geronimo.plugins.monitoring.client;
 
 import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.Vector;
-import java.util.Set;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -32,22 +26,30 @@
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
 
-import org.apache.geronimo.plugins.monitoring.client.GraphsBuilder;
-import org.apache.geronimo.plugins.monitoring.client.util.DBManager;
 /**
  * STATS
  */
-public class MonitoringPortlet extends GenericPortlet {
+public class MonitoringPortlet extends GenericPortlet
+{
 
-    private static final String MBEAN_JSP = "/WEB-INF/view/monitoringMbean.jsp";
+    private static final String      NORMALVIEW_JSP    = "/WEB-INF/view/monitoringNormal.jsp";
 
-    private static final String TIMEFRAME_JSP = "/WEB-INF/view/monitoringTimeframe.jsp";
+    private static final String      PAGEVIEW_JSP      = "/WEB-INF/view/monitoringPage.jsp";
 
-    private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/monitoringMaximized.jsp";
+    private static final String      MBEAN_JSP         = "/WEB-INF/view/monitoringMbean.jsp";
 
-    private static final String HELPVIEW_JSP = "/WEB-INF/view/monitoringHelp.jsp";
+    private static final String      TIMEFRAME_JSP     = "/WEB-INF/view/monitoringTimeframe.jsp";
+
+    private static final String      MAXIMIZEDVIEW_JSP = "/WEB-INF/view/monitoringMaximized.jsp";
+
+    private static final String      HELPVIEW_JSP      = "/WEB-INF/view/monitoringHelp.jsp";
+
+    private static final String      EDITVIEW_JSP      = "/WEB-INF/view/monitoringEdit.jsp";
+
+    private PortletRequestDispatcher normalView;
+
+    private PortletRequestDispatcher pageView;
 
     private PortletRequestDispatcher mBeanView;
 
@@ -57,115 +59,85 @@
 
     private PortletRequestDispatcher helpView;
 
+    private PortletRequestDispatcher editView;
+
+    @Override
     public void processAction(ActionRequest actionRequest,
-                              ActionResponse actionResponse) throws PortletException, IOException {
-        actionResponse.setRenderParameter("time", actionRequest.getParameter("time"));
-        actionResponse.setRenderParameter("mode", actionRequest.getParameter("mode"));
-        if (actionRequest.getParameter("mode").equals("mbean")) {
-            actionResponse.setRenderParameter("bean", actionRequest.getParameter("bean"));
+            ActionResponse actionResponse) throws PortletException, IOException
+    {
+        String action = actionRequest.getParameter("action");
+        actionResponse.setRenderParameter("action", action);
+        if (action.equals("showView"))
+        {
+            String view_id = actionRequest.getParameter("view_id");
+            actionResponse.setRenderParameter("view_id", view_id);
         }
     }
 
+    @Override
     public void doView(RenderRequest request, RenderResponse response)
-    throws PortletException, IOException {
-        Integer timeFrame = 60;
-        String mode = "mbean";
-        String bean = "TomcatWebConnector";
-        if (request.getParameter("time") != null)
-            timeFrame = Integer.parseInt(request.getParameter("time"));
-        if (request.getParameter("mode") != null)
-            mode = request.getParameter("mode");
-        if (request.getParameter("bean") != null)
-            bean = request.getParameter("bean");
-        response.setProperty("time", timeFrame.toString());
-        response.setProperty("mode", mode);
-
-        try {
-            
-           /* //DBBBBB_--------
-            Connection con = DBManager.getConnection();
-
-                PreparedStatement pStmt = con.prepareStatement("CREATE TABLE mrc_servers(server_id INTEGER PRIMARY KEY, server_ip VARCHAR(15), username VARCHAR(128), password VARCHAR(1024) )");
-            pStmt.executeUpdate();
-                        pStmt = con.prepareStatement("INSERT INTO mrc_servers VALUES(0, '127.0.0.1', 'system', 'manager')");
-            pStmt.executeUpdate();
-                        pStmt = con.prepareStatement("INSERT INTO mrc_servers VALUES(1, '127.0.0.2', 'system', 'manager')");
-            pStmt.executeUpdate();
-                        pStmt = con.prepareStatement("SELECT * FROM mrc_servers");
-                ResultSet rs = pStmt.executeQuery();
-
-                while(rs.next()){
-                    
-                    Integer server_id = rs.getInt("server_id");
-                    String server_ip = rs.getString("server_ip");
-                    String username = rs.getString("username");
-                    String password = rs.getString("password");
-
-                    System.out.println(server_id);
-                    System.out.println(server_ip);
-                    System.out.println(username);
-                    System.out.println(password);
-                }
-            //DBBBBB_--------*/
-            GraphsBuilder run = new GraphsBuilder(0);
-            if (mode.equals("mbean")) {
-                Vector <StatsGraph> GraphVector = run.BuildOnMbean(14, timeFrame, bean);
-                Set <String> trackedBeans = run.GetTrackedBeansPretty();
-                request.setAttribute("GraphVector", GraphVector);
-                request.setAttribute("trackedBeans", trackedBeans);
-                if (WindowState.MINIMIZED.equals(request.getWindowState())) {
-                    return;
-                } else
-                    mBeanView.include(request, response);
-            }
-            if (mode.equals("timeframe")) {
-                Vector <StatsGraph> GraphVector = run.BuildAllOnTimeFrame(14, timeFrame);
-                Set <String> trackedBeans = run.GetTrackedBeansPretty();
-                request.setAttribute("GraphVector", GraphVector);
-                request.setAttribute("trackedBeans", trackedBeans);
-                if (WindowState.MINIMIZED.equals(request.getWindowState())) {
-                    return;
-                } else
-                    timeFrameView.include(request, response);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
+            throws PortletException, IOException
+    {
+        String action = request.getParameter("action");
+        if (action == null)
+            action = "showNormal";
+        if (action.equals("showView"))
+        {
+            String view_id = request.getParameter("view_id");
+            request.setAttribute("view_id", view_id);
+            pageView.include(request, response);
+        }
+        else
+        {
+            normalView.include(request, response);
         }
-
-        //if (WindowState.MINIMIZED.equals(request.getWindowState())) {
-        //return;
-        //}
-
-        //if (WindowState.NORMAL.equals(request.getWindowState())) {
-        //  normalView.include(request, response);
-        //} else {
-        //  maximizedView.include(request, response);
-        //}
 
     }
 
+    @Override
     protected void doHelp(RenderRequest renderRequest,
-                          RenderResponse renderResponse) throws PortletException, IOException {
+            RenderResponse renderResponse) throws PortletException, IOException
+    {
         helpView.include(renderRequest, renderResponse);
     }
 
-    public void init(PortletConfig portletConfig) throws PortletException {
+    @Override
+    protected void doEdit(RenderRequest renderRequest,
+            RenderResponse renderResponse) throws PortletException, IOException
+    {
+        editView.include(renderRequest, renderResponse);
+    }
+
+    @Override
+    public void init(PortletConfig portletConfig) throws PortletException
+    {
         super.init(portletConfig);
+        normalView = portletConfig.getPortletContext().getRequestDispatcher(
+                NORMALVIEW_JSP);
+        pageView = portletConfig.getPortletContext().getRequestDispatcher(
+                PAGEVIEW_JSP);
         mBeanView = portletConfig.getPortletContext().getRequestDispatcher(
-                                                                          MBEAN_JSP);
+                MBEAN_JSP);
         timeFrameView = portletConfig.getPortletContext().getRequestDispatcher(
-                                                                              TIMEFRAME_JSP);
+                TIMEFRAME_JSP);
         maximizedView = portletConfig.getPortletContext().getRequestDispatcher(
-                                                                              MAXIMIZEDVIEW_JSP);
+                MAXIMIZEDVIEW_JSP);
         helpView = portletConfig.getPortletContext().getRequestDispatcher(
-                                                                         HELPVIEW_JSP);
+                HELPVIEW_JSP);
+        editView = portletConfig.getPortletContext().getRequestDispatcher(
+                EDITVIEW_JSP);
     }
 
-    public void destroy() {
+    @Override
+    public void destroy()
+    {
+        normalView = null;
+        pageView = null;
         mBeanView = null;
         timeFrameView = null;
         maximizedView = null;
         helpView = null;
+        editView = null;
         super.destroy();
     }
 }



Mime
View raw message