portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r773302 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/cache/ main/resources/org/apache/jetspeed/portlets/cache/ main/resources/org/apache/jetspeed/portlets/cache/resources/ webapp/WEB-INF/ ...
Date Sun, 10 May 2009 03:34:08 GMT
Author: taylor
Date: Sun May 10 03:34:06 2009
New Revision: 773302

URL: http://svn.apache.org/viewvc?rev=773302&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-997
cache monitor

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java?rev=773302&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
Sun May 10 03:34:06 2009
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.cache;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.cache.JetspeedCacheMonitor;
+import org.apache.portals.bridges.common.GenericServletPortlet;
+
+/**
+ * Jetspeed Cache Monitor Portlet
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class CacheMonitorPortlet extends GenericServletPortlet
+{
+    private JetspeedCacheMonitor cacheMonitor;
+    public static final String ALL = "(all)";
+    
+    public void init(PortletConfig config)
+    throws PortletException 
+    {
+        super.init(config);
+        cacheMonitor = (JetspeedCacheMonitor) getPortletContext().getAttribute(CommonPortletServices.CPS_CACHE_MONITOR);
+        if (null == cacheMonitor)
+        {
+            throw new PortletException("Failed to find the Cache Monitor on portlet initialization");
+        }        
+    }
+        
+    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
+    IOException
+    {
+        String cacheName = actionRequest.getParameter("cacheNameCalc");
+        if (cacheName != null)
+        {
+            if (cacheName.equals(ALL))
+            {
+                cacheMonitor.calculateStatistics();
+            }
+            else
+            {
+                cacheMonitor.calculateStatistics(cacheName);
+            }
+        }
+        else
+        {
+            cacheName = actionRequest.getParameter("cacheNameReset");
+            if (cacheName != null)
+            {
+                if (cacheName.equals(ALL))
+                {
+                    cacheMonitor.resetStatistics();
+                }
+                else
+                {
+                    cacheMonitor.resetStatistics(cacheName);
+                }                
+            }            
+        }
+    }    
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/cache/CacheMonitorPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties?rev=773302&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
Sun May 10 03:34:06 2009
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# $Id$
+#
+
+# DO NOT TRANSLATE & DO NOT INCLUDE IN L10N PROPERTIES FILE
+cachemonitor.table.title=Jetspeed Cache Monitor
+cachemonitor.label.name=Cache Name
+cachemonitor.label.maxmemory=Max-Memory
+cachemonitor.label.maxdisk=Max-Disk
+cachemonitor.label.idle=Time-Idle
+cachemonitor.label.live=Time-Live
+cachemonitor.label.memsize=Mem-Count
+cachemonitor.label.disksize=Disk-Count
+cachemonitor.label.inmemsize=In-Mem-Size
+cachemonitor.label.hits=Cache-Hits
+cachemonitor.label.misses=Misses
+cachemonitor.label.evictions=Evictions
+cachemonitor.label.objects=Objects
+cachemonitor.label.avgget=Avg-Get-Ms
+cachemonitor.action.calculate=Calculate
+cachemonitor.action.reset=Reset
+cachemonitor.action.calculate.all=Calculate All
+cachemonitor.action.reset.all=Reset All
+

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/cache/resources/CacheMonitorResources.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=773302&r1=773301&r2=773302&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/jetspeed-portlet.xml
Sun May 10 03:34:06 2009
@@ -143,6 +143,7 @@
 		<js:service name='JetspeedPrincipalManagerProvider'/>        
 		<js:service name='PAM'/>
 		<js:service name='AuthenticationProvider'/>        
+		<js:service name='CacheMonitor'/>
 	</js:services>
 
 </portlet-app>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml?rev=773302&r1=773301&r2=773302&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/portlet.xml Sun May
10 03:34:06 2009
@@ -1643,6 +1643,28 @@
     </portlet-preferences>
 </portlet>
 
+<portlet id="CacheMonitor">
+    <description>Monitor the Jetspeed Caches.</description>
+    <portlet-name>CacheMonitor</portlet-name>
+    <display-name>Cache Monitor</display-name>
+    <portlet-class>org.apache.jetspeed.portlets.cache.CacheMonitorPortlet</portlet-class>
+    <init-param>
+        <name>ViewPage</name>
+        <value>/WEB-INF/view/cache/cacheMonitor.jsp</value>
+    </init-param>
+    <supports>
+        <mime-type>text/html</mime-type>
+        <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <resource-bundle>org.apache.jetspeed.portlets.cache.resources.CacheMonitorResources</resource-bundle>
+    <portlet-info>
+        <title>Cache Monitor</title>
+        <short-title>Cache</short-title>
+        <keywords>cache,monitor,memory,admin</keywords>            
+    </portlet-info>
+</portlet>
+
       
     <custom-portlet-mode>
         <description>a Custom Edit_defaults Mode</description>            

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp?rev=773302&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
Sun May 10 03:34:06 2009
@@ -0,0 +1,101 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+--%>
+<%@page import="java.util.List"%>
+<%@page import="java.text.DecimalFormat"%>
+<%@page import="java.text.NumberFormat"%>
+<%@page import="org.apache.jetspeed.cache.JetspeedCacheMonitor"%>
+<%@page import="org.apache.jetspeed.cache.CacheMonitorState"%>
+<%@page import="org.apache.jetspeed.CommonPortletServices"%>
+<%@page import="org.apache.jetspeed.portlets.cache.CacheMonitorPortlet"%>
+<%@ page contentType="text/html" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+
+<portlet:defineObjects/>
+<fmt:setBundle basename="org.apache.jetspeed.portlets.cache.resources.CacheMonitorResources"
/>
+
+   <p>   
+ 	<%
+ 	JetspeedCacheMonitor cacheMonitor = (JetspeedCacheMonitor)portletConfig.getPortletContext().getAttribute(CommonPortletServices.CPS_CACHE_MONITOR);
+ 	List<CacheMonitorState> states = cacheMonitor.snapshotStatistics();
+  	%>
+<table style="border-collapse: collapse; width: 350px; margin-top: 8px; float: left;">
+	<tr>
+		<th class="portlet-section-header" colspan="17"><fmt:message key="cachemonitor.table.title"/></th>
+	</tr>
+
+     <tr>
+      <th class="portlet-section-subheader"><fmt:message key="cachemonitor.label.name"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.maxmemory"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.maxdisk"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.idle"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.live"/></td>
+      <th class="portlet-section-subheader">&nbsp;</td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.memsize"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.disksize"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.avgget"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.hits"/></td>
+      <th class="portlet-section-subheader"style="text-align: right"><fmt:message
key="cachemonitor.label.misses"/></td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.evictions"/></td>
+      <th class="portlet-section-subheader">&nbsp;</td>
+      <th class="portlet-section-subheader" style="text-align: right"><fmt:message
key="cachemonitor.label.inmemsize"/></td>
+      <th class="portlet-section-subheader">&nbsp;</td>
+      <th class="portlet-section-subheader">&nbsp;</td>
+      <th class="portlet-section-subheader">&nbsp;</td>
+     </tr>
+<%
+NumberFormat pf = new DecimalFormat("##0.000");
+NumberFormat nf = new DecimalFormat("###,###,##0");
+
+for (CacheMonitorState state : states)
+{
+%>     
+	
+     <tr>
+       <td class="portlet-section-body"><%=state.getCacheName()%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getMaxElementsInMemory())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getMaxElementsOnDisk())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getTimeToIdle())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getTimeToLive())%></td>
+       <td class="portlet-section-body">&nbsp;</td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getMemoryStoreSize())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getDiskStoreSize())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=pf.format(state.getAverageGetTime())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getCacheHits())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getCacheMisses())%></td>
+	   <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getEvictionCount())%></td>
+       <td class="portlet-section-body">&nbsp;</td>
+       <td class="portlet-section-body" style="text-align: right"><%=nf.format(state.getInMemorySize())%></td>
+	   <td class="portlet-section-body"><a href="<portlet:actionURL><portlet:param
name='cacheNameCalc' value='<%=state.getCacheName()%>'/></portlet:actionURL>"><fmt:message
key="cachemonitor.action.calculate"/></a></td>
+       <td class="portlet-section-body">&nbsp;</td>
+	   <td class="portlet-section-body"><a href="<portlet:actionURL><portlet:param
name='cacheNameReset' value='<%=state.getCacheName()%>'/></portlet:actionURL>"><fmt:message
key="cachemonitor.action.reset"/></a></td>
+     </tr>
+<%
+}
+%>
+	<tr>
+		<th class="portlet-section-header" colspan="17"></th>
+	</tr>
+	<tr>
+	<td class="portlet-section-body' colspan="17">
+	<a href="<portlet:actionURL><portlet:param name='cacheNameCalc' value='<%=CacheMonitorPortlet.ALL%>'/></portlet:actionURL>"><fmt:message
key="cachemonitor.action.calculate.all"/></a>
+	<a href="<portlet:actionURL><portlet:param name='cacheNameReset' value='<%=CacheMonitorPortlet.ALL%>'/></portlet:actionURL>"><fmt:message
key="cachemonitor.action.reset.all"/></a>
+	</td>
+    </tr>
+</table>
+    

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/cache/cacheMonitor.jsp
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message