geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r820189 - in /geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main: i18n-resources/ java/org/apache/geronimo/monitoring/console/ java/org/apache/geronimo/monitoring/console/util/ webapp/WEB-INF/view/
Date Wed, 30 Sep 2009 06:55:15 GMT
Author: xuhaihong
Date: Wed Sep 30 06:55:14 2009
New Revision: 820189

URL: http://svn.apache.org/viewvc?rev=820189&view=rev
Log:
GERONIMO-4810 Predefine a "localhost" server with some predefined graphs and views (Patch
from Vanessa)

Modified:
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_en.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_ja.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_zh.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_en.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_ja.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_zh.properties
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/util/DBManager.java
    geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_en.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_en.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_en.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_en.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 monitor.common.st                 = something
 monitor.common.unknown            = Unknown
 monitor.common.view               = Views
+monitor.common.restore            = Reset
 monitor.edit.desc                 = This is the edit page for the Monitoring Portlet
 monitor.edit.msg01                = Click on 'Monitoring → Add Server'. Choose
 monitor.edit.msg02                = The Server 'localhost' will appear 'online' i.e. the
monitoring console can talk to it.

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_ja.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_ja.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_ja.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_ja.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 monitor.common.st                 = 何か記述
 monitor.common.unknown            = 未知
 monitor.common.view               = ビュー
+monitor.common.restore            = Reset
 monitor.edit.desc                 = これはモニタリング・ポートレットの編集画面です
 monitor.edit.msg01                = モニタリングをクリック
→ 新規サーバーの追加を選択
 monitor.edit.msg02                = サーバー 'localhost' はオンラインでしょう。すなわちモニタリング・コンソールは通信する事ができます。\r\n

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_zh.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_zh.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_zh.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/monitor-portlet_zh.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 monitor.common.st                 = 什么
 monitor.common.unknown            = 未知
 monitor.common.view               = 视图
+monitor.common.restore            = 重置
 monitor.edit.desc                 = 这是监控器portlet的编辑页面
 monitor.edit.msg01                = 点击 '监控器 → 添加服务器'.
选择
 monitor.edit.msg02                = 服务器 'localhost'将显示为
'在线'',亦即监控器控制台可以与它交互

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_en.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_en.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_en.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_en.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 mconsole.errorMsg18 = Error encountered while updating graph.
 mconsole.errorMsg19 = Error encountered while deleting graph.
 mconsole.errorMsg20 = Please delete all the graphs belongs to the server before deleting
it.
+mconsole.errorMsg21 = Error encountered while reseting data.
 mconsole.infoMsg01  = Connection was successfully established.
 mconsole.infoMsg02  = Server <b>{0}</b> was successfully enabled.
 mconsole.infoMsg03  = Server <b>{0}</b> was successfully disabled.
@@ -53,3 +54,4 @@
 mconsole.infoMsg14  = Graph <b>{0}</b> has been added.
 mconsole.infoMsg15  = Graph <b>{0}</b> has been updated.
 mconsole.infoMsg16  = Graph <b>{0}</b> has been deleted.
+mconsole.infoMsg17  = Default data was successfully reset.

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_ja.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_ja.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_ja.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_ja.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 mconsole.errorMsg18 = グラフの更新中にエラーが発生しました。
 mconsole.errorMsg19 = グラフの削除中にエラーが発生しました。
 mconsole.errorMsg20 = サーバーを削除する前に全てのグラフを削除してください。
+mconsole.errorMsg21 = Error encountered while reseting data.
 mconsole.infoMsg01  = 接続は成功しました。
 mconsole.infoMsg02  = サーバー <b>{0}</b> を有効化しました。
 mconsole.infoMsg03  = サーバー <b>{0}</b> を無効化しました。
@@ -53,3 +54,4 @@
 mconsole.infoMsg14  = グラフ <b>{0}</b> を追加しました。
 mconsole.infoMsg15  = グラフ <b>{0}</b> を更新しました。
 mconsole.infoMsg16  = グラフ <b>{0}</b> を削除しました。
+mconsole.infoMsg17  = Default Data reset.

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_zh.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_zh.properties?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_zh.properties
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/i18n-resources/portletinfo_zh.properties
Wed Sep 30 06:55:14 2009
@@ -37,6 +37,7 @@
 mconsole.errorMsg18 = 更新图形时遇到错误。
 mconsole.errorMsg19 = 删除图形时遇到错误。
 mconsole.errorMsg20 = 请先删除所有属于这个Server的Graph,再删除这个Server。
+mconsole.errorMsg21 = 重置数据时遇到错误
 mconsole.infoMsg01  = 成功建立连接。
 mconsole.infoMsg02  = 成功启用服务器<b>{0}</b>。
 mconsole.infoMsg03  = 成功禁用服务器<b>{0}</b>。
@@ -52,4 +53,5 @@
 mconsole.infoMsg13  = 已删除视图。
 mconsole.infoMsg14  = 已添加图形<b>{0}</b>。
 mconsole.infoMsg15  = 已更新图形<b>{0}</b>。
-mconsole.infoMsg16  = 已删除图形<b>{0}</b>。
\ No newline at end of file
+mconsole.infoMsg16  = 已删除图形<b>{0}</b>。
+mconsole.infoMsg17  = 成功重置数据。
\ No newline at end of file

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/MonitoringPortlet.java
Wed Sep 30 06:55:14 2009
@@ -26,18 +26,20 @@
 import javax.naming.NamingException;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
-import javax.portlet.PortletRequest;
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
 import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.transaction.UserTransaction;
 
 import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.crypto.EncryptionManager;
+import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.monitoring.console.data.Graph;
 import org.apache.geronimo.monitoring.console.data.Node;
 import org.apache.geronimo.monitoring.console.data.View;
@@ -105,6 +107,8 @@
     private PortletRequestDispatcher helpView;
 
     private PortletRequestDispatcher editNormalView;
+    
+    private String server;        
 
     //annotations don't work in portlets yet, see init method for initialization
     @Resource
@@ -252,6 +256,9 @@
             actionResponse.setRenderParameter("port", "" + port);
             actionResponse.setRenderParameter("protocol", "" + protocol);
         }
+        else if(action.equals("restoreData")){
+            restoreData(actionRequest,actionResponse);
+        }
     }
 
     private void testConnection(String ip, String username,
@@ -359,6 +366,7 @@
         String action = request.getParameter("action");
         if (action == null)
             action = "showNormal";
+        if(request.isUserInRole("admin")){
         if (action.equals("showEditView")) {
             String view_id = request.getParameter("view_id");
             request.setAttribute("view_id", view_id);
@@ -453,6 +461,7 @@
             //TODO may need to avoid setting message
             normalView(request, response);
         }
+        }//end request.isUserInRole("admin")
     }
 
     private void normalView(RenderRequest request, RenderResponse response) throws PortletException,
IOException {
@@ -842,10 +851,25 @@
             }
 
         } catch (Exception e) {
-            log.info("error deleting graph", e);
+            log.error("error deleting graph", e);
             addErrorMessage(actionRequest, getLocalizedString(actionRequest, "mconsole.errorMsg19"),
e.getMessage());
         }
     }
+    
+    private void restoreData(ActionRequest actionRequest, ActionResponse actionResponse)
{
+        try {
+            if (server == null) {
+                server = getWebServerType(PortletManager.getKernel().getGBean(WebContainer.class).getClass());
+            }
+            deleteDefaultServerView(actionRequest, actionResponse);
+            initializeDefaultServerView(server);
+            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "mconsole.infoMsg17"));
+        } catch (Exception e) {
+            log.error("error deleting graph", e);
+            addErrorMessage(actionRequest, getLocalizedString(actionRequest, "mconsole.errorMsg21"),
e.getMessage());
+        }
+    }
+
 
     private void startTrackingMbean(String server_id, String mbean, PortletRequest request)
{
         Node node;
@@ -976,13 +1000,18 @@
         addServer = portletConfig.getPortletContext().getRequestDispatcher(ADDSERVER_JSP);
         helpView = portletConfig.getPortletContext().getRequestDispatcher(HELPVIEW_JSP);
         editNormalView = portletConfig.getPortletContext().getRequestDispatcher(EDITNORMALVIEW_JSP);
-
         try {
             Context ctx = new InitialContext();
             userTransaction = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
             entityManager = (EntityManager) ctx.lookup("java:comp/env/jpa/monitoring");
+            server= getWebServerType(PortletManager.getKernel().getGBean(WebContainer.class).getClass());
+            if (!isPredefinedServerViewExist()) {
+                initializeDefaultServerView(server);
+            }
         } catch (NamingException e) {
             throw new PortletException(e);
+        }catch (Exception e) {
+            throw new PortletException(e);
         }
     }
 
@@ -1004,4 +1033,211 @@
         editNormalView = null;
         super.destroy();
     }
+
+    private void initializeDefaultServerView(String server) throws Exception {
+        if (server == null) {
+            throw new Exception("Unrecognized web server type");
+        } else if (server.equalsIgnoreCase("tomcat")) {
+            initializeDefaultTomatServerView();
+        } else if (server.equalsIgnoreCase("jetty")) {
+            initializeDefaultJettyServerView();
+        }
+    }
+    
+    private String getObjectNameByShortName(String shortName) {
+        try {
+            Object targetGBean = PortletManager.getKernel().getGBean(shortName);
+            return PortletManager.getKernel().getAbstractNameFor(targetGBean).getObjectName().getCanonicalName();
+        } catch (Exception e) {
+            log.error("Fail to find the gbean object for the short name " + shortName);
+            return null;
+        }
+    }
+
+    private void initializeDefaultTomatServerView() throws Exception {
+        String tomcatWebConnectorObjectName = getObjectNameByShortName("TomcatWebConnector");
+        String tomcatWebSSLConnectorObjectName = getObjectNameByShortName("TomcatWebSSLConnector");
+        try {
+            userTransaction.begin();
+            Node node = persistDefaultServer();
+            if (tomcatWebConnectorObjectName != null) {
+                Graph[] webConnectorGraphs = new Graph[15];
+                webConnectorGraphs[0] = createGraph(node, "JVM Heap Size Current", "JVM Heap
Size Current", "60", getObjectNameByShortName("JVM"), "JVM Heap Size Current", "JVM Heap Size
Current", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[1] = createGraph(node, "Active Request Count", "Active
Request Count", "60", tomcatWebConnectorObjectName, "Active Request Count", "Active Request
Count", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[2] = createGraph(node, "Busy Threads Max", "Busy Threads
Max", "60", tomcatWebConnectorObjectName, "Busy Threads Max", "Busy Threads Max", "Time",
"A", "", "A", null, null);
+                webConnectorGraphs[3] = createGraph(node, "Busy Threads Current", "Busy Threads
Current", "60", tomcatWebConnectorObjectName, "Busy Threads Current", "Busy Threads Current",
"Time", "A", "", "A", null, null);
+                webConnectorGraphs[4] = createGraph(node, "Busy Threads Min", "Busy Threads
Min", "60", tomcatWebConnectorObjectName, "Busy Threads Min", "Busy Threads Min", "Time",
"A", "", "A", null, null);
+                webConnectorGraphs[5] = createGraph(node, "Bytes Received", "Bytes Received",
"60", tomcatWebConnectorObjectName, "Bytes Received", "Bytes Received", "Time", "A", "", "A",
null, null);
+                webConnectorGraphs[6] = createGraph(node, "Bytes Sent", "Bytes Sent", "60",
tomcatWebConnectorObjectName, "Bytes Sent", "Bytes Sent", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[7] = createGraph(node, "Error Count", "Error Count", "60",
tomcatWebConnectorObjectName, "Error Count", "Error Count", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[8] = createGraph(node, "Open Connections Current", "Open
Connections Current", "60", tomcatWebConnectorObjectName, "Open Connections Current", "Open
Connections Current", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[9] = createGraph(node, "Open Connections Max", "Open Connections
Max", "60", tomcatWebConnectorObjectName, "Open Connections Max", "Open Connections Max",
"Time", "A", "", "A", null, null);
+                webConnectorGraphs[10] = createGraph(node, "Open Connections Min", "Open
Connections Min", "60", tomcatWebConnectorObjectName, "Open Connections Min", "Open Connections
Min", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[11] = createGraph(node, "Request Time CurrentTime", "Request
Time CurrentTime", "60", tomcatWebConnectorObjectName, "Request Time CurrentTime", "Request
Time CurrentTime", "Time", "A", "", "A", null, null);
+                webConnectorGraphs[12] = createGraph(node, "Request Time MaxTime", "Request
Time MaxTime", "60", tomcatWebConnectorObjectName, "Request Time MaxTime", "Request Time MaxTime",
"Time", "A", "", "A", null, null);
+                webConnectorGraphs[13] = createGraph(node, "Request Time MinTime", "Request
Time MinTime", "60", tomcatWebConnectorObjectName, "Request Time MinTime", "Request Time MinTime",
"Time", "A", "", "A", null, null);
+                webConnectorGraphs[14] = createGraph(node, "Request Time TotalTime", "Request
Time TotalTime", "60", tomcatWebConnectorObjectName, "Request Time TotalTime", "Request Time
TotalTime", "Time", "A", "", "A", null, null);
+                persistView("TomcatWebConnector View", "TomcatWebConnector View", webConnectorGraphs);
+            }
+            if (tomcatWebSSLConnectorObjectName != null) {
+                Graph[] webSSLConnectorGraphs = new Graph[15];               
+                webSSLConnectorGraphs[0] = createGraph(node, "JVM Heap Size Current", "JVM
Heap Size Current", "60", getObjectNameByShortName("JVM"), "JVM Heap Size Current", "JVM Heap
Size Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[1] = createGraph(node, "SSL Active Request Count",
"Active Request Count", "60", tomcatWebSSLConnectorObjectName, "Active Request Count", "Active
Request Count", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[2] = createGraph(node, "SSL Busy Threads Current",
"Busy Threads Current", "60", tomcatWebSSLConnectorObjectName, "Busy Threads Current", "Busy
Threads Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[3] = createGraph(node, "SSL Busy Threads Max", "Busy
Threads Max", "60", tomcatWebSSLConnectorObjectName, "Busy Threads Max", "Busy Threads Max",
"Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[4] = createGraph(node, "SSL Busy Threads Min", "Busy
Threads Min", "60", tomcatWebSSLConnectorObjectName, "Busy Threads Min", "Busy Threads Min",
"Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[5] = createGraph(node, "SSL Bytes Received", "Bytes
Received", "60", tomcatWebSSLConnectorObjectName, "Bytes Received", "Bytes Received", "Time",
"A", "", "A", "", null);
+                webSSLConnectorGraphs[6] = createGraph(node, "SSL Bytes Sent", "Bytes Sent",
"60", tomcatWebSSLConnectorObjectName, "Bytes Sent", "Bytes Sent", "Time", "A", "", "A", "",
null);
+                webSSLConnectorGraphs[7] = createGraph(node, "SSL Error Count", "Error Count",
"60", tomcatWebSSLConnectorObjectName, "Error Count", "Error Count", "Time", "A", "", "A",
"", null);
+                webSSLConnectorGraphs[8] = createGraph(node, "SSL Open Connections Current",
"Open Connections Current", "60", tomcatWebSSLConnectorObjectName, "Open Connections Current",
"Open Connections Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[9] = createGraph(node, "SSL Open Connections Max",
"Open Connections Max", "60", tomcatWebSSLConnectorObjectName, "Open Connections Max", "Open
Connections Max", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[10] = createGraph(node, "SSL Open Connections Min",
"Open Connections Min", "60", tomcatWebSSLConnectorObjectName, "Open Connections Min", "Open
Connections Min", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[11] = createGraph(node, "SSL Request Time CurrentTime",
"Request Time CurrentTime", "60", tomcatWebSSLConnectorObjectName, "Request Time CurrentTime",
"Request Time CurrentTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[12] = createGraph(node, "SSL Request Time MaxTime",
"Request Time MaxTime", "60", tomcatWebSSLConnectorObjectName, "Request Time MaxTime", "Request
Time MaxTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[13] = createGraph(node, "SSL Request Time MinTime",
"Request Time MinTime", "60", tomcatWebSSLConnectorObjectName, "Request Time MinTime", "Request
Time MinTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[14] = createGraph(node, "SSL Request Time TotalTime",
"Request Time TotalTime", "60", tomcatWebSSLConnectorObjectName, "Request Time TotalTime",
"Request Time TotalTime", "Time", "A", "", "A", "", null);               
+                persistView("TomcatWebSSLConnector View", "TomcatWebSSLConnector View", webSSLConnectorGraphs);
+            }
+        } catch (Exception e) {
+            userTransaction.rollback();
+            throw e;
+        } finally {
+            userTransaction.commit();
+        }
+    }
+    
+    private void initializeDefaultJettyServerView() throws Exception {
+        String jettyWebConnectorObjectName = getObjectNameByShortName("JettyWebConnector");
+        String jettyWebSSLConnectorObjectName = getObjectNameByShortName("JettySSLConnector");
+        try {
+            userTransaction.begin();
+            Node node = persistDefaultServer();
+            if (jettyWebConnectorObjectName != null) {
+                Graph[] webConnectorGraphs = new Graph[12];
+                webConnectorGraphs[0] = createGraph(node, "JVM Heap Size Current", "JVM Heap
Size Current", "60", getObjectNameByShortName("JVM"), "JVM Heap Size Current", "JVM Heap Size
Current", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[1] = createGraph(node, "Connections Duration Count", "Connections
Duration Count", "60", jettyWebConnectorObjectName, "Connections Duration Count", "Connections
Duration Count", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[2] = createGraph(node, "Connections Duration MaxTime",
"Connections Duration MaxTime", "60", jettyWebConnectorObjectName, "Connections Duration MaxTime",
"Connections Duration MaxTime", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[3] = createGraph(node, "Connections Duration MinTime",
"Connections Duration MinTime", "60", jettyWebConnectorObjectName, "Connections Duration MinTime",
"Connections Duration MinTime", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[4] = createGraph(node, "Connections Duration TotalTime",
"Connections Duration TotalTime", "60", jettyWebConnectorObjectName, "Connections Duration
TotalTime", "Connections Duration TotalTime", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[5] = createGraph(node, "Connections Request Current",
"Connections Request Current", "60", jettyWebConnectorObjectName, "Connections Request Current",
"Connections Request Current", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[6] = createGraph(node, "Connections Request Max", "Connections
Request Max", "60", jettyWebConnectorObjectName, "Connections Request Max", "Connections Request
Max", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[7] = createGraph(node, "Connections Request Min", "Connections
Request Min", "60", jettyWebConnectorObjectName, "Connections Request Min", "Connections Request
Min", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[8] = createGraph(node, "Open Connections Current", "Open
Connections Current", "60", jettyWebConnectorObjectName, "Open Connections Current", "Open
Connections Current", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[9] = createGraph(node, "Open Connections Max", "Open Connections
Max", "60", jettyWebConnectorObjectName, "Open Connections Max", "Open Connections Max", "Time",
"A", "", "A", "", null);
+                webConnectorGraphs[10] = createGraph(node, "Open Connections Min", "Open
Connections Min", "60", jettyWebConnectorObjectName, "Open Connections Min", "Open Connections
Min", "Time", "A", "", "A", "", null);
+                webConnectorGraphs[11] = createGraph(node, "Request Time CurrentTime", "Request
Time CurrentTime", "60", jettyWebConnectorObjectName, "Request Time CurrentTime", "Request
Time CurrentTime", "Time", "A", "", "A", "", null);
+                persistView("JettyWebConnector View", "JettyWebConnector View", webConnectorGraphs);
+            }
+            if (jettyWebSSLConnectorObjectName != null) {
+                Graph[] webSSLConnectorGraphs = new Graph[12];
+                webSSLConnectorGraphs[0] = createGraph(node, "JVM Heap Size Current", "JVM
Heap Size Current", "60", getObjectNameByShortName("JVM"), "JVM Heap Size Current", "JVM Heap
Size Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[1] = createGraph(node, "Connections Duration Count",
"Connections Duration Count", "60", jettyWebSSLConnectorObjectName, "Connections Duration
Count", "Connections Duration Count", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[2] = createGraph(node, "Connections Duration MaxTime",
"Connections Duration MaxTime", "60", jettyWebSSLConnectorObjectName, "Connections Duration
MaxTime", "Connections Duration MaxTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[3] = createGraph(node, "Connections Duration MinTime",
"Connections Duration MinTime", "60", jettyWebSSLConnectorObjectName, "Connections Duration
MinTime", "Connections Duration MinTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[4] = createGraph(node, "Connections Duration TotalTime",
"Connections Duration TotalTime", "60", jettyWebSSLConnectorObjectName, "Connections Duration
TotalTime", "Connections Duration TotalTime", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[5] = createGraph(node, "Connections Request Current",
"Connections Request Current", "60", jettyWebSSLConnectorObjectName, "Connections Request
Current", "Connections Request Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[6] = createGraph(node, "Connections Request Max", "Connections
Request Max", "60", jettyWebSSLConnectorObjectName, "Connections Request Max", "Connections
Request Max", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[7] = createGraph(node, "Connections Request Min", "Connections
Request Min", "60", jettyWebSSLConnectorObjectName, "Connections Request Min", "Connections
Request Min", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[8] = createGraph(node, "Open Connections Current",
"Open Connections Current", "60", jettyWebSSLConnectorObjectName, "Open Connections Current",
"Open Connections Current", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[9] = createGraph(node, "Open Connections Max", "Open
Connections Max", "60", jettyWebSSLConnectorObjectName, "Open Connections Max", "Open Connections
Max", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[10] = createGraph(node, "Open Connections Min", "Open
Connections Min", "60", jettyWebSSLConnectorObjectName, "Open Connections Min", "Open Connections
Min", "Time", "A", "", "A", "", null);
+                webSSLConnectorGraphs[11] = createGraph(node, "Request Time CurrentTime",
"Request Time CurrentTime", "60", jettyWebSSLConnectorObjectName, "Request Time CurrentTime",
"Request Time CurrentTime", "Time", "A", "", "A", "", null);
+                persistView("JettySSLConnector View", "JettySSLConnector View", webSSLConnectorGraphs);
+            }
+        } catch (Exception e) {
+            userTransaction.rollback();
+            throw e;
+        } finally {
+            userTransaction.commit();
+        }
+    }
+    
+    private Node persistDefaultServer() throws Exception {
+        Node node = new Node();
+        node.setName("Default Server");
+        node.setHost("localhost");
+        node.setUserName("");
+        node.setPassword("");
+        node.setPort(1099);
+        node.setProtocol("jmx");
+        entityManager.persist(node);
+        return node;
+    }
+    
+    private Graph createGraph(Node node, String name, String description, String timeframe,
String mbean, String dataname1, String xlabel, String ylabel, String data1operation, String
operation,
+            String data2operation, String dataname2, String showArchive) throws Exception
{
+        Graph graph = new Graph();
+        graph.setNode(node);
+        graph.setGraphName1(name);
+        graph.setDescription(description);
+        graph.setXlabel(xlabel);
+        graph.setYlabel(ylabel);
+        graph.setTimeFrame(Integer.parseInt(timeframe));
+        graph.setMBeanName(mbean);
+        graph.setDataName1(dataname1);
+        graph.setData1operation(data1operation.charAt(0));
+        graph.setOperation(operation);
+        graph.setShowArchive(showArchive != null && showArchive.equals("on"));
+        graph.setDataName2(dataname2);
+        graph.setData2operation(data2operation == null ? 'A' : data2operation.charAt(0));
+        return graph;
+    }
+    
+    private View persistView(String name, String description, Graph[] graphsArray) throws
Exception {
+        View view = new View();
+        view.setName(name);
+        view.setDescription(description);
+        if (graphsArray != null) {
+            for (Graph graph : graphsArray) {
+                view.getGraphs().add(graph);
+                graph.getViews().add(view);
+            }
+        }
+        entityManager.persist(view);
+        return view;
+    }
+    
+    private boolean isPredefinedServerViewExist() {
+        Node node = entityManager.find(Node.class, "Default Server");
+        return node != null;
+    }
+    
+    private void deleteDefaultServerView(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
+        try {
+            userTransaction.begin();
+            Node node = entityManager.find(Node.class, "Default Server");
+            if (node != null) {
+                List<Graph> graphs = entityManager.createNamedQuery("graphsByNode").setParameter("name",
node.getName()).getResultList();
+                if (!(graphs == null || graphs.isEmpty())) {
+                    for (Graph graph : graphs) {
+                        List<View> views = graph.getViews();
+                        for (View view : views) {
+                            entityManager.remove(view);
+                        }
+                        entityManager.remove(graph);
+                    }
+                }
+                MRCConnector mrc = null;
+                try {
+                    mrc = new MRCConnector(node);
+                    if (mrc.isSnapshotRunning() == 1) {
+                        if (!mrc.stopSnapshotThread()) {
+                            addInfoMessage(actionRequest, getLocalizedString(actionRequest,
"mconsole.infoMsg06", node));
+                        }
+                    }
+                } finally {
+                    if (null != mrc)
+                        mrc.dispose();
+                }
+                entityManager.remove(node);
+            }
+            userTransaction.commit();
+        } catch (Exception e) {
+            userTransaction.rollback();
+            throw e;
+        }
+    }
+
+    
+    
 }

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/util/DBManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/util/DBManager.java?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/util/DBManager.java
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/java/org/apache/geronimo/monitoring/console/util/DBManager.java
Wed Sep 30 06:55:14 2009
@@ -27,11 +27,15 @@
 import javax.naming.NamingException;
 import javax.sql.DataSource;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class DBManager
 {
-    private static Connection con         = null;
+    private Connection con         = null;
     private static boolean    initialized = false;
-
+    private static final Logger logger = LoggerFactory.getLogger(DBManager.class);
+    
     public DBManager()
     {
         con = createConnection();
@@ -40,27 +44,18 @@
                 initialized = true;
     }
 
-    public static Connection createConnection()
-    {
-
-        try
-        {
+    public static Connection createConnection() {
+        try {
             Context context = new InitialContext();
-            DataSource ds = (DataSource) context
-                    .lookup("java:comp/env/MonitoringClientDS");
-            con = ds.getConnection();
-        }
-        catch (NamingException e)
-        {
-            e.printStackTrace();
-        }
-        catch (SQLException e)
-        {
-            System.err.println("SQL state: " + e.getSQLState());
-            System.err.println("SQL error: " + e.getErrorCode());
-            e.printStackTrace();
+            DataSource ds = (DataSource) context.lookup("java:comp/env/MonitoringClientDS");
+            return ds.getConnection();
+        } catch (NamingException e) {
+            logger.error("Fail to get connection from MonitoringClientDS", e);
+            return null;
+        } catch (SQLException e) {
+            logger.error("Fail to get connection from MonitoringClientDS", e);
+            return null;
         }
-        return con;
     }
 
     public Connection getConnection()

Modified: geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp?rev=820189&r1=820188&r2=820189&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
(original)
+++ geronimo/server/branches/2.2/plugins/monitoring/mconsole-war/src/main/webapp/WEB-INF/view/monitoringNormal.jsp
Wed Sep 30 06:55:14 2009
@@ -33,9 +33,20 @@
 }
 //-->
 </script>
-
+<script type = "text/javascript">
+<!--
+function confirm_del() {
+    var msg = "All the changes you made to default servers/views/graphs will be lost.\nAre
you sure you want to proceed?";
+    return confirm(msg);
+}
+//-->
+</script>
 <CommonMsg:commonMsg/>
-
+<%if (request.isUserInRole("admin")){ %>
+<div align="left">
+<a><strong>Note:&nbsp</strong>To reset default servers/views/graphs,
please click this link:</a>&nbsp&nbsp
+<a href="<portlet:actionURL portletMode="edit"><portlet:param name="action" value="restoreData"
/></portlet:actionURL>" onclick="return confirm_del()"><fmt:message key="monitor.common.restore"/></a></div>
+<%} %>
 <br>
 <b><fmt:message key="monitor.common.view"/>:</b>
 <table width="100%" class="TableLine" summary="Monitoring - Views">
@@ -76,8 +87,8 @@
 </table>
 <% if (request.isUserInRole("admin")) {%>
 <div align="right"><a href="<portlet:actionURL portletMode="edit"><portlet:param
name="action" value="showAddView" /></portlet:actionURL>"><img border=0 src="/monitoring/images/max-b.png"
alt="Create View"><fmt:message key="monitor.view.create"/></a></div>
-<b><fmt:message key="monitor.common.server"/>:</b>
 <% }%>
+<b><fmt:message key="monitor.common.server"/>:</b>
 <table width="100%" class="TableLine" summary="Monitoring - Servers">
  <tr>
   <th scope="col" class="DarkBackground" width="30%"><fmt:message key="monitor.common.name"/></th>



Mime
View raw message