Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 81323 invoked from network); 9 Oct 2007 03:27:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Oct 2007 03:27:58 -0000 Received: (qmail 38830 invoked by uid 500); 9 Oct 2007 03:27:45 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 38780 invoked by uid 500); 9 Oct 2007 03:27:45 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 38746 invoked by uid 99); 9 Oct 2007 03:27:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 20:27:45 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Oct 2007 03:27:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E52DA1A9832; Mon, 8 Oct 2007 20:27:27 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: akulshreshtha@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071009032727.E52DA1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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> DataNameList = new HashMap>(); - private int timeFrame; - private int snapCount; - private MRCConnector MRCConnection = new MRCConnector(); + private String ServerIP = new String(); + private final HashMap> DataNameList = new HashMap>(); + 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 BuildAllOnTimeFrame(int snapcount, int timeframe) - throws Exception { - - timeFrame = timeframe; - snapCount = snapcount; - HashMap> DataList = new HashMap>(); + public StatsGraph buildOneDB(int snapcount, int graph_id) throws Exception + { + PreparedStatement pStmt = null; + ResultSet rsServer = null; - // Run through the mbeans - for (Iterator it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - // Verify that it's not times - if (!mbeanName.equals("times")) { - stats = DataNameList.get(mbeanName); - for (Iterator itt = stats.iterator(); itt.hasNext();) { - String key = (String) itt.next(); - // Place elements into the DataList - DataList.put(mbeanName + "+" + key, new Vector()); - } - } - } + 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 snapshot_date = new Vector(); - Vector snapshot_time = new Vector(); - ; - Vector PrettyTime = new Vector(); - - 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>> 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> mapTimeFix = snapshotList - .get(0); - - // Temporary map, used to generate blank data to be added to the - // list at position 0 - HashMap> tempMap = new HashMap>(); - - // Temporary submap, used to store 0 elements to be added to the - // tempmap - HashMap subMap = new HashMap(); - - // 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(subMap)); - - // Clear out the subMap for use again - subMap.clear(); - - // Run through the mbeans - for (Iterator it = mapTimeFix.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - HashMap 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 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(subMap)); - } - } - snapshotList.add(0, new HashMap>(tempMap)); - } + snapCount = snapcount; + HashMap> DataList = new HashMap>(); - /* - * 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> mapTimeFix = snapshotList - .get(i); - HashMap> 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> tempMap = new HashMap>(); - HashMap subMap = new HashMap(); - - for (Iterator it = mapTimeFix.keySet() - .iterator(); it.hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - HashMap 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 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(subMap)); - subMap.clear(); - } - } + DataList.put(graphName, new Vector()); - 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(subMap)); - subMap.clear(); - snapshotList.add(i, new HashMap>(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> 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 it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - - // Verify that it's not times - if (!mbeanName.equals("times")) { - stats = DataNameList.get(mbeanName); - for (Iterator itt = stats.iterator(); itt - .hasNext();) { - String key = (String) itt.next(); - Vector 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 snapshot_date = new Vector(); + Vector snapshot_time = new Vector(); + ; + Vector PrettyTime = new Vector(); + + 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>> snapshotList = MRCConnection + .getSnapshots(snapCount, skipCount); + + // Check if snapshotList is 0 + // TODO: Return a buncha null datas + if (snapshotList.size() == 0) + { + HashMap> tempMap = new HashMap>(); + HashMap subMap = new HashMap(); + subMap.put(dataName, new Long(0)); + tempMap.put(mBeanName, new HashMap(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(subMap)); + + snapshotList + .add(new HashMap>( + 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> mapTimeFix = snapshotList + .get(0); - Vector GraphVector = new Vector(); + // Temporary map, used to generate blank data to be added to + // the + // list at position 0 + HashMap> tempMap = new HashMap>(); + + // Temporary submap, used to store 0 elements to be added to + // the + // tempmap + HashMap subMap = new HashMap(); + + // 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 it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - - // Verify that it's not times - if (!mbeanName.equals("times")) { - stats = DataNameList.get(mbeanName); - for (Iterator 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(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 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> DataList = new HashMap>(); + // Add the submap to the tempmap, and clear it + tempMap.put(mBeanName, new HashMap(subMap)); -// Run through the mbeans - for (Iterator it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - // Verify that it's not times - if (mbeanName.contains(MBeanName)) { - stats = DataNameList.get(mbeanName); - for (Iterator itt = stats.iterator(); itt.hasNext();) { - String key = (String) itt.next(); - // Place elements into the DataList - DataList.put(mbeanName + "+" + key, new Vector()); + snapshotList.add(0, + new HashMap>( + 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 snapshot_date = new Vector(); - Vector snapshot_time = new Vector(); - ; - Vector PrettyTime = new Vector(); - - 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> mapTimeFix = snapshotList + .get(i); + HashMap> 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> tempMap = new HashMap>(); + HashMap subMap = new HashMap(); - try { - int skipCount = (int) ((timeFrame / (MRCConnector - .getSnapshotDuration() / 60000))) - / (snapCount - 2); - // TODO: Call the fetching thing here - ArrayList>> 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> mapTimeFix = snapshotList - .get(0); - - // Temporary map, used to generate blank data to be added to the - // list at position 0 - HashMap> tempMap = new HashMap>(); - - // Temporary submap, used to store 0 elements to be added to the - // tempmap - HashMap subMap = new HashMap(); - - // 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(subMap)); - - // Clear out the subMap for use again - subMap.clear(); - - // Run through the mbeans - for (Iterator it = mapTimeFix.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - HashMap 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 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(subMap)); - } - } - snapshotList.add(0, new HashMap>(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> mapTimeFix = snapshotList - .get(i); - HashMap> 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> tempMap = new HashMap>(); - HashMap subMap = new HashMap(); - - for (Iterator it = mapTimeFix.keySet() - .iterator(); it.hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - HashMap 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 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(subMap)); - subMap.clear(); - } + // Add the submap to the tempmap, and clear it + tempMap.put(mBeanName, new HashMap( + 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( + subMap)); + subMap.clear(); + snapshotList + .add( + i, + new HashMap>( + 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(subMap)); - subMap.clear(); - snapshotList.add(i, new HashMap>(tempMap)); - snapshotList.remove(0); - mapTimeFix = tempMap; - mapTimeFix2 = snapshotList.get(i - 1); } } - } - - for (int i = 0; i < snapshotList.size(); i++) { - HashMap> 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 it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - // Verify that it's not times - if (mbeanName.contains(MBeanName)) { - stats = DataNameList.get(mbeanName); - for (Iterator itt = stats.iterator(); itt - .hasNext();) { - String key = (String) itt.next(); - Vector 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> map = snapshotList + .get(i); + snapshot_date.add(map.get("times").get("snapshot_date")); + snapshot_time.add(map.get("times").get("snapshot_time")); + Vector 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 GraphVector = new Vector(); - - for (Iterator it = DataNameList.keySet().iterator(); it - .hasNext();) { - // get the mbean name - String mbeanName = (String) it.next(); - ArrayList stats = null; - - // Verify that it's not times - if (mbeanName.contains(MBeanName)) { - stats = DataNameList.get(mbeanName); - for (Iterator 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 GetTrackedBeansPretty() { Set trackedBeans = new HashSet(); - for (Iterator it = DataNameList.keySet().iterator(); it.hasNext();) { + for (Iterator 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 env = new Hashtable(); + "service:jmx:rmi:///jndi/rmi://" + ServerIP + + ":1099/JMXConnector"); + Hashtable env = new Hashtable(); 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> getDataNameList() throws Exception { + @SuppressWarnings("unchecked") + public HashMap> getDataNameList() + throws Exception + { HashMap> DataNameList = new HashMap>(); - try { - DataNameList = (HashMap>) mbServerConn.invoke( - new ObjectName(PATH), "getAllSnapshotStatAttributes", - new Object[] {}, new String[] {}); - } catch (Exception e) { + try + { + DataNameList = (HashMap>) 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 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>> getSnapshots(int snapCount, int skipCount) - throws Exception { - ArrayList>> list = (ArrayList>>) mbServerConn.invoke( - new ObjectName(PATH), "fetchSnapshotData", new Object[] { - snapCount, skipCount}, new String[] { - "java.lang.Integer", "java.lang.Integer"}); + @SuppressWarnings("unchecked") + public ArrayList>> getSnapshots( + int snapCount, int skipCount) throws Exception + { + ArrayList>> list = (ArrayList>>) 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 GraphVector = run.BuildOnMbean(14, timeFrame, bean); - Set 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 GraphVector = run.BuildAllOnTimeFrame(14, timeFrame); - Set 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(); } }