You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2004/06/09 06:11:20 UTC
cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/admin JCSAdminBean.java JCSAdmin.jsp CountingOnlyOutputStream.java CacheRegionInfo.java CacheElementInfo.java
asmuts 2004/06/08 21:11:20
Modified: src/java/org/apache/jcs/admin/servlet JCSAdminServlet.java
Added: src/java/org/apache/jcs/admin JCSAdminBean.java JCSAdmin.jsp
CountingOnlyOutputStream.java CacheRegionInfo.java
CacheElementInfo.java
Log:
New admin jsp., will move and clean later.
I don't want anyone to have to use velocity to use the admin page.
Revision Changes Path
1.10 +71 -284 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/servlet/JCSAdminServlet.java
Index: JCSAdminServlet.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/admin/servlet/JCSAdminServlet.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- JCSAdminServlet.java 15 Apr 2004 19:22:56 -0000 1.9
+++ JCSAdminServlet.java 9 Jun 2004 04:11:20 -0000 1.10
@@ -1,6 +1,5 @@
package org.apache.jcs.admin.servlet;
-
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
@@ -17,7 +16,6 @@
* limitations under the License.
*/
-
import java.io.IOException;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
@@ -31,6 +29,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.jcs.admin.CacheElementInfo;
+import org.apache.jcs.admin.CacheRegionInfo;
+import org.apache.jcs.admin.CountingOnlyOutputStream;
+import org.apache.jcs.admin.JCSAdminBean;
import org.apache.jcs.engine.CacheConstants;
import org.apache.jcs.engine.memory.MemoryCache;
import org.apache.jcs.engine.behavior.ICacheElement;
@@ -69,321 +71,106 @@
*
* @version $Id$
*/
-public class JCSAdminServlet extends VelocityServlet
+public class JCSAdminServlet
+ extends VelocityServlet
{
- private static final String DEFAULT_TEMPLATE_NAME =
- "/org/apache/jcs/admin/servlet/JCSAdminServletDefault.vm";
+ private static final String DEFAULT_TEMPLATE_NAME =
+ "/org/apache/jcs/admin/servlet/JCSAdminServletDefault.vm";
- private static final String REGION_DETAIL_TEMPLATE_NAME =
- "/org/apache/jcs/admin/servlet/JCSAdminServletRegionDetail.vm";
+ private static final String REGION_DETAIL_TEMPLATE_NAME =
+ "/org/apache/jcs/admin/servlet/JCSAdminServletRegionDetail.vm";
- // Keys for parameters
+ // Keys for parameters
- private static final String CACHE_NAME_PARAM = "cacheName";
+ private static final String CACHE_NAME_PARAM = "cacheName";
- private static final String ACTION_PARAM = "action";
- private static final String KEY_PARAM = "key";
- private static final String SILENT_PARAM = "silent";
+ private static final String ACTION_PARAM = "action";
+ private static final String KEY_PARAM = "key";
+ private static final String SILENT_PARAM = "silent";
- // Possible values for 'action' parameter
+ // Possible values for 'action' parameter
- private static final String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
- private static final String CLEAR_REGION_ACTION = "clearRegion";
- private static final String REMOVE_ACTION = "remove";
- private static final String DETAIL_ACTION = "detail";
+ private static final String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
+ private static final String CLEAR_REGION_ACTION = "clearRegion";
+ private static final String REMOVE_ACTION = "remove";
+ private static final String DETAIL_ACTION = "detail";
- private CompositeCacheManager cacheHub = CompositeCacheManager.getInstance();
+ private CompositeCacheManager cacheHub = CompositeCacheManager.getInstance();
- /** @see org.apache.velocity.servlet.VelocityServlet#handleRequest */
- protected Template handleRequest( HttpServletRequest request,
- HttpServletResponse response,
- Context context )
- throws Exception
- {
- String templateName = DEFAULT_TEMPLATE_NAME;
+ /** @see org.apache.velocity.servlet.VelocityServlet#handleRequest */
+ protected Template handleRequest( HttpServletRequest request,
+ HttpServletResponse response,
+ Context context ) throws Exception
+ {
- // Get cacheName for actions from request (might be null)
+ JCSAdminBean admin = new JCSAdminBean();
- String cacheName = request.getParameter( CACHE_NAME_PARAM );
+ String templateName = DEFAULT_TEMPLATE_NAME;
- // If an action was provided, handle it
+ // Get cacheName for actions from request (might be null)
- String action = request.getParameter( ACTION_PARAM );
+ String cacheName = request.getParameter( CACHE_NAME_PARAM );
- if ( action != null )
- {
- if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
- {
- clearAllRegions();
- }
- else if ( action.equals( CLEAR_REGION_ACTION ) )
- {
- if ( cacheName == null )
- {
- // Not Allowed
- }
- else
- {
- clearRegion( cacheName );
- }
- }
- else if ( action.equals( REMOVE_ACTION ) )
- {
- String[] keys = request.getParameterValues( KEY_PARAM );
-
- for ( int i = 0; i < keys.length; i++ )
- {
- removeItem( cacheName, keys[ i ] );
- }
-
- templateName = REGION_DETAIL_TEMPLATE_NAME;
- }
- else if ( action.equals( DETAIL_ACTION ) )
- {
- templateName = REGION_DETAIL_TEMPLATE_NAME;
- }
- }
-
- if ( request.getParameter( SILENT_PARAM ) != null )
- {
- // If silent parameter was passed, no output should be produced.
+ // If an action was provided, handle it
- return null;
- }
- else
- {
- // Populate the context based on the template
-
- if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
- {
- context.put( "cacheName", cacheName );
- context.put( "elementInfoRecords", buildElementInfo( cacheName ) );
- }
- else if ( templateName == DEFAULT_TEMPLATE_NAME )
- {
- context.put( "cacheInfoRecords", buildCacheInfo() );
- }
-
- return getTemplate( templateName );
- }
- }
+ String action = request.getParameter( ACTION_PARAM );
- private LinkedList buildElementInfo( String cacheName ) throws Exception
+ if ( action != null )
{
- CompositeCache cache =
- ( CompositeCache ) cacheHub.getCache( cacheName );
-
- Object[] keys = cache.getMemoryCache().getKeyArray();
-
- // Attempt to sort keys according to their natural ordering. If that
- // fails, get the key array again and continue unsorted.
-
- try
+ if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
+ {
+ admin.clearAllRegions();
+ }
+ else if ( action.equals( CLEAR_REGION_ACTION ) )
+ {
+ if ( cacheName == null )
{
- Arrays.sort( keys );
+ // Not Allowed
}
- catch ( Exception e )
+ else
{
- keys = cache.getMemoryCache().getKeyArray();
+ admin.clearRegion( cacheName );
}
-
- LinkedList records = new LinkedList();
-
- ICacheElement element;
- IElementAttributes attributes;
- CacheElementInfo elementInfo;
-
- DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT,
- DateFormat.SHORT );
-
- long now = System.currentTimeMillis();
+ }
+ else if ( action.equals( REMOVE_ACTION ) )
+ {
+ String[] keys = request.getParameterValues( KEY_PARAM );
for ( int i = 0; i < keys.length; i++ )
{
- element =
- cache.getMemoryCache().getQuiet( (Serializable) keys[ i ] );
-
- attributes = element.getElementAttributes();
-
- elementInfo = new CacheElementInfo();
-
- elementInfo.key = String.valueOf( keys[ i ] );
- elementInfo.eternal = attributes.getIsEternal();
- elementInfo.maxLifeSeconds = attributes.getMaxLifeSeconds();
-
- elementInfo.createTime =
- format.format( new Date( attributes.getCreateTime() ) );
-
- elementInfo.expiresInSeconds =
- ( now - attributes.getCreateTime()
- - ( attributes.getMaxLifeSeconds() * 1000 ) ) / -1000;
-
- records.add( elementInfo );
+ admin.removeItem( cacheName, keys[i] );
}
- return records;
+ templateName = REGION_DETAIL_TEMPLATE_NAME;
+ }
+ else if ( action.equals( DETAIL_ACTION ) )
+ {
+ templateName = REGION_DETAIL_TEMPLATE_NAME;
+ }
}
- private LinkedList buildCacheInfo() throws Exception
+ if ( request.getParameter( SILENT_PARAM ) != null )
{
- String[] cacheNames = cacheHub.getCacheNames();
-
- Arrays.sort( cacheNames );
-
- LinkedList cacheInfo = new LinkedList();
-
- CacheRegionInfo regionInfo;
- CompositeCache cache;
-
- for ( int i = 0; i < cacheNames.length; i++ )
- {
- cache = ( CompositeCache ) cacheHub.getCache( cacheNames[ i ] );
+ // If silent parameter was passed, no output should be produced.
- regionInfo = new CacheRegionInfo();
-
- regionInfo.cache = cache;
- regionInfo.byteCount = getByteCount( cache );
-
- cacheInfo.add( regionInfo );
- }
-
- return cacheInfo;
+ return null;
}
-
- public int getByteCount( CompositeCache cache )
- throws Exception
+ else
{
- MemoryCache memCache = cache.getMemoryCache();
-
- Iterator iter = memCache.getIterator();
+ // Populate the context based on the template
- CountingOnlyOutputStream counter = new CountingOnlyOutputStream();
- ObjectOutputStream out = new ObjectOutputStream( counter );
+ if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
+ {
+ context.put( "cacheName", cacheName );
+ context.put( "elementInfoRecords", admin.buildElementInfo( cacheName ) );
+ }
+ else if ( templateName == DEFAULT_TEMPLATE_NAME )
+ {
+ context.put( "cacheInfoRecords", admin.buildCacheInfo() );
+ }
- while ( iter.hasNext() )
- {
- ICacheElement ce = (ICacheElement)
- ( ( Map.Entry ) iter.next() ).getValue();
-
- out.writeObject( ce.getVal() );
- }
-
- // 4 bytes lost for the serialization header
-
- return counter.getCount() - 4;
- }
-
- private void clearAllRegions() throws IOException
- {
- String[] names = cacheHub.getCacheNames();
-
- for ( int i = 0; i < names.length; i++ )
- {
- cacheHub.getCache( names[ i ] ).removeAll();
- }
+ return getTemplate( templateName );
}
+ }
- private void clearRegion( String cacheName ) throws IOException
- {
- cacheHub.getCache( cacheName ).removeAll();
- }
-
- private void removeItem( String cacheName, String key ) throws IOException
- {
- cacheHub.getCache( cacheName ).remove( key );
- }
-
- /** Stores info on a cache region for the template */
- public class CacheRegionInfo
- {
- CompositeCache cache = null;
- long byteCount = 0;
-
- public CompositeCache getCache()
- {
- return cache;
- }
-
- public long getByteCount()
- {
- return byteCount;
- }
-
- public String getStatus()
- {
- int status = cache.getStatus();
-
- return ( status == CacheConstants.STATUS_ALIVE ? "ALIVE"
- : status == CacheConstants.STATUS_DISPOSED ? "DISPOSED"
- : status == CacheConstants.STATUS_ERROR ? "ERROR"
- : "UNKNOWN" );
- }
- }
-
- /** Stores info on a cache element for the template */
- public class CacheElementInfo
- {
- String key = null;
- boolean eternal = false;
- String createTime = null;
- long maxLifeSeconds = -1;
- long expiresInSeconds = -1;
-
- public String getKey()
- {
- return key;
- }
-
- public boolean isEternal()
- {
- return eternal;
- }
-
- public String getCreateTime()
- {
- return createTime;
- }
-
- public long getMaxLifeSeconds()
- {
- return maxLifeSeconds;
- }
-
- public long getExpiresInSeconds()
- {
- return expiresInSeconds;
- }
- }
-
- /**
- * Keeps track of the number of bytes written to it, but doesn't write them
- * anywhere.
- */
- private static class CountingOnlyOutputStream extends OutputStream
- {
- private int count;
-
- public void write( byte[] b ) throws IOException
- {
- count += b.length;
- }
-
- public void write( byte[] b, int off, int len ) throws IOException
- {
- count += len;
- }
-
- public void write( int b ) throws IOException
- {
- count++;
- }
-
- /**
- * The number of bytes that have passed through this stream.
- */
- public int getCount()
- {
- return this.count;
- }
- }
}
1.1 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/JCSAdminBean.java
Index: JCSAdminBean.java
===================================================================
package org.apache.jcs.admin;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
import java.io.IOException;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.Map;
import java.util.Date;
import java.text.DateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.jcs.engine.CacheConstants;
import org.apache.jcs.engine.memory.MemoryCache;
import org.apache.jcs.engine.behavior.ICacheElement;
import org.apache.jcs.engine.behavior.IElementAttributes;
import org.apache.jcs.engine.control.CompositeCacheManager;
import org.apache.jcs.engine.control.CompositeCache;
/**
* A servlet which provides HTTP access to JCS. Allows a summary of regions
* to be viewed, and removeAll to be run on individual regions or all regions.
* Also provides the ability to remove items (any number of key arguments can
* be provided with action 'remove'). Should be initialized with a properties
* file that provides at least a classpath resource loader.
*
*/
public class JCSAdminBean
{
private CompositeCacheManager cacheHub = CompositeCacheManager.getInstance();
public LinkedList buildElementInfo( String cacheName ) throws Exception
{
CompositeCache cache =
( CompositeCache ) cacheHub.getCache( cacheName );
Object[] keys = cache.getMemoryCache().getKeyArray();
// Attempt to sort keys according to their natural ordering. If that
// fails, get the key array again and continue unsorted.
try
{
Arrays.sort( keys );
}
catch ( Exception e )
{
keys = cache.getMemoryCache().getKeyArray();
}
LinkedList records = new LinkedList();
ICacheElement element;
IElementAttributes attributes;
CacheElementInfo elementInfo;
DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT );
long now = System.currentTimeMillis();
for ( int i = 0; i < keys.length; i++ )
{
element =
cache.getMemoryCache().getQuiet( ( Serializable ) keys[i] );
attributes = element.getElementAttributes();
elementInfo = new CacheElementInfo();
elementInfo.key = String.valueOf( keys[i] );
elementInfo.eternal = attributes.getIsEternal();
elementInfo.maxLifeSeconds = attributes.getMaxLifeSeconds();
elementInfo.createTime =
format.format( new Date( attributes.getCreateTime() ) );
elementInfo.expiresInSeconds =
( now - attributes.getCreateTime()
- ( attributes.getMaxLifeSeconds() * 1000 ) ) / -1000;
records.add( elementInfo );
}
return records;
}
public LinkedList buildCacheInfo() throws Exception
{
String[] cacheNames = cacheHub.getCacheNames();
Arrays.sort( cacheNames );
LinkedList cacheInfo = new LinkedList();
CacheRegionInfo regionInfo;
CompositeCache cache;
for ( int i = 0; i < cacheNames.length; i++ )
{
cache = ( CompositeCache ) cacheHub.getCache( cacheNames[i] );
regionInfo = new CacheRegionInfo();
regionInfo.cache = cache;
regionInfo.byteCount = getByteCount( cache );
cacheInfo.add( regionInfo );
}
return cacheInfo;
}
public int getByteCount( CompositeCache cache ) throws Exception
{
MemoryCache memCache = cache.getMemoryCache();
Iterator iter = memCache.getIterator();
CountingOnlyOutputStream counter = new CountingOnlyOutputStream();
ObjectOutputStream out = new ObjectOutputStream( counter );
// non serializable objects will cause problems here
try
{
while ( iter.hasNext() )
{
ICacheElement ce = ( ICacheElement )
( ( Map.Entry ) iter.next() ).getValue();
out.writeObject( ce.getVal() );
}
}
catch ( Exception e )
{
//log later
}
// 4 bytes lost for the serialization header
return counter.getCount() - 4;
}
public void clearAllRegions() throws IOException
{
String[] names = cacheHub.getCacheNames();
for ( int i = 0; i < names.length; i++ )
{
cacheHub.getCache( names[i] ).removeAll();
}
}
public void clearRegion( String cacheName ) throws IOException
{
cacheHub.getCache( cacheName ).removeAll();
}
public void removeItem( String cacheName, String key ) throws IOException
{
cacheHub.getCache( cacheName ).remove( key );
}
}
1.1 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/JCSAdmin.jsp
Index: JCSAdmin.jsp
===================================================================
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.LinkedList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="org.apache.jcs.admin.*" %>
<jsp:useBean id="jcsBean" scope="request" class="org.apache.jcs.admin.JCSAdminBean" />
<html>
<head><title> JCS Admin Servlet </title></head>
<body>
<%
String CACHE_NAME_PARAM = "cacheName";
String ACTION_PARAM = "action";
String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
String CLEAR_REGION_ACTION = "clearRegion";
String REMOVE_ACTION = "remove";
String DETAIL_ACTION = "detail";
String KEY_PARAM = "key";
String SILENT_PARAM = "silent";
String DEFAULT_TEMPLATE_NAME = "DEFAULT";
String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
String templateName = DEFAULT_TEMPLATE_NAME;
HashMap context = new HashMap();
// Get cacheName for actions from request (might be null)
String cacheName = request.getParameter( CACHE_NAME_PARAM );
// If an action was provided, handle it
String action = request.getParameter( ACTION_PARAM );
if ( action != null )
{
if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
{
jcsBean.clearAllRegions();
}
else if ( action.equals( CLEAR_REGION_ACTION ) )
{
if ( cacheName == null )
{
// Not Allowed
}
else
{
jcsBean.clearRegion( cacheName );
}
}
else if ( action.equals( REMOVE_ACTION ) )
{
String[] keys = request.getParameterValues( KEY_PARAM );
for ( int i = 0; i < keys.length; i++ )
{
jcsBean.removeItem( cacheName, keys[ i ] );
}
templateName = REGION_DETAIL_TEMPLATE_NAME;
}
else if ( action.equals( DETAIL_ACTION ) )
{
templateName = REGION_DETAIL_TEMPLATE_NAME;
}
}
if ( request.getParameter( SILENT_PARAM ) != null )
{
// If silent parameter was passed, no output should be produced.
//return null;
}
else
{
// Populate the context based on the template
if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
{
//context.put( "cacheName", cacheName );
context.put( "elementInfoRecords", jcsBean.buildElementInfo( cacheName ) );
}
else if ( templateName == DEFAULT_TEMPLATE_NAME )
{
context.put( "cacheInfoRecords", jcsBean.buildCacheInfo() );
}
}
//handle display
if ( templateName == REGION_DETAIL_TEMPLATE_NAME ) {
%>
<h1> Keys for region: $cacheName </h1>
<table border="1" cellpadding="5" >
<tr>
<th> Key </th>
<th> Eternal? </th>
<th> Create time </th>
<th> Max Life (s) </th>
<th> Till Expiration (s) </th>
</tr>
<%
List list = (List)context.get( "elementInfoRecords" );
Iterator it = list.iterator();
while ( it.hasNext() ) {
CacheElementInfo element = (CacheElementInfo)it.next();
%>
<tr>
<td> <%=element.getKey()%> </td>
<td> <%=element.isEternal()%> </td>
<td> <%=element.getCreateTime()%> </td>
<td> <%=element.getMaxLifeSeconds()%> </td>
<td> <%=element.getExpiresInSeconds()%> </td>
<td> <a href="?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a> </td>
</tr>
<%
}
} else {
%>
<h1> Cache Regions </h1>
<p>These are the regions which are currently defined in the cache. 'Items' and
'Bytes' refer to the elements currently in memory (not spooled). You can clear
all items for a region by selecting 'Remove all' next to the desired region
below. You can also <a href="?action=clearAllRegions">Clear all regions</a>
which empties the entire cache.</p>
<table border="1" cellpadding="5" >
<tr>
<th> Cache Name </th>
<th> Items </th>
<th> Bytes </th>
<th> Status </th>
<th> Memory Hits </th>
<th> Aux Hits </th>
<th> Not Found Misses </th>
<th> Expired Misses </th>
</tr>
<%
List list = (List)context.get( "cacheInfoRecords" );
Iterator it = list.iterator();
while (it.hasNext() ) {
CacheRegionInfo record = (CacheRegionInfo)it.next();
%>
<tr>
<td> <%=record.getCache().getCacheName()%> </td>
<td> <%=record.getCache().getSize()%> </td>
<td> <%=record.getByteCount()%> </td>
<td> <%=record.getStatus()%> </td>
<td> <%=record.getCache().getHitCountRam()%> </td>
<td> <%=record.getCache().getHitCountAux()%> </td>
<td> <%=record.getCache().getMissCountNotFound()%> </td>
<td> <%=record.getCache().getMissCountExpired()%> </td>
<td>
<a href="?action=detail&cacheName=<%=record.getCache().getCacheName()%>"> Detail </a>
| <a href="?action=clearRegion&cacheName=<%=record.getCache().getCacheName()%>"> Remove all </a>
</td>
</tr>
<%
}
}
%>
</table>
</body>
</html>
1.1 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/CountingOnlyOutputStream.java
Index: CountingOnlyOutputStream.java
===================================================================
package org.apache.jcs.admin;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
import java.io.IOException;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* Keeps track of the number of bytes written to it, but doesn't write them
* anywhere.
*/
public class CountingOnlyOutputStream
extends OutputStream
{
private int count;
public void write( byte[] b ) throws IOException
{
count += b.length;
}
public void write( byte[] b, int off, int len ) throws IOException
{
count += len;
}
public void write( int b ) throws IOException
{
count++;
}
/**
* The number of bytes that have passed through this stream.
*/
public int getCount()
{
return this.count;
}
}
1.1 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/CacheRegionInfo.java
Index: CacheRegionInfo.java
===================================================================
package org.apache.jcs.admin;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
import org.apache.jcs.engine.control.CompositeCache;
import org.apache.jcs.engine.CacheConstants;
/** Stores info on a cache region for the template */
public class CacheRegionInfo
{
CompositeCache cache = null;
long byteCount = 0;
public CompositeCache getCache()
{
return cache;
}
public long getByteCount()
{
return byteCount;
}
public String getStatus()
{
int status = cache.getStatus();
return ( status == CacheConstants.STATUS_ALIVE ? "ALIVE"
: status == CacheConstants.STATUS_DISPOSED ? "DISPOSED"
: status == CacheConstants.STATUS_ERROR ? "ERROR"
: "UNKNOWN" );
}
}
1.1 jakarta-turbine-jcs/src/java/org/apache/jcs/admin/CacheElementInfo.java
Index: CacheElementInfo.java
===================================================================
package org.apache.jcs.admin;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.
*/
/** Stores info on a cache element for the template */
public class CacheElementInfo
{
String key = null;
boolean eternal = false;
String createTime = null;
long maxLifeSeconds = -1;
long expiresInSeconds = -1;
public String getKey()
{
return key;
}
public boolean isEternal()
{
return eternal;
}
public String getCreateTime()
{
return createTime;
}
public long getMaxLifeSeconds()
{
return maxLifeSeconds;
}
public long getExpiresInSeconds()
{
return expiresInSeconds;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org