geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r601793 - in /geronimo/sandbox/monitoring: client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/ client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/ client/client-war/src/main/webapp/...
Date Thu, 06 Dec 2007 17:33:31 GMT
Author: ecraig
Date: Thu Dec  6 09:33:23 2007
New Revision: 601793

URL: http://svn.apache.org/viewvc?rev=601793&view=rev
Log:
GERONIMO-3678
Monitoring console should accept a port no for server to be monitored

Monitoring client has been updated to allow this to be specified/stored in db.

Patch by Viet Nguyen


Modified:
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MRCConnector.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/MonitoringPortlet.java
    geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringGraphs.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
    geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViews.jsp
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
    geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotProcessor.java

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/GraphsBuilder.java?rev=601793&r1=601792&r2=601793&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 Thu Dec  6 09:33:23 2007
@@ -77,6 +77,7 @@
                 ip = rsServer.getString("ip");
                 String username = rsServer.getString("username");
                 String password = rsServer.getString("password");
+                int port = rsServer.getInt("port");
                 // close the connection before calling the MRCConnector because it opens another
                 // connection to the db to update the SERVERS.last_seen attribute
                 try {
@@ -84,7 +85,7 @@
                 } catch(Exception e) {
                     throw e;
                 }
-                mrc = new MRCConnector(ip, username, password);
+                mrc = new MRCConnector(ip, username, password, port);
 
                 snapCount = timeFrame
                         / java.lang.Integer

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=601793&r1=601792&r2=601793&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 Thu Dec  6 09:33:23 2007
@@ -57,7 +57,7 @@
      * @throws Exception -
      *             If the connection to mrc-server fails
      */
-    public MRCConnector(String ip, String userName, String password)
+    public MRCConnector(String ip, String userName, String password, int port)
             throws Exception
     {
         // decrypt the password
@@ -66,7 +66,7 @@
             Properties props = new Properties();
             props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                     "org.apache.openejb.client.RemoteInitialContextFactory");
-            props.setProperty(Context.PROVIDER_URL, "ejbd://" + ip + ":4201");
+            props.setProperty(Context.PROVIDER_URL, "ejbd://" + ip + ":" + port);
             props.setProperty(Context.SECURITY_PRINCIPAL, userName);
             props.setProperty(Context.SECURITY_CREDENTIALS, password);
             props.setProperty("openejb.authentication.realmName", "geronimo-admin");

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=601793&r1=601792&r2=601793&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 Thu Dec  6 09:33:23 2007
@@ -249,13 +249,16 @@
             String username = actionRequest.getParameter("username");
             String password = actionRequest.getParameter("password");
             String password2 = actionRequest.getParameter("password2");
-            String message = testConnection(name, ip, username, password);
+            String strPort = actionRequest.getParameter("port");
+            int port = Integer.parseInt(strPort);
+            String message = testConnection(name, ip, username, password, port);
             actionResponse.setRenderParameter("message", message);
             actionResponse.setRenderParameter("name", name);
             actionResponse.setRenderParameter("username", username);
             actionResponse.setRenderParameter("ip", ip);
             actionResponse.setRenderParameter("password", password);
             actionResponse.setRenderParameter("password2", password2);
+            actionResponse.setRenderParameter("port", "" + port);
         }
         else if (action.equals("testEditServerConnection"))
         {
@@ -267,7 +270,9 @@
             String server_id = actionRequest.getParameter("server_id");
             String snapshot = actionRequest.getParameter("snapshot");
             String retention = actionRequest.getParameter("retention");
-            String message = testConnection(name, ip, username, password);
+            String strPort = actionRequest.getParameter("port");
+            int port = Integer.parseInt(strPort);
+            String message = testConnection(name, ip, username, password, port);
             actionResponse.setRenderParameter("message", message);
             actionResponse.setRenderParameter("name", name);
             actionResponse.setRenderParameter("username", username);
@@ -277,15 +282,16 @@
             actionResponse.setRenderParameter("snapshot", snapshot);
             actionResponse.setRenderParameter("server_id", server_id);
             actionResponse.setRenderParameter("retention", retention);
+            actionResponse.setRenderParameter("port", "" + port);
         }
     }
 
     private String testConnection(String name, String ip, String username,
-            String password)
+            String password, int port)
     {
         try
         {
-            MRCConnector mrc = new MRCConnector(ip, username, password);
+            MRCConnector mrc = new MRCConnector(ip, username, password, port);
             return "<font color=\"green\"><strong><li>Connection was successfully established.</li></strong></font>";
         }
         catch (Exception e)
@@ -570,12 +576,14 @@
                     .setAttribute("password2", request
                             .getParameter("password2"));
             request.setAttribute("message", request.getParameter("message"));
+            request.setAttribute("port", request.getParameter("port"));
             addServer.include(request, response);
         }
         else if (action.equals("testEditServerConnection"))
         {
             request.setAttribute("name", request.getParameter("name"));
             request.setAttribute("ip", request.getParameter("ip"));
+            request.setAttribute("port", request.getParameter("port"));
             request.setAttribute("username", request.getParameter("username"));
             request.setAttribute("password", request.getParameter("password"));
             request
@@ -719,6 +727,8 @@
         String username = actionRequest.getParameter("username");
         String snapshot = actionRequest.getParameter("snapshot");
         String retention = actionRequest.getParameter("retention");
+        String strPort = actionRequest.getParameter("port");
+        int port = Integer.parseInt(strPort);
         // encrypt the password
         if(password != null && !password.equals("")) {
             password = EncryptionManager.encrypt(password);
@@ -734,7 +744,9 @@
                                 + ip
                                 + "', username='"
                                 + username
-                                + "', modified=CURRENT_TIMESTAMP, last_seen=CURRENT_TIMESTAMP WHERE server_id="
+                                + "', modified=CURRENT_TIMESTAMP, last_seen=CURRENT_TIMESTAMP, "
+                                + "port=" + port 
+                                + " WHERE server_id="
                                 + server_id);
                 pStmt.executeUpdate();
                 // when user did not specify the password, just grab it from the db
@@ -768,8 +780,8 @@
             if(snapshot == null || retention == null) {
                 // do not update if we do not know
             } else {
-                (new MRCConnector(ip, username, password)).setSnapshotDuration(Long.parseLong(snapshot) * 1000 * 60);
-                (new MRCConnector(ip, username, password)).setSnapshotRetention(Integer.parseInt(retention));
+                (new MRCConnector(ip, username, password, port)).setSnapshotDuration(Long.parseLong(snapshot) * 1000 * 60);
+                (new MRCConnector(ip, username, password, port)).setSnapshotRetention(Integer.parseInt(retention));
             }
             // set success message
             actionResponse.setRenderParameter(
@@ -789,6 +801,7 @@
         Connection con = DBase.getConnection();
         String name = actionRequest.getParameter("name");
         String ip = actionRequest.getParameter("ip");
+        int port = Integer.parseInt(actionRequest.getParameter("port"));
         String password = actionRequest.getParameter("password");
         String username = actionRequest.getParameter("username");
         // encrypt the password
@@ -798,7 +811,7 @@
         try
         {
             PreparedStatement pStmt = con
-                    .prepareStatement("INSERT INTO servers (name, ip, username, password, modified, last_seen, added) VALUES ('"
+                    .prepareStatement("INSERT INTO servers (name, ip, username, password, modified, last_seen, added, port) VALUES ('"
                             + name
                             + "','"
                             + ip
@@ -806,7 +819,7 @@
                             + username
                             + "','"
                             + password
-                            + "',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)");
+                            + "',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP," + port + ")");
             pStmt.executeUpdate();
             actionResponse.setRenderParameter("message",
                     "<font color=\"green\"><strong><li>Server " + name + " at "
@@ -1086,8 +1099,7 @@
         }
     }
 
-    private String startTrackingMbean(String server_id, String mbean)
-    {
+    private String startTrackingMbean(String server_id, String mbean) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
         MRCConnector mrc = null;
@@ -1096,14 +1108,12 @@
         String server_ip = null;
         String username = null;
         String password = null;
-        try
-        {
-            pStmt = con
-                    .prepareStatement("SELECT * FROM servers WHERE server_id="
-                            + server_id);
+        int port = -1;
+        // fetch server information
+        try {
+            pStmt = con.prepareStatement("SELECT * FROM servers WHERE server_id=" + server_id);
             rs = pStmt.executeQuery();
-            if (!rs.next())
-            {
+            if (!rs.next()) {
                 return "<font color=\"red\"><strong><li>DATABASE ERROR: Server id "
                         + server_id
                         + " not found in database</li></strong></font>";
@@ -1111,53 +1121,44 @@
             server_ip = rs.getString("ip");
             password = rs.getString("password");
             username = rs.getString("username");
-        }
-        catch (SQLException e)
-        {
+            port = rs.getInt("port");
+        } catch (SQLException e) {
             return "<font color=\"red\"><strong><li>DATABASE ERROR: "
                     + e.getMessage() + "</li></strong></font>";
         }
-        try
-        {
+        // attempt to connect to the mrc server
+        try {
             con.close();
-            mrc = new MRCConnector(server_ip, username, password);
-        }
-        catch (Exception e)
-        {
+            mrc = new MRCConnector(server_ip, username, password, port);
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to connect to server "
                     + server_ip
                     + ": "
                     + e.getMessage()
                     + "</li></strong></font>";
         }
-        try
-        {
-            if (mrc.startTrackingMbean(mbean))
-            {
+        
+        // tell the mrc server to start tracking an mbean
+        try {
+            if (mrc.startTrackingMbean(mbean)) {
                 String mbarr[] = mbean.split("name=");
                 return "<font color=\"green\"><strong><li>MBean " + mbarr[1]
                         + " tracking on server " + rs.getString("name")
                         + "</li></strong></font>";
-            }
-            else
-            {
+            } else {
                 String mbarr[] = mbean.split("name=");
                 return "<font color=\"red\"><strong><li>ERROR: MBean "
                         + mbarr[1] + " could <b>NOT</b> be tracked on server "
                         + rs.getString("name") + "</li></strong></font>";
             }
-
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: MBean " + mbean
                     + " could <b>NOT</b> be tracked on server " + server_ip
                     + ": " + e.getMessage() + "</li></strong></font>";
         }
     }
 
-    private String stopTrackingMbean(String server_id, String mbean)
-    {
+    private String stopTrackingMbean(String server_id, String mbean) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
         MRCConnector mrc = null;
@@ -1166,14 +1167,14 @@
         String server_ip = null;
         String username = null;
         String password = null;
-        try
-        {
+        int port = -1;
+        // fetch server's information
+        try {
             pStmt = con
                     .prepareStatement("SELECT * FROM servers WHERE server_id="
                             + server_id);
             rs = pStmt.executeQuery();
-            if (!rs.next())
-            {
+            if (!rs.next()) {
                 return "<font color=\"red\"><strong><li>DATABASE ERROR: Server id "
                         + server_id
                         + " not found in database</li></strong></font>";
@@ -1181,46 +1182,37 @@
             server_ip = rs.getString("ip");
             password = rs.getString("password");
             username = rs.getString("username");
-        }
-        catch (SQLException e)
-        {
+            port = rs.getInt("port");
+        } catch (SQLException e) {
             return "<font color=\"red\"><strong><li>DATABASE ERROR: "
                     + e.getMessage() + "</li></strong></font>";
         }
-        try
-        {
+        // attempt to connect to the mrc-server
+        try {
             con.close();
-            mrc = new MRCConnector(server_ip, username, password);
-        }
-        catch (Exception e)
-        {
+            mrc = new MRCConnector(server_ip, username, password, port);
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to connect to server "
                     + server_ip
                     + ": "
                     + e.getMessage()
                     + "</li></strong></font>";
         }
-        try
-        {
-            if (mrc.stopTrackingMbean(mbean))
-            {
+        // tell the mrc-server to stop tracking some mbean
+        try {
+            if (mrc.stopTrackingMbean(mbean)) {
                 String mbarr[] = mbean.split("name=");
                 return "<font color=\"green\"><strong><li>MBean " + mbarr[1]
                         + " removed from tracking on server "
                         + rs.getString("name") + "</li></strong></font>";
-            }
-            else
-            {
+            } else {
                 String mbarr[] = mbean.split("name=");
                 return "<font color=\"red\"><strong><li>ERROR: MBean "
                         + mbarr[1]
                         + " could <b>NOT</b> be removed from tracking on server "
                         + rs.getString("name") + "</li></strong></font>";
             }
-
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: MBean " + mbean
                     + " could <b>NOT</b> be removed from tracking on server "
                     + server_ip + ": " + e.getMessage()
@@ -1238,14 +1230,14 @@
         String server_ip = null;
         String username = null;
         String password = null;
-        try
-        {
+        int port = -1;
+        // fetch the server's information
+        try {
             pStmt = con
                     .prepareStatement("SELECT * FROM servers WHERE server_id="
                             + server_id);
             rs = pStmt.executeQuery();
-            if (!rs.next())
-            {
+            if (!rs.next()) {
                 return "<font color=\"red\"><strong><li>DATABASE ERROR: Server id "
                         + server_id
                         + " not found in database</li></strong></font>";
@@ -1253,39 +1245,33 @@
             server_ip = rs.getString("ip");
             password = rs.getString("password");
             username = rs.getString("username");
-        }
-        catch (SQLException e)
-        {
+            port = rs.getInt("port");
+        } catch (SQLException e) {
             return "<font color=\"red\"><strong><li>DATABASE ERROR: "
                     + e.getMessage() + "</li></strong></font>";
         }
-        try
-        {
+        // attempt to connect to the mrc-server
+        try {
             con.close();
-            mrc = new MRCConnector(server_ip, username, password);
-        }
-        catch (Exception e)
-        {
+            mrc = new MRCConnector(server_ip, username, password, port);
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to connect to server "
                     + server_ip
                     + ": "
                     + e.getMessage()
                     + "</li></strong></font>";
         }
-        try
-        {
-            if (mrc.stopSnapshotThread())
+        // tell the mrc-server to stop taking snapshots
+        try {
+            if (mrc.stopSnapshotThread()) {
                 return "<font color=\"green\"><strong><li>Snapshot thread stopped on server "
                         + rs.getString("name") + "</li></strong></font>";
-            else
-            {
+            } else {
                 return "<font color=\"red\"><strong><li>ERROR: Snapshot thread could <b>NOT</b> be stopped on server "
                         + rs.getString("name") + "</li></strong></font>";
             }
 
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Snapshot thread could <b>NOT</b> be stopped on server "
                     + server_ip
                     + ": "
@@ -1294,8 +1280,7 @@
         }
     }
 
-    private String startThread(String server_id, Long snapshotDuration)
-    {
+    private String startThread(String server_id, Long snapshotDuration) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
         MRCConnector mrc = null;
@@ -1304,14 +1289,14 @@
         String server_ip = null;
         String username = null;
         String password = null;
-        try
-        {
+        int port = -1;
+        // fetch the server's information
+        try {
             pStmt = con
                     .prepareStatement("SELECT * FROM servers WHERE server_id="
                             + server_id);
             rs = pStmt.executeQuery();
-            if (!rs.next())
-            {
+            if (!rs.next()) {
                 return "<font color=\"red\"><strong><li>DATABASE ERROR: Server id "
                         + server_id
                         + " not found in database</li></strong></font>";
@@ -1319,42 +1304,32 @@
             server_ip = rs.getString("ip");
             password = rs.getString("password");
             username = rs.getString("username");
-        }
-        catch (SQLException e)
-        {
+            port = rs.getInt("port");
+        } catch (SQLException e) {
             return "<font color=\"red\"><strong><li>DATABASE ERROR: "
                     + e.getMessage() + "</li></strong></font>";
         }
-        try
-        {
+        // attempt to connect to the mrc-server
+        try {
             con.close();
-            mrc = new MRCConnector(server_ip, username, password);
-        }
-        catch (Exception e)
-        {
+            mrc = new MRCConnector(server_ip, username, password, port);
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to connect to server "
                     + server_ip
                     + ": "
                     + e.getMessage()
                     + "</li></strong></font>";
         }
-        try
-        {
-
-            if (mrc.startSnapshotThread(new Long(snapshotDuration)))
-            {
+        // tell the mrc-server to start the collection of statistics
+        try {
+            if (mrc.startSnapshotThread(new Long(snapshotDuration))) {
                 return "<font color=\"green\"><strong><li>Snapshot thread started on server "
                         + rs.getString("name") + "</li></strong></font>";
-            }
-            else
-            {
+            } else {
                 return "<font color=\"red\"><strong><li>ERROR: Snapshot thread could <b>NOT</b> be started on server "
                         + rs.getString("name") + "</li></strong></font>";
             }
-
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Snapshot thread could <b>NOT</b> be started on server "
                     + server_ip
                     + ": "

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/java/org/apache/geronimo/plugins/monitoring/client/util/DBManager.java Thu Dec  6 09:33:23 2007
@@ -112,9 +112,10 @@
             PreparedStatement pStmt = con
                     .prepareStatement("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(128) UNIQUE NOT NULL,"
+                            + "enabled     SMALLINT DEFAULT 1 NOT NULL,"
+                            + "name        VARCHAR(128) DEFAULT NULL,"
+                            + "ip          VARCHAR(128) UNIQUE NOT NULL,"
+                            + "port        INT NOT NULL,"
                             + "username    VARCHAR(128) NOT NULL,"
                             + "password    VARCHAR(1024) NOT NULL,"
                             + "added       TIMESTAMP NOT NULL,"

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp Thu Dec  6 09:33:23 2007
@@ -75,7 +75,10 @@
 {
     TreeMap <String,String> trackedBeansMap = null;
     try {
-        MRCConnection = new MRCConnector(rs.getString("ip"), rs.getString("username"), rs.getString("password"));
+        MRCConnection = new MRCConnector(       rs.getString("ip"), 
+                                                rs.getString("username"), 
+                                                rs.getString("password"),
+                                                rs.getInt("port"));
         trackedBeansMap = MRCConnection.getTrackedBeansMap();
         serverIds.add(rs.getString("server_id"));
         serverNames.add(rs.getString("name") +" - "+rs.getString("ip"));
@@ -131,7 +134,8 @@
 function show(x) {
 document.getElementById(x).style.display='';
 }
-function validate() {
+function validate() 
+{
    if (! (document.addGraph.name.value  
       && document.addGraph.dataname1.value
       && document.addGraph.mbean.value
@@ -153,21 +157,41 @@
             alert("Operation must use at least one math symbol (+, -, *, /)");
             return false;
         }
-       if (document.addGraph.othermath.value.length > 1) 
-       {
-        if (!document.addGraph.othermath.value.charAt(0).match(mathChars) || !document.addGraph.othermath.value.charAt(document.addGraph.othermath.value.length - 1).match(mathChars))
+        if (document.addGraph.dataname2.value != "")
         {
-            alert("Operation must create a valid formula");
-            return false;
+            if (document.addGraph.othermath.value.length > 1) 
+            {
+                if (!document.addGraph.othermath.value.charAt(0).match(mathChars) || !document.addGraph.othermath.value.charAt(document.addGraph.othermath.value.length - 1).match(mathChars))
+                {
+                    alert("Operation must create a valid formula");
+                    return false;
+                }
+            }
+                if (document.addGraph.othermath.value.length == 2) 
+                {
+                    alert("Operation must create a valid formula");
+                    return false;
+                }
         }
+        else
+        {
+            if (document.addGraph.othermath.value.length > 1) 
+            {
+                if (!document.addGraph.othermath.value.charAt(0).match(mathChars) || document.addGraph.othermath.value.charAt(document.addGraph.othermath.value.length - 1).match(mathChars))
+                {
+                    alert("Operation must create a valid formula");
+                    return false;
+                }
+            }
+            else if (document.addGraph.othermath.value.length == 1) 
+            {
+                alert("Operation must create a valid formula");
+                return false;
+            }
         }
-        if (document.addGraph.othermath.value.length == 2) 
-       {
-            alert("Operation must create a valid formula");
-            return false;
-       }
-   }
-   return;
+        
+    }
+       return;
 }
 function noAlpha(obj){
     reg = /[^0-9]/g;

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp Thu Dec  6 09:33:23 2007
@@ -31,7 +31,6 @@
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
-<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <portlet:defineObjects/>
 
 <%
@@ -42,18 +41,15 @@
 String username = (String) request.getAttribute("username");
 String password = (String) request.getAttribute("password");
 String password2 = (String) request.getAttribute("password2");
-if(message == null)
-    message = "";
-if(name == null)
-    name = "";
-if(ip == null)
-    ip = "";
-if(username == null)
-    username = "";
-if(password == null)
-    password = "";
-if(password2 == null)
-    password2 = "";
+String port = (String) request.getAttribute("port");
+
+if(message == null)     message = "";
+if(name == null)        name = "";
+if(ip == null)          ip = "";
+if(username == null)    username = "";
+if(password == null)    password = "";
+if(password2 == null)   password2 = "";
+if(port == null)        port = "4201";
 %>
 <!-- <head> -->
 
@@ -73,9 +69,10 @@
 	if (! (document.addServer.name.value 
 		&& document.addServer.ip.value 
 		&& document.addServer.username.value
-		&& document.addServer.password.value ))
+		&& document.addServer.password.value
+		&& document.addServer.port.value ))
 	{
-		alert("Name, Address, Username, and Password are all required fields");
+		alert("Name, Address, Port, Username, and Password are all required fields");
 		return false;
 	}
 	if (document.addServer.password.value != document.addServer.password2.value)
@@ -123,7 +120,13 @@
     <tr>
       <td>IP/Hostname:</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="text" name="ip" value=<%= "\"" + ip + "\"" %>/></td>
+      <td align="right"><input type="text" name="ip" value="<%=ip%>"/></td>
+      <td></td>
+    </tr>
+    <tr>
+      <td>Port:</td>
+      <td>&nbsp;</td>
+      <td align="right"><input type="text" name="port"  onKeyUp='noAlpha(this)' onKeyPress='noAlpha(this)' value="<%=port%>"/></td>
       <td></td>
     </tr>
     <tr>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringAddView.jsp Thu Dec  6 09:33:23 2007
@@ -32,7 +32,6 @@
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
-<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <portlet:defineObjects/>
 
 <%

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp Thu Dec  6 09:33:23 2007
@@ -97,7 +97,10 @@
 {
     TreeMap <String,String> trackedBeansMap = null;
     try {
-        MRCConnection = new MRCConnector(rs.getString("ip"), rs.getString("username"), rs.getString("password"));
+        MRCConnection = new MRCConnector(           rs.getString("ip"), 
+                                                    rs.getString("username"), 
+                                                    rs.getString("password"),
+                                                    rs.getInt("port"));
         trackedBeansMap = MRCConnection.getTrackedBeansMap();
         serverIds.add(rs.getString("server_id"));
         serverNames.add(rs.getString("name") +" - "+rs.getString("ip"));

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp Thu Dec  6 09:33:23 2007
@@ -1,4 +1,5 @@
 
+
 <%--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -49,22 +50,16 @@
 String password2 = (String) request.getAttribute("password2");
 String snapshot = (String) request.getAttribute("snapshot");
 String retention = (String) request.getAttribute("retention");
-if(message == null)
-    message = "";
-if(name == null)
-    name = "";
-if(ip == null)
-    ip = "";
-if(username == null)
-    username = "";
-if(password == null)
-    password = "";
-if(password2 == null)
-    password2 = "";
-if(snapshot == null)
-    snapshot = "";
-if(retention == null)
-    retention = "";
+String port = (String)request.getAttribute("port");
+if(message == null)     message = "";
+if(name == null)        name = "";
+if(ip == null)          ip = "";
+if(username == null)    username = "";
+if(password == null)    password = "";
+if(password2 == null)   password2 = "";
+if(snapshot == null)    snapshot = "";
+if(retention == null)   retention = "";
+if(port == null)        port = "";
 
 DBManager DBase = new DBManager();
 Connection con = DBase.getConnection();
@@ -86,6 +81,7 @@
         name = rs.getString("name");
         username = rs.getString("username");
         ip = rs.getString("ip");
+        port = rs.getString("port");
         dbPassword = (String)EncryptionManager.decrypt(rs.getString("password"));
     }
     added = rs.getString("added");
@@ -95,12 +91,12 @@
     try {
         // close connection before using the MRCConnector
         con.close();
-        mrc = new MRCConnector(ip, username, password);
+        mrc = new MRCConnector(ip, username, password, Integer.parseInt(port));
     } catch (Exception e) {
         // the password supplied by the user doesn't work
         try {
             if(retention.equals("") || snapshot.equals("")) {
-                mrc = new MRCConnector(ip, username, dbPassword);
+                mrc = new MRCConnector(ip, username, dbPassword, Integer.parseInt(port));
 		        // get the snapshot on the first call or any subsequent valid connections
 		        snapshot = snapshot == "" ?  "" + mrc.getSnapshotDuration() / 1000 / 60 : snapshot;
 		        // get the retention on the first call or any subsequent valid connection
@@ -130,9 +126,10 @@
    if (! (document.editServer.name.value 
       && document.editServer.ip.value 
       && document.editServer.username.value
-      && document.editServer.snapshot.value ))
+      && document.editServer.snapshot.value 
+      && document.editServer.port.value))
    {
-      alert("Name, Address, Username, and Snapshot Duration are all required fields.");
+      alert("Name, Address, Port, Username, and Snapshot Duration are all required fields.");
       return false;
    }
    if (document.editServer.password.value != document.editServer.password2.value)
@@ -218,6 +215,12 @@
       <td>IP/Hostname:</td>
       <td>&nbsp;</td>
       <td align="right"><input type="text" name="ip" value=<%= "\"" + ip + "\"" %>/></td>
+      <td></td>
+    </tr>
+    <tr>
+      <td>Port:</td>
+      <td>&nbsp;</td>
+      <td align="right"><input type="text" name="port" onKeyUp='noAlpha(this)' onKeyPress='noAlpha(this)' value=<%= "\"" + port + "\"" %>/></td>
       <td></td>
     </tr>
     <%

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringEditView.jsp Thu Dec  6 09:33:23 2007
@@ -32,7 +32,6 @@
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
-<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <portlet:defineObjects/>
 
 <%

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringGraphs.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringGraphs.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringGraphs.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringGraphs.jsp Thu Dec  6 09:33:23 2007
@@ -23,7 +23,6 @@
 <%@ page import="java.sql.PreparedStatement" %>
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
-<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
 <portlet:defineObjects/>

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp Thu Dec  6 09:33:23 2007
@@ -95,6 +95,7 @@
  // data structure to store the server's info
  class ServerInfo {
      public String ip;
+     public int port;
      public String username;
      public String password;
      public String server_id;
@@ -112,11 +113,13 @@
      s.server_id = rs.getString("server_id");
      s.name = rs.getString("name");
      s.enabled = rs.getInt("enabled") == 1 ? true : false;
+     s.port = rs.getInt("port");
      serverInfos.add( s );
  }
  // for each server, draw it
  for(int i = 0 ; i < serverInfos.size(); i++) {
      String ip = serverInfos.get(i).ip;
+     int port = serverInfos.get(i).port;
      String username = serverInfos.get(i).username;
      String password = serverInfos.get(i).password;
      String server_id = serverInfos.get(i).server_id;
@@ -128,7 +131,7 @@
      Long snapshotDuration = new Long(0);
      if (enabled) {
 	     try {
-	         mrc = new MRCConnector(ip, username, password);
+	         mrc = new MRCConnector(ip, username, password, port);
 	         online = true;
 	     } catch (Exception e) {
 	         online = false;

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp Thu Dec  6 09:33:23 2007
@@ -60,6 +60,7 @@
  // data structure to store the server's info
  class ServerInfo {
      public String ip;
+     public int port;
      public String username;
      public String password;
      public String server_id;
@@ -77,6 +78,7 @@
      s.server_id = rs.getString("server_id");
      s.name = rs.getString("name");
      s.enabled = rs.getInt("enabled") == 1 ? true : false;
+     s.port = rs.getInt("port");
      serverInfos.add( s );
  }
  // for each server, draw it
@@ -85,6 +87,7 @@
      String username = serverInfos.get(i).username;
      String password = serverInfos.get(i).password;
      String server_id = serverInfos.get(i).server_id;
+     int port = serverInfos.get(i).port;
      boolean enabled = serverInfos.get(i).enabled;
      String name = serverInfos.get(i).name;
      boolean online = false;
@@ -93,7 +96,7 @@
      Long snapshotDuration = new Long(0);
      if (enabled) {
 	     try {
-	         mrc = new MRCConnector(ip, username, password);
+	         mrc = new MRCConnector(ip, username, password, port);
 	         online = true;
 	     } catch (Exception e) {
 	         online = false;

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp Thu Dec  6 09:33:23 2007
@@ -57,11 +57,11 @@
 PreparedStatement pStmt = con.prepareStatement("SELECT * FROM servers WHERE enabled=1 AND server_id="+server_id);
 ResultSet rs = pStmt.executeQuery();
 
-if (rs.next())
-{
+if (rs.next()) {
     TreeMap <String,String> availableBeansMap = null;
     TreeMap <String,String> trackedBeansMap = null;
     String ip = rs.getString("ip");
+    int port = rs.getInt("port");
     String username = rs.getString("username");
     String name = rs.getString("name");
     String password = rs.getString("password");
@@ -71,15 +71,7 @@
     long retention = -1;
     rs.close();
     try {
-        mrc = new MRCConnector(ip, username, password);
-        
-        //TODO: Fix update here
-        //DBase = new DBManager();
-        //con = DBase.getConnection();
-        //pStmt = con.prepareStatement("UPDATE servers SET last_seen=CURRENT_TIMESTAMP WHERE server_id="+server_id);
-        //pStmt.executeUpdate();
-        //con.close();
-        
+        mrc = new MRCConnector(ip, username, password, port);
         availableBeansMap = mrc.getFreeStatisticsProviderBeanNamesMap();
         retention = mrc.getSnapshotRetention();
         trackedBeansMap = mrc.getTrackedBeansMap();
@@ -88,9 +80,7 @@
             collecting = true;
         else
             collecting = false;
-    }
-    catch (Exception e)
-    {
+    } catch (Exception e) {
         isOnline = false;
         collecting = false;
         message = message + "<br><font color='red'><strong><li>Server is offline</li></strong></font>";

Modified: geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViews.jsp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViews.jsp?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViews.jsp (original)
+++ geronimo/sandbox/monitoring/client/client-war/src/main/webapp/WEB-INF/view/monitoringViews.jsp Thu Dec  6 09:33:23 2007
@@ -23,7 +23,6 @@
 <%@ page import="java.sql.PreparedStatement" %>
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
-<%@ page import="org.apache.geronimo.plugins.monitoring.client.MRCConnector" %>
 <%@ page import="org.apache.geronimo.plugins.monitoring.client.util.*" %>
 <%@ page import="org.apache.geronimo.console.util.PortletManager" %>
 <portlet:defineObjects/>

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java (original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/MasterRemoteControl.java Thu Dec  6 09:33:23 2007
@@ -102,9 +102,10 @@
     // mangement ejb - use this to do the monitoring
     private static Management mejb = null;
     
-    // credentials for snapshot thread
+    // credentials for snapshot processor
     private static String username = null;
     private static String password = null;;
+    private static int port = -1;
 
     // inject Data Sources
     @Resource(name="jdbc/ActiveDS") private DataSource activeDS;
@@ -157,6 +158,7 @@
             // save credentials
             this.username = username;
             this.password = password;
+            this.port = port;
 
         } catch(Exception e) {
             log.error(e.getMessage(), e);

Modified: geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotProcessor.java?rev=601793&r1=601792&r2=601793&view=diff
==============================================================================
--- geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotProcessor.java (original)
+++ geronimo/sandbox/monitoring/mrc-server/mrc-ejb/src/main/java/org/apache/geronimo/monitor/snapshot/SnapshotProcessor.java Thu Dec  6 09:33:23 2007
@@ -166,14 +166,8 @@
      * @return An instance of a MRC. 
      */
     public static MasterRemoteControlLocal getMRC(String username, String password) {
-        // TODO:
-        //      Need to find a way to grab the MRC using LocalInitialContext
-        //      so it can get through security and be more efficient.
         Properties props = new Properties();
         props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
-        
-//        props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
-//        props.setProperty(Context.PROVIDER_URL, "127.0.0.1:4201");
         props.setProperty(Context.SECURITY_PRINCIPAL, username);
         props.setProperty(Context.SECURITY_CREDENTIALS, password);
         props.setProperty("openejb.authentication.realmName", "geronimo-admin");



Mime
View raw message