101 |
brianR |
1 |
<%--
|
|
|
2 |
Licensed to the Apache Software Foundation (ASF) under one
|
|
|
3 |
or more contributor license agreements. See the NOTICE file
|
|
|
4 |
distributed with this work for additional information
|
|
|
5 |
regarding copyright ownership. The ASF licenses this file
|
|
|
6 |
to you under the Apache License, Version 2.0 (the
|
|
|
7 |
"License"); you may not use this file except in compliance
|
|
|
8 |
with the License. You may obtain a copy of the License at
|
|
|
9 |
|
|
|
10 |
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
11 |
|
|
|
12 |
Unless required by applicable law or agreed to in writing,
|
|
|
13 |
software distributed under the License is distributed on an
|
|
|
14 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
15 |
KIND, either express or implied. See the License for the
|
|
|
16 |
specific language governing permissions and limitations
|
|
|
17 |
under the License.
|
|
|
18 |
--%>
|
|
|
19 |
<%@ page import="java.util.HashMap" %>
|
|
|
20 |
<%@ page import="java.util.List" %>
|
|
|
21 |
<%@ page import="java.util.Iterator" %>
|
|
|
22 |
<%@ page import="org.apache.jcs.admin.*" %>
|
|
|
23 |
<%@ page import="org.apache.jcs.*" %>
|
|
|
24 |
|
|
|
25 |
<jsp:useBean id="jcsBean" scope="request" class="org.apache.jcs.admin.JCSAdminBean" />
|
|
|
26 |
|
|
|
27 |
<html>
|
|
|
28 |
|
|
|
29 |
<head>
|
|
|
30 |
|
|
|
31 |
<SCRIPT LANGUAGE="Javascript">
|
|
|
32 |
function decision( message, url )
|
|
|
33 |
{
|
|
|
34 |
if( confirm(message) )
|
|
|
35 |
{
|
|
|
36 |
location.href = url;
|
|
|
37 |
}
|
|
|
38 |
}
|
|
|
39 |
</SCRIPT>
|
|
|
40 |
|
|
|
41 |
<title> JCS Admin Servlet </title>
|
|
|
42 |
|
|
|
43 |
</head>
|
|
|
44 |
|
|
|
45 |
<body>
|
|
|
46 |
|
|
|
47 |
<%
|
|
|
48 |
String CACHE_NAME_PARAM = "cacheName";
|
|
|
49 |
String ACTION_PARAM = "action";
|
|
|
50 |
String CLEAR_ALL_REGIONS_ACTION = "clearAllRegions";
|
|
|
51 |
String CLEAR_REGION_ACTION = "clearRegion";
|
|
|
52 |
String REMOVE_ACTION = "remove";
|
|
|
53 |
String DETAIL_ACTION = "detail";
|
|
|
54 |
String REGION_SUMMARY_ACTION = "regionSummary";
|
|
|
55 |
String ITEM_ACTION = "item";
|
|
|
56 |
String KEY_PARAM = "key";
|
|
|
57 |
String SILENT_PARAM = "silent";
|
|
|
58 |
|
|
|
59 |
String DEFAULT_TEMPLATE_NAME = "DEFAULT";
|
|
|
60 |
String REGION_DETAIL_TEMPLATE_NAME = "DETAIL";
|
|
|
61 |
String ITEM_TEMPLATE_NAME = "ITEM";
|
|
|
62 |
String REGION_SUMMARY_TEMPLATE_NAME = "SUMMARY";
|
|
|
63 |
|
|
|
64 |
String templateName = DEFAULT_TEMPLATE_NAME;
|
|
|
65 |
|
|
|
66 |
HashMap context = new HashMap();
|
|
|
67 |
|
|
|
68 |
// Get cacheName for actions from request (might be null)
|
|
|
69 |
String cacheName = request.getParameter( CACHE_NAME_PARAM );
|
|
|
70 |
|
|
|
71 |
if ( cacheName != null )
|
|
|
72 |
{
|
|
|
73 |
cacheName = cacheName.trim();
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
// If an action was provided, handle it
|
|
|
77 |
String action = request.getParameter( ACTION_PARAM );
|
|
|
78 |
|
|
|
79 |
if ( action != null )
|
|
|
80 |
{
|
|
|
81 |
if ( action.equals( CLEAR_ALL_REGIONS_ACTION ) )
|
|
|
82 |
{
|
|
|
83 |
jcsBean.clearAllRegions();
|
|
|
84 |
}
|
|
|
85 |
else if ( action.equals( CLEAR_REGION_ACTION ) )
|
|
|
86 |
{
|
|
|
87 |
if ( cacheName == null )
|
|
|
88 |
{
|
|
|
89 |
// Not Allowed
|
|
|
90 |
}
|
|
|
91 |
else
|
|
|
92 |
{
|
|
|
93 |
jcsBean.clearRegion( cacheName );
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
else if ( action.equals( REMOVE_ACTION ) )
|
|
|
97 |
{
|
|
|
98 |
String[] keys = request.getParameterValues( KEY_PARAM );
|
|
|
99 |
|
|
|
100 |
for ( int i = 0; i < keys.length; i++ )
|
|
|
101 |
{
|
|
|
102 |
jcsBean.removeItem( cacheName, keys[ i ] );
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
templateName = REGION_DETAIL_TEMPLATE_NAME;
|
|
|
106 |
}
|
|
|
107 |
else if ( action.equals( DETAIL_ACTION ) )
|
|
|
108 |
{
|
|
|
109 |
templateName = REGION_DETAIL_TEMPLATE_NAME;
|
|
|
110 |
}
|
|
|
111 |
else if ( action.equals( ITEM_ACTION ) )
|
|
|
112 |
{
|
|
|
113 |
templateName = ITEM_TEMPLATE_NAME;
|
|
|
114 |
}
|
|
|
115 |
else if ( action.equals( REGION_SUMMARY_ACTION ) )
|
|
|
116 |
{
|
|
|
117 |
templateName = REGION_SUMMARY_TEMPLATE_NAME;
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
if ( request.getParameter( SILENT_PARAM ) != null )
|
|
|
122 |
{
|
|
|
123 |
// If silent parameter was passed, no output should be produced.
|
|
|
124 |
//return null;
|
|
|
125 |
}
|
|
|
126 |
else
|
|
|
127 |
{
|
|
|
128 |
// Populate the context based on the template
|
|
|
129 |
if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
|
|
|
130 |
{
|
|
|
131 |
//context.put( "cacheName", cacheName );
|
|
|
132 |
context.put( "elementInfoRecords", jcsBean.buildElementInfo( cacheName ) );
|
|
|
133 |
}
|
|
|
134 |
else if ( templateName == DEFAULT_TEMPLATE_NAME )
|
|
|
135 |
{
|
|
|
136 |
context.put( "cacheInfoRecords", jcsBean.buildCacheInfo() );
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
///////////////////////////////////////////////////////////////////////////////////
|
|
|
141 |
//handle display
|
|
|
142 |
|
|
|
143 |
if ( templateName == ITEM_TEMPLATE_NAME )
|
|
|
144 |
{
|
|
|
145 |
String key = request.getParameter( KEY_PARAM );
|
|
|
146 |
|
|
|
147 |
if ( key != null )
|
|
|
148 |
{
|
|
|
149 |
key = key.trim();
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
JCS cache = JCS.getInstance( cacheName );
|
|
|
153 |
|
|
|
154 |
org.apache.jcs.engine.behavior.ICacheElement element = cache.getCacheElement( key );
|
|
|
155 |
%>
|
|
|
156 |
<h1> Item for key [<%=key%>] in region [<%=cacheName%>] </h1>
|
|
|
157 |
|
|
|
158 |
<a href="JCSAdmin.jsp?action=detail&cacheName=<%=cacheName%>">Region Detail</a>
|
|
|
159 |
| <a href="JCSAdmin.jsp">All Regions</a>
|
|
|
160 |
|
|
|
161 |
<pre>
|
|
|
162 |
<%=element%>
|
|
|
163 |
</pre>
|
|
|
164 |
<%
|
|
|
165 |
}
|
|
|
166 |
else
|
|
|
167 |
if ( templateName == REGION_SUMMARY_TEMPLATE_NAME )
|
|
|
168 |
{
|
|
|
169 |
%>
|
|
|
170 |
|
|
|
171 |
<h1> Summary for region [<%=cacheName%>] </h1>
|
|
|
172 |
|
|
|
173 |
<a href="JCSAdmin.jsp">All Regions</a>
|
|
|
174 |
|
|
|
175 |
<%
|
|
|
176 |
JCS cache = JCS.getInstance( cacheName );
|
|
|
177 |
String stats = cache.getStats();
|
|
|
178 |
%>
|
|
|
179 |
|
|
|
180 |
<br>
|
|
|
181 |
<b> Stats for region [<%=cacheName%>] </b>
|
|
|
182 |
|
|
|
183 |
<pre>
|
|
|
184 |
<%=stats%>
|
|
|
185 |
</pre>
|
|
|
186 |
|
|
|
187 |
<%
|
|
|
188 |
}
|
|
|
189 |
else
|
|
|
190 |
if ( templateName == REGION_DETAIL_TEMPLATE_NAME )
|
|
|
191 |
{
|
|
|
192 |
%>
|
|
|
193 |
|
|
|
194 |
<h1> Detail for region [<%=cacheName%>] </h1>
|
|
|
195 |
|
|
|
196 |
<a href="JCSAdmin.jsp">All Regions</a>
|
|
|
197 |
|
|
|
198 |
<table border="1" cellpadding="5" >
|
|
|
199 |
<tr>
|
|
|
200 |
<th> Key </th>
|
|
|
201 |
<th> Eternal? </th>
|
|
|
202 |
<th> Create time </th>
|
|
|
203 |
<th> Max Life (s) </th>
|
|
|
204 |
<th> Till Expiration (s) </th>
|
|
|
205 |
</tr>
|
|
|
206 |
<%
|
|
|
207 |
List list = (List)context.get( "elementInfoRecords" );
|
|
|
208 |
Iterator it = list.iterator();
|
|
|
209 |
while ( it.hasNext() ) {
|
|
|
210 |
CacheElementInfo element = (CacheElementInfo)it.next();
|
|
|
211 |
%>
|
|
|
212 |
<tr>
|
|
|
213 |
<td> <%=element.getKey()%> </td>
|
|
|
214 |
<td> <%=element.isEternal()%> </td>
|
|
|
215 |
<td> <%=element.getCreateTime()%> </td>
|
|
|
216 |
<td> <%=element.getMaxLifeSeconds()%> </td>
|
|
|
217 |
<td> <%=element.getExpiresInSeconds()%> </td>
|
|
|
218 |
<td>
|
|
|
219 |
<a href="JCSAdmin.jsp?action=item&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> View </a>
|
|
|
220 |
| <a href="JCSAdmin.jsp?action=remove&cacheName=<%=cacheName%>&key=<%=element.getKey()%>"> Remove </a>
|
|
|
221 |
</td>
|
|
|
222 |
</tr>
|
|
|
223 |
<%
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
JCS cache = JCS.getInstance( cacheName );
|
|
|
227 |
String stats = cache.getStats();
|
|
|
228 |
%>
|
|
|
229 |
</table>
|
|
|
230 |
|
|
|
231 |
<br>
|
|
|
232 |
<b> Stats for region [<%=cacheName%>] </b>
|
|
|
233 |
|
|
|
234 |
<pre>
|
|
|
235 |
<%=stats%>
|
|
|
236 |
</pre>
|
|
|
237 |
<%
|
|
|
238 |
}
|
|
|
239 |
else
|
|
|
240 |
{
|
|
|
241 |
%>
|
|
|
242 |
|
|
|
243 |
<h1> Cache Regions </h1>
|
|
|
244 |
|
|
|
245 |
<p>
|
|
|
246 |
These are the regions which are currently defined in the cache. 'Items' and
|
|
|
247 |
'Bytes' refer to the elements currently in memory (not spooled). You can clear
|
|
|
248 |
all items for a region by selecting 'Remove all' next to the desired region
|
|
|
249 |
below. You can also <a href="javascript:decision('Clicking OK will clear all the data from all regions!','JCSAdmin.jsp?action=clearAllRegions')">Clear all regions</a>
|
|
|
250 |
which empties the entire cache.
|
|
|
251 |
</p>
|
|
|
252 |
<p>
|
|
|
253 |
<form action="JCSAdmin.jsp">
|
|
|
254 |
<input type="hidden" name="action" value="item">
|
|
|
255 |
Retrieve (key) <input type="text" name="key">
|
|
|
256 |
(region) <select name="cacheName">
|
|
|
257 |
<%
|
|
|
258 |
List listSelect = (List)context.get( "cacheInfoRecords" );
|
|
|
259 |
Iterator itSelect = listSelect.iterator();
|
|
|
260 |
while ( itSelect.hasNext() )
|
|
|
261 |
{
|
|
|
262 |
CacheRegionInfo record = (CacheRegionInfo)itSelect.next();
|
|
|
263 |
%>
|
|
|
264 |
<option value="<%=record.getCache().getCacheName()%>"><%=record.getCache().getCacheName()%></option>
|
|
|
265 |
<%
|
|
|
266 |
}
|
|
|
267 |
%>
|
|
|
268 |
</select>
|
|
|
269 |
<input type="submit">
|
|
|
270 |
</form>
|
|
|
271 |
</p>
|
|
|
272 |
|
|
|
273 |
<table border="1" cellpadding="5" >
|
|
|
274 |
<tr>
|
|
|
275 |
<th> Cache Name </th>
|
|
|
276 |
<th> Items </th>
|
|
|
277 |
<th> Bytes </th>
|
|
|
278 |
<th> Status </th>
|
|
|
279 |
<th> Memory Hits </th>
|
|
|
280 |
<th> Aux Hits </th>
|
|
|
281 |
<th> Not Found Misses </th>
|
|
|
282 |
<th> Expired Misses </th>
|
|
|
283 |
</tr>
|
|
|
284 |
|
|
|
285 |
<%
|
|
|
286 |
List list = (List)context.get( "cacheInfoRecords" );
|
|
|
287 |
Iterator it = list.iterator();
|
|
|
288 |
while (it.hasNext() )
|
|
|
289 |
{
|
|
|
290 |
CacheRegionInfo record = (CacheRegionInfo)it.next();
|
|
|
291 |
|
|
|
292 |
%>
|
|
|
293 |
<tr>
|
|
|
294 |
<td> <%=record.getCache().getCacheName()%> </td>
|
|
|
295 |
<td> <%=record.getCache().getSize()%> </td>
|
|
|
296 |
<td> <%=record.getByteCount()%> </td>
|
|
|
297 |
<td> <%=record.getStatus()%> </td>
|
|
|
298 |
<td> <%=record.getCache().getHitCountRam()%> </td>
|
|
|
299 |
<td> <%=record.getCache().getHitCountAux()%> </td>
|
|
|
300 |
<td> <%=record.getCache().getMissCountNotFound()%> </td>
|
|
|
301 |
<td> <%=record.getCache().getMissCountExpired()%> </td>
|
|
|
302 |
<td>
|
|
|
303 |
<a href="JCSAdmin.jsp?action=regionSummary&cacheName=<%=record.getCache().getCacheName()%>"> Summary </a>
|
|
|
304 |
| <a href="JCSAdmin.jsp?action=detail&cacheName=<%=record.getCache().getCacheName()%>"> Detail </a>
|
|
|
305 |
| <a href="javascript:decision('Clicking OK will remove all the data from the region [<%=record.getCache().getCacheName()%>]!','JCSAdmin.jsp?action=clearRegion&cacheName=<%=record.getCache().getCacheName()%>')"> Clear </a>
|
|
|
306 |
</td>
|
|
|
307 |
</tr>
|
|
|
308 |
<%
|
|
|
309 |
}
|
|
|
310 |
%>
|
|
|
311 |
</table>
|
|
|
312 |
<%
|
|
|
313 |
}
|
|
|
314 |
%>
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
</body>
|
|
|
318 |
|
|
|
319 |
</html>
|