geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecr...@apache.org
Subject svn commit: r616237 - in /geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main: java/org/apache/geronimo/monitoring/console/ webapp/WEB-INF/view/
Date Tue, 29 Jan 2008 10:21:06 GMT
Author: ecraig
Date: Tue Jan 29 02:21:04 2008
New Revision: 616237

URL: http://svn.apache.org/viewvc?rev=616237&view=rev
Log:
GERONIMO-3730
monitoring plugin to support jmx connections in mconsole

Added base methods and such for JMX connections from client side
EJB still works flawlessly after these changes, some quirks with JMX still to be hammered
out



Added:
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
      - copied, changed from r616184, geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnectorEJB.java
Removed:
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnectorEJB.java
Modified:
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/GraphsBuilder.java
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
    geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/GraphsBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/GraphsBuilder.java?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/GraphsBuilder.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/GraphsBuilder.java
Tue Jan 29 02:21:04 2008
@@ -35,7 +35,7 @@
     private String ip = new String();
     private int timeFrame;
     private int snapCount;
-    private MRCConnectorEJB mrc = new MRCConnectorEJB();
+    private MRCConnector mrc = new MRCConnector();
     private Connection con;
 
     // constructor
@@ -80,7 +80,8 @@
                 String username = rsServer.getString("username");
                 String password = rsServer.getString("password");
                 int port = rsServer.getInt("port");
-                // close the connection before calling the MRCConnectorEJB because
+                int protocol = rsServer.getInt("protocol");
+                // close the connection before calling the MRCConnector because
                 // it opens another
                 // connection to the db to update the SERVERS.last_seen
                 // attribute
@@ -89,8 +90,7 @@
                 } catch (Exception e) {
                     throw e;
                 }
-                mrc = new MRCConnectorEJB(ip, username, password, port);
-
+                mrc = new MRCConnector(ip, username, password, port, protocol);
                 snapCount = timeFrame
                         / java.lang.Integer
                                 .valueOf(java.lang.Long

Copied: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
(from r616184, geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnectorEJB.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java?p2=geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java&p1=geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnectorEJB.java&r1=616184&r2=616237&rev=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnectorEJB.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MRCConnector.java
Tue Jan 29 02:21:04 2008
@@ -23,12 +23,19 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
 import javax.naming.Context;
 import javax.naming.InitialContext;
 
@@ -37,44 +44,71 @@
 
 import org.apache.geronimo.util.EncryptionManager;
 
-public class MRCConnectorEJB {
+public class MRCConnector {
 
+    private static final String PATH = "geronimo:ServiceModule=org.apache.geronimo.plugins.monitoring/agent-car-jmx/2.1-SNAPSHOT/car,J2EEServer=geronimo,name=MasterRemoteControlJMX,j2eeType=GBean";
+    private static MBeanServerConnection mbServerConn;
     private MasterRemoteControlRemote mrc = null;
+    private int Protocol = 0;
 
-    MRCConnectorEJB() {
+    MRCConnector() {
 
     }
 
     /**
      * @param ip -
-     *                IP address of mrc-server to connect to
+     *            IP address of mrc-server to connect to
      * @param userName -
-     *                Username for JMX connection to the host
+     *            Username for JMX connection to the host
      * @param password -
-     *                Password for JMX connection to the host
+     *            Password for JMX connection to the host
      * @throws Exception -
-     *                 If the connection to mrc-server fails
+     *             If the connection to mrc-server fails
      */
-    public MRCConnectorEJB(String ip, String userName, String password, int port)
-            throws Exception {
+    public MRCConnector(String ip, String userName, String password, int port,
+            int protocol) throws Exception {
         // decrypt the password
         password = (String) EncryptionManager.decrypt(password);
-        try {
-            Properties props = new Properties();
-            props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
-                    "org.apache.openejb.client.RemoteInitialContextFactory");
-            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");
-            Context ic = new InitialContext(props);
-            mrc = (MasterRemoteControlRemote) ic.lookup("ejb/mgmt/MRCRemote");
-            mrc.setUpMEJB(userName, password);
-        } catch (Exception e) {
-            throw e;
+        Protocol = protocol;
+
+        if (Protocol == 1) {
+
+            try {
+                Properties props = new Properties();
+                props
+                        .setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                                "org.apache.openejb.client.RemoteInitialContextFactory");
+                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");
+                Context ic = new InitialContext(props);
+                mrc = (MasterRemoteControlRemote) ic
+                        .lookup("ejb/mgmt/MRCRemote");
+                mrc.setUpMEJB(userName, password);
+            } catch (Exception e) {
+                throw e;
+            }
+
+        } else {
+            try {
+                JMXServiceURL serviceURL = new JMXServiceURL(
+                        "service:jmx:rmi:///jndi/rmi://" + ip + ":" + port
+                                + "/JMXConnector");
+                Hashtable<String, Object> env = new Hashtable<String, Object>();
+                String[] credentials = new String[2];
+                credentials[0] = userName;
+                credentials[1] = password;
+                env.put(JMXConnector.CREDENTIALS, credentials);
+                JMXConnector connector = JMXConnectorFactory.connect(
+                        serviceURL, env);
+                mbServerConn = connector.getMBeanServerConnection();
+            } catch (Exception e) {
+                throw e;
+            }
+
         }
         // when the code has reach this point, a connection was successfully
         // established
@@ -106,17 +140,25 @@
      * @return - Returns an Long representing the current snapshot duration set
      *         on the server side
      * @throws Exception -
-     *                 If the connection to the MRC-Server fails
+     *             If the connection to the MRC-Server fails
      */
     public Long getSnapshotDuration() throws Exception {
-        return mrc.getSnapshotDuration();
+        if (Protocol == 1) {
+
+            return mrc.getSnapshotDuration();
+
+        } else {
+
+            return (Long) mbServerConn.invoke(new ObjectName(PATH),
+                    "getSnapshotDuration", new Object[] {}, new String[] {});
+        }
     }
 
     /**
      * @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
+     *             If the connection to the MRC-Server fails
      */
     @SuppressWarnings("unchecked")
     public HashMap<String, ArrayList<String>> getDataNameList()
@@ -124,10 +166,23 @@
 
         HashMap<String, ArrayList<String>> DataNameList = new HashMap<String,
ArrayList<String>>();
 
-        try {
-            DataNameList = mrc.getAllSnapshotStatAttributes();
-        } catch (Exception e) {
-            e.printStackTrace();
+        if (Protocol == 1) {
+
+            try {
+                DataNameList = mrc.getAllSnapshotStatAttributes();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        } else {
+            try {
+                DataNameList = (HashMap<String, ArrayList<String>>) mbServerConn
+                        .invoke(new ObjectName(PATH),
+                                "getAllSnapshotStatAttributes",
+                                new Object[] {}, new String[] {});
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
         // Strip out snapshot_date and snapshot_time, we know these exist
         for (Iterator<String> it = DataNameList.keySet().iterator(); it
@@ -141,19 +196,29 @@
 
     /**
      * @param snapCount -
-     *                Number of snapshots to request from the server
+     *            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.
+     *            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
+     *             If the connection to the MRC-Server fails
      */
     @SuppressWarnings("unchecked")
     public ArrayList<HashMap<String, HashMap<String, Object>>> getSnapshots(
             int snapCount, int skipCount) throws Exception {
-        ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList
= mrc
-                .fetchSnapshotData(snapCount, skipCount);
+        ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList
= null;
+        if (Protocol == 1) {
+
+            snapshotList = mrc.fetchSnapshotData(snapCount, skipCount);
+
+        } else {
+            snapshotList = (ArrayList<HashMap<String, HashMap<String, Object>>>)
mbServerConn
+                    .invoke(new ObjectName(PATH), "fetchSnapshotData",
+                            new Object[] { snapCount, skipCount },
+                            new String[] { "java.lang.Integer",
+                                    "java.lang.Integer" });
+        }
         // Check if snapshotList is empty
         if (snapshotList.size() == 0) {
             return snapshotList;
@@ -291,8 +356,21 @@
     public TreeMap<Long, Long> getSpecificStatistics(String mbeanName,
             String statsName, int snapCount, int skipCount, boolean showArchive)
             throws Exception {
-        TreeMap<Long, Long> snapshotList = mrc.getSpecificStatistics(mbeanName,
-                statsName, snapCount, skipCount, showArchive);
+        TreeMap<Long, Long> snapshotList = null;
+        if (Protocol == 1) {
+
+            snapshotList = mrc.getSpecificStatistics(mbeanName, statsName,
+                    snapCount, skipCount, showArchive);
+
+        } else {
+            snapshotList = (TreeMap<Long, Long>) mbServerConn.invoke(
+                    new ObjectName(PATH), "getSpecificStatistics",
+                    new Object[] { mbeanName, statsName, snapCount, skipCount,
+                            showArchive }, new String[] { "java.lang.String",
+                            "java.lang.String", "java.lang.Integer",
+                            "java.lang.Integer", "java.lang.Boolean" });
+
+        }
         // Check if snapshotList is empty
         if (snapshotList.size() == 0) {
             return snapshotList;
@@ -308,7 +386,8 @@
             // Calculate appropriate time, add it to the submap, then
             // add
             // that to the tempMap
-            snapshotList.put((timeFix - (getSnapshotDuration() * skipCount)), new Long(0));
+            snapshotList.put((timeFix - (getSnapshotDuration() * skipCount)),
+                    new Long(0));
         }
 
         /*
@@ -324,8 +403,7 @@
             Long tempLong1 = tempArray.get(i);
             Long tempLong2 = tempArray.get(i - 1);
             // here is where we will in missing data
-            while ((((tempLong1 / 1000) / 60) - ((tempLong2 / 1000) / 60) > 
-                    (((getSnapshotDuration() / 1000) / 60) * skipCount))
+            while ((((tempLong1 / 1000) / 60) - ((tempLong2 / 1000) / 60) > (((getSnapshotDuration()
/ 1000) / 60) * skipCount))
                     && i > 0) {
                 tempLong1 = tempLong1 - (getSnapshotDuration() * skipCount);
                 snapshotList.remove(tempArray.get(0));
@@ -342,8 +420,18 @@
             throws Exception {
         int snapCount = 1;
         int skipCount = 1;
-        ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList
= mrc
-                .fetchSnapshotData(snapCount, skipCount);
+        ArrayList<HashMap<String, HashMap<String, Object>>> snapshotList
= null;
+        if (Protocol == 1) {
+
+            snapshotList = mrc.fetchSnapshotData(snapCount, skipCount);
+
+        } else {
+            snapshotList = (ArrayList<HashMap<String, HashMap<String, Object>>>)
mbServerConn
+                    .invoke(new ObjectName(PATH), "fetchSnapshotData",
+                            new Object[] { snapCount, skipCount },
+                            new String[] { "java.lang.Integer",
+                                    "java.lang.Integer" });
+        }
         // Check if snapshotList is empty
         if (snapshotList.size() == 0) {
             return null;
@@ -354,50 +442,106 @@
     /**
      * @return - Returns a boolean indicating successful stop
      * @throws Exception -
-     *                 If the connection to the MRC-Server fails
+     *             If the connection to the MRC-Server fails
      */
     public boolean stopSnapshotThread() throws Exception {
-        return mrc.stopSnapshot();
+        if (Protocol == 1) {
+
+            return mrc.stopSnapshot();
+
+        } else {
+            return (Boolean) mbServerConn.invoke(new ObjectName(PATH),
+                    "stopSnapshot", new Object[] {}, new String[] {});
+        }
     }
 
     /**
      * @return - Returns a boolean indicating successful stop
      * @throws Exception -
-     *                 If the connection to the MRC-Server fails
+     *             If the connection to the MRC-Server fails
      */
     public boolean startSnapshotThread(long time) throws Exception {
-        return mrc.startSnapshot(time);
+        if (Protocol == 1) {
+
+            return mrc.startSnapshot(time);
+
+        } else {
+            return (Boolean) mbServerConn.invoke(new ObjectName(PATH),
+                    "startSnapshot", new Object[] { time },
+                    new String[] { "java.lang.Long" });
+        }
     }
 
     public boolean isSnapshotRunning() {
         boolean running = false;
-        try {
-            running = mrc.isSnapshotRunning();
-        } catch (Exception e) {
-            return false;
+        if (Protocol == 1) {
+
+            try {
+                running = mrc.isSnapshotRunning();
+            } catch (Exception e) {
+                return false;
+            }
+
+        } else {
+            try {
+                running = (Boolean) mbServerConn.invoke(new ObjectName(PATH),
+                        "isSnapshotRunning", new Object[] {}, new String[] {});
+            } catch (Exception e) {
+                return false;
+            }
         }
         return running;
     }
 
     @SuppressWarnings("unchecked")
     public Set<String> getAllMbeanNames() throws Exception {
-        return mrc.getAllMBeanNames();
+        if (Protocol == 1) {
+
+            return mrc.getAllMBeanNames();
+
+        } else {
+            return (Set<String>) mbServerConn.invoke(new ObjectName(PATH),
+                    "getAllMBeanNames", new Object[] {}, new String[] {});
+        }
     }
 
     @SuppressWarnings("unchecked")
     public Set<String> getStatisticsProviderBeanNames() throws Exception {
-        return mrc.getStatisticsProviderMBeanNames();
+        if (Protocol == 1) {
+
+            return mrc.getStatisticsProviderMBeanNames();
+
+        } else {
+            return (Set<String>) mbServerConn.invoke(new ObjectName(PATH),
+                    "getStatisticsProviderMBeanNames", new Object[] {},
+                    new String[] {});
+        }
     }
 
     @SuppressWarnings("unchecked")
     public HashMap<String, ArrayList<String>> getAllSnapshotStatAttributes()
             throws Exception {
-        return mrc.getAllSnapshotStatAttributes();
+        if (Protocol == 1) {
+
+            return mrc.getAllSnapshotStatAttributes();
+
+        } else {
+            return (HashMap<String, ArrayList<String>>) mbServerConn.invoke(
+                    new ObjectName(PATH), "getAllSnapshotStatAttributes",
+                    new Object[] {}, new String[] {});
+        }
     }
 
     @SuppressWarnings("unchecked")
     public Set<String> getTrackedBeans() throws Exception {
-        return mrc.getTrackedMBeans();
+        if (Protocol == 1) {
+
+            return mrc.getTrackedMBeans();
+
+        } else {
+            return (Set<String>) mbServerConn.invoke(new ObjectName(PATH),
+                    "getTrackedBeans", new Object[] {}, new String[] {});
+        }
     }
 
     @SuppressWarnings("unchecked")
@@ -553,30 +697,96 @@
 
     @SuppressWarnings("unchecked")
     public boolean stopTrackingMbean(String MBean) throws Exception {
-        mrc.removeMBeanForSnapshot(MBean);
+        if (Protocol == 1) {
+
+            mrc.removeMBeanForSnapshot(MBean);
+
+        } else {
+            mbServerConn
+                    .invoke(new ObjectName(PATH), "removeMBeanForSnapshot",
+                            new Object[] { MBean },
+                            new String[] { "java.lang.String" });
+
+        }
         return true;
     }
 
     @SuppressWarnings("unchecked")
     public boolean startTrackingMbean(String MBean) throws Exception {
-        mrc.addMBeanForSnapshot(MBean);
+        if (Protocol == 1) {
+
+            mrc.addMBeanForSnapshot(MBean);
+
+        } else {
+            mbServerConn
+                    .invoke(new ObjectName(PATH), "addMBeanForSnapshot",
+                            new Object[] { MBean },
+                            new String[] { "java.lang.String" });
+        }
         return true;
     }
 
     @SuppressWarnings("unchecked")
     public HashMap<String, Long> getStats(String MBean) throws Exception {
-        return mrc.getStats(MBean);
+        if (Protocol == 1) {
+
+            return mrc.getStats(MBean);
+
+        } else {
+            return (HashMap<String, Long>) mbServerConn.invoke(new ObjectName(
+                    PATH), "getStats", new Object[] { MBean },
+                    new String[] { "java.lang.String" });
+        }
     }
 
     public void setSnapshotDuration(long duration) {
-        mrc.setSnapshotDuration(new Long(duration));
+        if (Protocol == 1) {
+
+            mrc.setSnapshotDuration(new Long(duration));
+
+        } else {
+            try {
+
+                mbServerConn.invoke(new ObjectName(PATH),
+                        "setSnapshotDuration",
+                        new Object[] { new Long(duration) },
+                        new String[] { "java.lang.Long" });
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 
     public long getSnapshotRetention() {
-        return Long.parseLong(mrc.getSnapshotRetention());
+        if (Protocol == 1) {
+
+            return Long.parseLong(mrc.getSnapshotRetention());
+
+        } else {
+            try {
+                return Long.parseLong((String) mbServerConn.invoke(
+                        new ObjectName(PATH), "getSnapshotRetention",
+                        new Object[] {}, new String[] {}));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return 0;
     }
 
     public void setSnapshotRetention(int duration) {
-        mrc.setSnapshotRetention(duration);
+        if (Protocol == 1) {
+
+            mrc.setSnapshotRetention(duration);
+
+        } else {
+            try {
+                mbServerConn.invoke(new ObjectName(PATH),
+                        "setSnapshotRetention", new Object[] { duration },
+                        new String[] { "java.lang.Integer" });
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 }

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
Tue Jan 29 02:21:04 2008
@@ -242,15 +242,8 @@
     private String testConnection(String name, String ip, String username,
             String password, int port, int protocol) {
         try {
-            if (protocol == 1)
-            {
-                MRCConnectorEJB mrc = new MRCConnectorEJB(ip, username, password, port);
-            }
-            else if (protocol == 2)
-            {
-                System.out.println("");
-                //TODO: JMX Stuff here
-            }
+            MRCConnector mrc = new MRCConnector(ip, username, password, port, protocol);
+
             return "<font color=\"green\"><strong><li>Connection was successfully
established.</li></strong></font>";
         } catch (Exception e) {
             return "<font color=\"red\"><strong><li>Failed to create a
connection to server.</li></strong></font>";
@@ -665,17 +658,10 @@
             if (snapshot == null || retention == null) {
                 // do not update if we do not know
             } else {
-                if (protocol == 1)
-                {
-                    (new MRCConnectorEJB(ip, username, password, port))
+                    (new MRCConnector(ip, username, password, port, protocol))
                         .setSnapshotDuration(Long.parseLong(snapshot) * 1000 * 60);
-                    (new MRCConnectorEJB(ip, username, password, port))
+                    (new MRCConnector(ip, username, password, port, protocol))
                         .setSnapshotRetention(Integer.parseInt(retention));
-                }
-                else if (protocol == 2)
-                {
-                       //TODO: JMX Here
-                }
             }
             // set success message
             actionResponse
@@ -986,7 +972,7 @@
     private String startTrackingMbean(String server_id, String mbean) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
-        MRCConnectorEJB mrc = null;
+        MRCConnector mrc = null;
         DBManager DBase = new DBManager();
         Connection con = DBase.getConnection();
         String server_ip = null;
@@ -1017,15 +1003,7 @@
         // attempt to connect to the mrc server
         try {
             con.close();
-            if (protocol == 1)
-            {
-                mrc = new MRCConnectorEJB(server_ip, username, password, port);
-            }
-            else if (protocol == 2)
-            {
-                System.out.println("");
-                //TODO: JMX Stuff here
-            }
+            mrc = new MRCConnector(server_ip, username, password, port, protocol);
         } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to
connect to server "
                     + server_ip
@@ -1057,7 +1035,7 @@
     private String stopTrackingMbean(String server_id, String mbean) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
-        MRCConnectorEJB mrc = null;
+        MRCConnector mrc = null;
         DBManager DBase = new DBManager();
         Connection con = DBase.getConnection();
         String server_ip = null;
@@ -1088,15 +1066,7 @@
         // attempt to connect to the mrc-server
         try {
             con.close();
-            if (protocol == 1)
-            {
-                mrc = new MRCConnectorEJB(server_ip, username, password, port);
-            }
-            else if (protocol == 2)
-            {
-                System.out.println("");
-                //TODO: JMX Stuff here
-            }
+                mrc = new MRCConnector(server_ip, username, password, port, protocol);
        } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to
connect to server "
                     + server_ip
@@ -1129,7 +1099,7 @@
     private String stopThread(String server_id) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
-        MRCConnectorEJB mrc = null;
+        MRCConnector mrc = null;
         DBManager DBase = new DBManager();
         Connection con = DBase.getConnection();
         String server_ip = null;
@@ -1160,15 +1130,7 @@
         // attempt to connect to the mrc-server
         try {
             con.close();
-            if (protocol == 1)
-            {
-                mrc = new MRCConnectorEJB(server_ip, username, password, port);
-            }
-            else if (protocol == 2)
-            {
-                System.out.println("");
-                //TODO: JMX Stuff here
-            }
+            mrc = new MRCConnector(server_ip, username, password, port, protocol);
         } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to
connect to server "
                     + server_ip
@@ -1198,7 +1160,7 @@
     private String startThread(String server_id, Long snapshotDuration) {
         PreparedStatement pStmt = null;
         ResultSet rs = null;
-        MRCConnectorEJB mrc = null;
+        MRCConnector mrc = null;
         DBManager DBase = new DBManager();
         Connection con = DBase.getConnection();
         String server_ip = null;
@@ -1229,15 +1191,7 @@
         // attempt to connect to the mrc-server
         try {
             con.close();
-            if (protocol == 1)
-            {
-                mrc = new MRCConnectorEJB(server_ip, username, password, port);
-            }
-            else if (protocol == 2)
-            {
-                System.out.println("");
-                //TODO: JMX Stuff here
-            }
+            mrc = new MRCConnector(server_ip, username, password, port, protocol);
         } catch (Exception e) {
             return "<font color=\"red\"><strong><li>MRC ERROR: Unable to
connect to server "
                     + server_ip

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddGraph.jsp
Tue Jan 29 02:21:04 2008
@@ -30,7 +30,7 @@
 <%@ page import="java.sql.ResultSet"%>
 <%@ page import="java.sql.SQLException"%>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*"%>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB"%>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector"%>
 <portlet:defineObjects />
 
 <%
@@ -45,7 +45,7 @@
             PreparedStatement pStmt = con
                     .prepareStatement("SELECT * FROM servers WHERE enabled=1");
             ResultSet rs = pStmt.executeQuery();
-            MRCConnectorEJB mrc = null;
+            MRCConnector mrc = null;
             ArrayList<String> serverIds = new ArrayList<String>();
             ArrayList<String> serverNames = new ArrayList<String>();
             Long snapshotDuration = 5L;
@@ -73,10 +73,11 @@
 {
     TreeMap <String,String> trackedBeansMap = null;
     try {
-        mrc = new MRCConnectorEJB(       rs.getString("ip"), 
+        mrc = new MRCConnector(       rs.getString("ip"), 
                                                 rs.getString("username"), 
                                                 rs.getString("password"),
-                                                rs.getInt("port"));
+                                                rs.getInt("port"),
+                                                rs.getInt("protocol"));
         trackedBeansMap = mrc.getTrackedBeansMap();
         serverIds.add(rs.getString("server_id"));
         serverNames.add(rs.getString("name") +" - "+rs.getString("ip"));

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringAddServer.jsp
Tue Jan 29 02:21:04 2008
@@ -99,7 +99,12 @@
     reg = /[^0-9]/g;
     obj.value =  obj.value.replace(reg,"");
 }
-
+function setPort() {
+    if (document.addServer.protocol[0].checked == true)
+        document.addServer.port.value = "4201";
+    else
+        document.addServer.port.value = "1099";
+}
 //-->
 </script>
 <!-- </head> -->
@@ -139,7 +144,7 @@
     <tr>
       <td>Protocol</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="radio" name="protocol" value="1" <%if (protocol.equals("1")){
%>checked="checked"<%} %>>EJB <input type="radio" name="protocol" value="2"
<%if (protocol.equals("2")){ %>checked="checked"<%} %>>JMX</td>
+      <td align="right"><input type="radio" name="protocol" onchange='setPort()'
value="1" <%if (protocol.equals("1")){ %>checked="checked"<%} %>>EJB <input
type="radio" name="protocol" onchange='setPort()' value="2" <%if (protocol.equals("2")){
%>checked="checked"<%} %>>JMX</td>
       <td></td>
     </tr>
     <tr>

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditGraph.jsp
Tue Jan 29 02:21:04 2008
@@ -30,7 +30,7 @@
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*" %>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB" %>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
 <portlet:defineObjects/>
 
 <%
@@ -76,7 +76,7 @@
     pStmt = con.prepareStatement("SELECT * FROM servers WHERE enabled=1");
     rs = pStmt.executeQuery();
 
-    MRCConnectorEJB mrc = null;
+    MRCConnector mrc = null;
     Long snapshotDuration = null;
 
     ArrayList<String> serverIds = new ArrayList<String>();
@@ -96,10 +96,11 @@
 {
     TreeMap <String,String> trackedBeansMap = null;
     try {
-        mrc = new MRCConnectorEJB(           rs.getString("ip"), 
+        mrc = new MRCConnector(           rs.getString("ip"), 
                                                     rs.getString("username"), 
                                                     rs.getString("password"),
-                                                    rs.getInt("port"));
+                                                    rs.getInt("port"),
+                                                    rs.getInt("protocol"));
         trackedBeansMap = mrc.getTrackedBeansMap();;
         serverIds.add(rs.getString("server_id"));
         serverNames.add(rs.getString("name") +" - "+rs.getString("ip"));

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringEditServer.jsp
Tue Jan 29 02:21:04 2008
@@ -31,7 +31,7 @@
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*" %>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB" %>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
 <%@ page import="org.apache.geronimo.util.EncryptionManager" %>
 
 <portlet:defineObjects/>
@@ -78,7 +78,7 @@
 
 PreparedStatement pStmt = con.prepareStatement("SELECT * FROM servers WHERE server_id="+server_id);
 ResultSet rs = pStmt.executeQuery();
-MRCConnectorEJB mrc = null;
+MRCConnector mrc = null;
 boolean isOnline = true;
 String added = "";
 String modified = "";
@@ -102,14 +102,14 @@
     last_seen = rs.getString("last_seen");
     enabled = rs.getInt("enabled") == 1 ? true : false;
     try {
-        // close connection before using the MRCConnectorEJB
+        // close connection before using the MRCConnector
         con.close();
-        mrc = new MRCConnectorEJB(ip, username, password, Integer.parseInt(port));
+        mrc = new MRCConnector(ip, username, password, Integer.parseInt(port), Integer.parseInt(protocol));
     } catch (Exception e) {
         // the password supplied by the user doesn't work
         try {
             if(retention.equals("") || snapshot.equals("")) {
-                mrc = new MRCConnectorEJB(ip, username, dbPassword, Integer.parseInt(port));
+                mrc = new MRCConnector(ip, username, dbPassword, Integer.parseInt(port),
Integer.parseInt(protocol));
 		        // 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
@@ -176,7 +176,12 @@
     reg = /[^0-9]/g;
     obj.value =  obj.value.replace(reg,"");
  }
-
+function setPort() {
+    if (document.editServer.protocol[0].checked)
+        document.editServer.port.value = "4201";
+    else
+        document.editServer.port.value = "1099";
+}
 //-->
 </script>
 <!-- </head> -->
@@ -234,7 +239,7 @@
     <tr>
       <td>Protocol</td>
       <td>&nbsp;</td>
-      <td align="right"><input type="radio" name="protocol" value="1" <%if (protocol.equals("1")){
%>checked="checked"<%} %>>EJB <input type="radio" name="protocol" value="2"
<%if (protocol.equals("1")){ %>checked="checked"<%} %>>JMX</td>
+      <td align="right"><input type="radio" name="protocol" onchange='setPort()'
value="1" <%if (protocol.equals("1")){ %>checked="checked"<%} %>>EJB <input
type="radio" name="protocol" onchange='setPort()' value="2" <%if (protocol.equals("2")){
%>checked="checked"<%} %>>JMX</td>
       <td></td>
     </tr>
     <tr>

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
Tue Jan 29 02:21:04 2008
@@ -23,7 +23,7 @@
 <%@ page import="java.sql.PreparedStatement" %>
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB" %>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*" %>
 <portlet:defineObjects/>
 <%
@@ -95,6 +95,7 @@
  class ServerInfo {
      public String ip;
      public int port;
+     public int protocol;
      public String username;
      public String password;
      public String server_id;
@@ -113,12 +114,14 @@
      s.name = rs.getString("name");
      s.enabled = rs.getInt("enabled") == 1 ? true : false;
      s.port = rs.getInt("port");
+     s.protocol = rs.getInt("protocol");
      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;
+     int protocol = serverInfos.get(i).protocol;
      String username = serverInfos.get(i).username;
      String password = serverInfos.get(i).password;
      String server_id = serverInfos.get(i).server_id;
@@ -126,11 +129,11 @@
      String name = serverInfos.get(i).name;
      boolean online = false;
      boolean collecting = false;
-     MRCConnectorEJB mrc = null;
+     MRCConnector mrc = null;
      Long snapshotDuration = new Long(0);
      if (enabled) {
 	     try {
-	         mrc = new MRCConnectorEJB(ip, username, password, port);
+	         mrc = new MRCConnector(ip, username, password, port, protocol);
 	         online = true;
 	     } catch (Exception e) {
 	         online = false;

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringServers.jsp
Tue Jan 29 02:21:04 2008
@@ -22,7 +22,7 @@
 <%@ page import="java.sql.PreparedStatement" %>
 <%@ page import="java.sql.ResultSet" %>
 <%@ page import="java.sql.SQLException" %>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB" %>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*" %>
 <portlet:defineObjects/>
 <%
@@ -60,6 +60,7 @@
  class ServerInfo {
      public String ip;
      public int port;
+     public int protocol;
      public String username;
      public String password;
      public String server_id;
@@ -78,6 +79,7 @@
      s.name = rs.getString("name");
      s.enabled = rs.getInt("enabled") == 1 ? true : false;
      s.port = rs.getInt("port");
+     s.protocol = rs.getInt("protocol");
      serverInfos.add( s );
  }
  // for each server, draw it
@@ -87,15 +89,16 @@
      String password = serverInfos.get(i).password;
      String server_id = serverInfos.get(i).server_id;
      int port = serverInfos.get(i).port;
+     int protocol = serverInfos.get(i).protocol;
      boolean enabled = serverInfos.get(i).enabled;
      String name = serverInfos.get(i).name;
      boolean online = false;
      boolean collecting = false;
-     MRCConnectorEJB mrc = null;
+     MRCConnector mrc = null;
      Long snapshotDuration = new Long(0);
      if (enabled) {
 	     try {
-	         mrc = new MRCConnectorEJB(ip, username, password, port);
+	         mrc = new MRCConnector(ip, username, password, port, protocol);
 	         online = true;
 	     } catch (Exception e) {
 	         online = false;

Modified: geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp?rev=616237&r1=616236&r2=616237&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
(original)
+++ geronimo/server/trunk/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringViewServer.jsp
Tue Jan 29 02:21:04 2008
@@ -32,7 +32,7 @@
 <%@ page import="java.sql.SQLException" %>
 <%@ page import="java.sql.Timestamp" %>
 <%@ page import="org.apache.geronimo.monitoring.console.util.*" %>
-<%@ page import="org.apache.geronimo.monitoring.console.MRCConnectorEJB" %>
+<%@ page import="org.apache.geronimo.monitoring.console.MRCConnector" %>
 <portlet:defineObjects/>
 
 <%
@@ -43,7 +43,7 @@
 DBManager DBase = new DBManager();
 Connection con = DBase.getConnection();
 
-MRCConnectorEJB mrc = null;
+MRCConnector mrc = null;
 
 boolean isOnline = true;
 boolean collecting = false;
@@ -62,6 +62,7 @@
     TreeMap <String,String> trackedBeansMap = null;
     String ip = rs.getString("ip");
     int port = rs.getInt("port");
+    int protocol = rs.getInt("protocol");
     String username = rs.getString("username");
     String name = rs.getString("name");
     String password = rs.getString("password");
@@ -71,7 +72,7 @@
     long retention = -1;
     rs.close();
     try {
-        mrc = new MRCConnectorEJB(ip, username, password, port);
+        mrc = new MRCConnector(ip, username, password, port, protocol);
         availableBeansMap = mrc.getFreeStatisticsProviderBeanNamesMap();
         retention = mrc.getSnapshotRetention();
         trackedBeansMap = mrc.getTrackedBeansMap();



Mime
View raw message