[jboss-svn-commits] JBL Code SVN: r14356 - in labs/shotoku/trunk/shotoku-cache/cache-admin/src: web/WEB-INF and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Aug 18 16:25:48 EDT 2007


Author: adamw
Date: 2007-08-18 16:25:48 -0400 (Sat, 18 Aug 2007)
New Revision: 14356

Modified:
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/WEB-INF/web.xml
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.css
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.jsp
Log:
Admin panel

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java	2007-08-18 18:13:09 UTC (rev 14355)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java	2007-08-18 20:25:48 UTC (rev 14356)
@@ -46,7 +46,7 @@
 		if (cacheItems == null) {
 			cacheItems = new ArrayList<CacheItemBean>();
 			for (RenewableCacheItemData cacheItemData : getService().getCacheItemsData()) {
-				cacheItems.add(new CacheItemBean(cacheItemData));
+				cacheItems.add(new CacheItemBean(cacheItemData, getService()));
 			}
 		}
 		

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java	2007-08-18 18:13:09 UTC (rev 14355)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java	2007-08-18 20:25:48 UTC (rev 14356)
@@ -1,23 +1,36 @@
 package org.jboss.shotoku.cache.admin;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
+import org.jboss.cache.CacheException;
 import org.jboss.shotoku.cache.RenewableCacheItemData;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 
 public class CacheItemBean {
 	private RenewableCacheItemData cacheItem;
-	private Set keysDuringUpdate;
-	private Set keysNotDuringUpdate;
-	private Map keysUpdates;
+	private List<? extends Object> keysDuringUpdate;
+	private List<? extends Object> keysNotDuringUpdate;
+	private Map<Object, Long> keysUpdatesAgo;
+	private RenewableCacheServiceMBean service;
 	
 	@SuppressWarnings("unchecked")
-	public CacheItemBean(RenewableCacheItemData cacheItem) {
+	public CacheItemBean(RenewableCacheItemData cacheItem, RenewableCacheServiceMBean service) {
 		this.cacheItem = cacheItem;
+		this.service = service;
 
-		keysDuringUpdate = cacheItem.getKeysDuringUpdate();
-		keysUpdates = cacheItem.getKeysUpdates();
-		keysNotDuringUpdate = keysUpdates.keySet();
+		keysDuringUpdate = new ArrayList<Object>(cacheItem.getKeysDuringUpdate());
+		
+		Map<Object, Long> keysUpdates = cacheItem.getKeysUpdates();		
+		long now = System.currentTimeMillis();
+		keysUpdatesAgo = new HashMap<Object, Long>();
+		for (Object key : keysUpdates.keySet()) {
+			keysUpdatesAgo.put(key, (long)((now-keysUpdates.get(key))/1000));
+		}
+		
+		keysNotDuringUpdate = new ArrayList<Object>(keysUpdates.keySet());
 		keysNotDuringUpdate.removeAll(keysDuringUpdate);
 	}
 	
@@ -29,15 +42,27 @@
 		return cacheItem.getInterval();
 	}
 	
-	public Set getKeysDuringUpdate() {
+	public List<? extends Object> getKeysDuringUpdate() {
 		return keysDuringUpdate;
 	}
 	
-	public Set getKeysNotDuringUpdate() {
+	public List<? extends Object> getKeysNotDuringUpdate() {
 		return keysNotDuringUpdate;
 	}
 	
-	public Long getLastUpdateForKey(Object key) {
-		return (Long) keysUpdates.get(key);
+	public Map<Object, Long> getLastUpdatesAgo() {
+		return keysUpdatesAgo;
 	}
+	
+	public String getFqn() {
+		return cacheItem.getFqn().toString();
+	}
+	
+	public int getFqnKeysCount() {
+		try {
+			return service.getTreeCache().get(cacheItem.getFqn()).numAttributes();
+		} catch (CacheException e) {
+			throw new RuntimeException(e);
+		}
+	}
 }

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/WEB-INF/web.xml
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/WEB-INF/web.xml	2007-08-18 18:13:09 UTC (rev 14355)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/WEB-INF/web.xml	2007-08-18 20:25:48 UTC (rev 14356)
@@ -57,7 +57,7 @@
         <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
     
-    <!-- Filter for development -->
+    <!-- Filter for development 
     <filter>
         <filter-name>filesFromRepoFilter</filter-name>
         <filter-class>org.jboss.shotoku.cache.admin.WebFilesystemFilter</filter-class>
@@ -77,7 +77,7 @@
         <dispatcher>INCLUDE</dispatcher>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>REQUEST</dispatcher>
-    </filter-mapping>
+    </filter-mapping>-->
 
 	<!-- Listener, that does all the startup work (configuration, init). -->
 	<listener>

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.css
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.css	2007-08-18 18:13:09 UTC (rev 14355)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.css	2007-08-18 20:25:48 UTC (rev 14356)
@@ -5,6 +5,8 @@
 
 .header_panel {
     text-align: center;	
+    margin-bottom: 10px;
+	margin-top: 10px;
 }
 
 .info_table {
@@ -14,16 +16,27 @@
 .info_table td {
 	width: 30%;
 	padding: 5px;
+	vertical-align: top;
 	font-size: small;
-	vertical-align: top;
 }
 
+.cacheitem_table {
+	width: 100%;
+}
+
+.cacheitem_table table {
+	width: 100%;
+}
+
+.cacheitem_table table td {
+	padding: 5px;
+	width: 50%;
+}
+
 .messages {
-	margin-top: 10px;
 }
 
 .info_table .left_text {
-	
 	width: 70%;
 	text-align: right;	
 	font-weight: bold;
@@ -31,4 +44,25 @@
 
 .info_table .right_text {
 	vertical-align: bottom;
+}
+
+.cacheitem_table td {
+	font-size: small;
+	vertical-align: top;
+}
+
+.cacheitem_table th {
+	font-size: small;
+	vertical-align: top;
+	text-align: left;
+}
+
+.cacheitem_table .left_text {
+	width: 20%;
+	text-align: right;	
+	font-weight: bold;
+}
+
+.cacheitem_table .right_text {
+	vertical-align: bottom;
 }
\ No newline at end of file

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.jsp
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.jsp	2007-08-18 18:13:09 UTC (rev 14355)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/web/pages/admin.jsp	2007-08-18 20:25:48 UTC (rev 14356)
@@ -5,7 +5,7 @@
 
 <html>
 	<head>
-		<title>Hello world page.</title>
+		<title>Shotoku Cache Administration</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 		<link rel="stylesheet" href="admin.css" type="text/css" />	
 	</head>
@@ -20,7 +20,7 @@
 			</rich:panel>
 			
 			<h:form>
-				<a4j:poll interval="10000" reRender="information" />
+				<a4j:poll interval="10000" reRender="information,statistics" />
 			</h:form>
 			
 			<h:panelGrid columns="3" styleClass="info_table">
@@ -30,7 +30,7 @@
 							<h:outputText value="#{admin.serviceLastUpdateDate}" />
 								
 							<h:outputText value="Last update: "/>
-							<h:outputText value="#{admin.serviceLastUpdateSecondsAgo} seconds ago" />
+							<h:outputText value="#{admin.serviceLastUpdateSecondsAgo} second(s) ago" />
 							
 							<h:outputText value="Current data packet queue size: "/>
 							<h:outputText value="#{admin.currentQueueSize}" />
@@ -38,7 +38,7 @@
 					</rich:simpleTogglePanel>
 					
 					<rich:simpleTogglePanel switchType="client" label="Statistics">
-						<h:panelGrid columns="2" columnClasses="left_text,right_text">
+						<h:panelGrid columns="2" id="statistics" columnClasses="left_text,right_text">
 							<h:outputText value="Total number of data packets processed: "/>
 							<h:outputText value="#{admin.statistics.numberOfPacketsProcessed}" />
 							
@@ -55,7 +55,7 @@
 				
 					<rich:simpleTogglePanel switchType="client" label="Configuration">
 					<h:form>
-						<h:panelGrid columns="2">
+						<h:panelGrid columns="2" columnClasses="left_text,right_text">
 							<h:outputText value="Interval: "/>
 							<h:inputText value="#{admin.serviceInterval}" id="Interval" required="true">
 								<f:validateLongRange minimum="1000" />
@@ -72,6 +72,60 @@
 					</h:form>
 					</rich:simpleTogglePanel>
 			</h:panelGrid>
+			
+			<rich:panel styleClass="header_panel">
+				<h:outputText styleClass="header" value="Cache Items" />
+			</rich:panel>
+			
+			<h:dataTable var="cacheItem" value="#{admin.cacheItems}" styleClass="cacheitem_table">
+				<h:column>
+					<rich:simpleTogglePanel switchType="client" label="#{cacheItem.name}">
+						<h:panelGrid columns="2">
+							<rich:simpleTogglePanel switchType="client" label="Information">
+								<h:panelGrid columns="2" columnClasses="left_text,right_text">
+									<h:outputText value="Name: "/>
+									<h:outputText value="#{cacheItem.name}" />
+								
+									<h:outputText value="FQN: "/>
+									<h:outputText value="#{cacheItem.fqn}" />		
+								
+									<h:outputText value="FQN keys count: "/>
+									<h:outputText value="#{cacheItem.fqnKeysCount}" />						
+								</h:panelGrid>
+							</rich:simpleTogglePanel>
+							
+							<rich:simpleTogglePanel switchType="client" label="Configuration">
+							</rich:simpleTogglePanel>
+							
+							<rich:simpleTogglePanel switchType="client" label="Last updates of keys">
+								<h:dataTable var="key" id="keysNotInUpdate" value="#{cacheItem.keysNotDuringUpdate}">
+									<h:column>
+										<f:facet name="header"><h:outputText value="Key"/></f:facet>
+										<h:outputText value="#{key}" />
+									</h:column>
+									<h:column>
+										<f:facet name="header"><h:outputText value="Last update"/></f:facet>
+										<h:outputText value="#{cacheItem.lastUpdatesAgo[key]} second(s) ago" />
+									</h:column>
+								</h:dataTable>
+							</rich:simpleTogglePanel>
+							
+							<rich:simpleTogglePanel switchType="client" label="Keys during update">
+								<h:dataTable var="key" value="#{cacheItem.keysDuringUpdate}">
+									<h:column>
+										<f:facet name="header"><h:outputText value="Key"/></f:facet>
+										<h:outputText value="#{key}" />
+									</h:column>
+									<h:column>
+										<f:facet name="header"><h:outputText value="In update since"/></f:facet>
+										<h:outputText value="#{cacheItem.lastUpdatesAgo[key]} second(s)" />
+									</h:column>
+								</h:dataTable>
+							</rich:simpleTogglePanel>
+						</h:panelGrid>
+					</rich:simpleTogglePanel>
+				</h:column>
+			</h:dataTable>
 		</f:view>
 	</body>
 </html>




More information about the jboss-svn-commits mailing list