cache.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:16k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * $RCSfile: cache.jsp,v $
- * $Revision: 1.3.2.1 $
- * $Date: 2001/05/10 02:06:34 $
- */
- %>
- <%@ page import="java.util.*,
- java.text.*,
- com.coolservlets.forum.*,
- com.coolservlets.util.*,
- com.coolservlets.forum.database.*,
- com.coolservlets.forum.util.*,
- com.coolservlets.forum.util.admin.*" %>
- <jsp:useBean id="adminBean" scope="session"
- class="com.coolservlets.forum.util.admin.AdminBean"/>
- <% ////////////////////////////////
- // Jive authorization check
- // check the bean for the existence of an authorization token.
- // Its existence proves the user is valid. If it's not found, redirect
- // to the login page
- Authorization authToken = adminBean.getAuthToken();
- if( authToken == null ) {
- response.sendRedirect( "/mainctrl/bbs/admin" );
- return;
- }
- %>
- <% ////////////////////
- // Security check
- // make sure the user is authorized to create forums::
- ForumFactory forumFactory = ForumFactory.getInstance(authToken);
- ForumPermissions permissions = forumFactory.getPermissions(authToken);
- boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
- // redirect to error page if we're not a forum admin or a system admin
- if( !isSystemAdmin ) {
- request.setAttribute("message","没有权限创建论坛");
- response.sendRedirect("error.jsp");
- return;
- }
- %>
- <% /////////////////
- // get parameters
- int cacheID = ParamUtils.getIntParameter(request,"cacheID",-1);
- boolean doClear = ParamUtils.getBooleanParameter(request,"doClear");
- boolean doEdit = ParamUtils.getBooleanParameter(request,"doEdit");
- boolean doSave = ParamUtils.getBooleanParameter(request,"doSave");
- int maxSize = ParamUtils.getIntParameter(request,"cacheMaxSize",-1);
- boolean cacheEnabled = ParamUtils.getBooleanParameter(request,"cacheEnabled");
- boolean doCache = ParamUtils.getBooleanParameter(request,"doCache");
- DbForumFactory dbForumFactory = null;
- try {
- dbForumFactory = (DbForumFactory)((ForumFactoryProxy)forumFactory).getUnderlyingForumFactory();
- } catch (Exception e) { }
- DbCacheManager cacheManager = dbForumFactory.getCacheManager();
- // clear the requested cache
- if( doClear ) {
- if( cacheID != -1 ) {
- cacheManager.clear(cacheID);
- }
- }
- if( doSave ) {
- if( cacheID != -1 ) {
- Cache cache = cacheManager.getCache(cacheID);
- cache.setMaxSize(maxSize*1024);
- }
- }
- // turn the cache on or off
- if( doCache ) {
- cacheManager.setCacheEnabled(cacheEnabled);
- }
- cacheEnabled = cacheManager.isCacheEnabled();
- %>
- <%!
- Runtime runtime = Runtime.getRuntime();
- %>
- <html>
- <head>
- <title></title>
- <link rel="stylesheet" href="style/global.css">
- <script language="JavaScript" type="text/javascript">
- function convert(src,dest) {
- if( dest.value == "" ) { return; }
- var unit = src.options[src.selectedIndex].value;
- if( unit == "K" ) {
- dest.value = dest.value * 1024;
- } else if( unit == "MB" ) {
- dest.value = dest.value / 1024;
- }
- }
- </script>
- </head>
- <body background="images/shadowBack.gif" bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
- <% ///////////////////////
- // pageTitleInfo variable (used by include/pageTitle.jsp)
- String[] pageTitleInfo = { "缓存" };
- %>
- <% ///////////////////
- // pageTitle include
- %><%@ include file="include/pageTitle.jsp" %>
- <p>
- <b>缓存列表</b>
- <ul>
- <% DecimalFormat formatter = new DecimalFormat("#.00");
- %>
- <table bgcolor="#999999" cellpadding="0" cellspacing="0" border="0">
- <td>
- <table cellpadding="4" cellspacing="1" border="0" width="100%">
- <tr bgcolor="#eeeeee">
- <td class="forumCellHeader" align="center"><b>缓存类型</b></td>
- <td class="forumCellHeader" align="center"><b>大小</b></td>
- <td class="forumCellHeader" align="center"><b>对象</b></td>
- <td class="forumCellHeader" align="center"><b>效果</b></td>
- <td class="forumCellHeader" align="center"> </td>
- </tr>
- <%
- Cache cache;
- double memUsed, totalMem, freeMem, hitPercent;
- long hits, misses;
- %>
- <tr bgcolor="#ffffff">
- <% cache = cacheManager.getCache(DbCacheManager.MESSAGE_CACHE); %>
- <td>帖子</td>
- <%
- memUsed = (double)cache.getSize()/(1024*1024);
- totalMem = (double)cache.getMaxSize()/(1024*1024);
- freeMem = 100 - 100*memUsed/totalMem;
- %>
- <td><%= formatter.format(totalMem) %> MB,
- <%= formatter.format(freeMem)%>%空闲
- </td>
- <td align=right> <%= cache.getNumElements() %> </td>
- <%
- hits = cache.getCacheHits();
- misses = cache.getCacheMisses();
- if (hits + misses == 0) { hitPercent = 0.0; }
- else { hitPercent = 100*(double)hits/(hits+misses); }
- %>
- <td><%= formatter.format(hitPercent)%>% (<%= hits %>命中,<%= misses %>错失)</td>
- <form action="cache.jsp">
- <input type="hidden" name="doEdit" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.MESSAGE_CACHE %>">
- </form>
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.MESSAGE_CACHE %>">
- <td><input type="submit" value="清理缓存"></td>
- </form>
- </tr>
- <% if( doEdit && cacheID==DbCacheManager.MESSAGE_CACHE ) { %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doSave" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.MESSAGE_CACHE %>">
- <td colspan="4">
- 设置帖子大小:
- <input type="text" value="<%= cache.getMaxSize()/1024 %>" size="6"
- name="cacheMaxSize">K
- <br>
- 1024 K = 1 MB, 2048 K = 2 MB, 3072 K = 3 MB
- </td>
- <td colspan="2" align="center"><input type="submit" value="保存"></td>
- </form>
- </tr>
- <% } %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.THREAD_CACHE %>">
- <% cache = cacheManager.getCache(DbCacheManager.THREAD_CACHE); %>
- <td>主题</td>
- <%
- memUsed = (double)cache.getSize()/(1024*1024);
- totalMem = (double)cache.getMaxSize()/(1024*1024);
- freeMem = 100 - 100*memUsed/totalMem;
- %>
- <td><%= formatter.format(totalMem) %> MB,
- <%= formatter.format(freeMem)%>%空闲
- </td>
- <td align=right> <%= cache.getNumElements() %> </td>
- <%
- hits = cache.getCacheHits();
- misses = cache.getCacheMisses();
- if (hits + misses == 0) { hitPercent = 0.0; }
- else { hitPercent = 100*(double)hits/(hits+misses); }
- %>
- <td><%= formatter.format(hitPercent)%>% (<%= hits %>命中,<%= misses %>错失)</td>
- <form action="cache.jsp">
- <input type="hidden" name="doEdit" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.THREAD_CACHE %>">
- </form>
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.THREAD_CACHE %>">
- <td><input type="submit" value="清理缓存"></td>
- </form>
- </tr>
- <% if( doEdit && cacheID==DbCacheManager.THREAD_CACHE ) { %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doSave" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.THREAD_CACHE %>">
- <td colspan="4">
- 设置帖子大小:
- <input type="text" value="<%= cache.getMaxSize()/1024 %>" size="6"
- name="cacheMaxSize">K
- <br>
- 1024 K = 1 MB, 2048 K = 2 MB, 3072 K = 3 MB
- </td>
- <td colspan="2" align="center"><input type="submit" value="保存"></td>
- </form>
- </tr>
- <% } %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.FORUM_CACHE %>">
- <% cache = cacheManager.getCache(DbCacheManager.FORUM_CACHE); %>
- <td>论坛</td>
- <%
- memUsed = (double)cache.getSize()/(1024*1024);
- totalMem = (double)cache.getMaxSize()/(1024*1024);
- freeMem = 100 - 100*memUsed/totalMem;
- %>
- <td><%= formatter.format(totalMem) %> MB,
- <%= formatter.format(freeMem)%>%空闲
- </td>
- <td align=right> <%= cache.getNumElements() %> </td>
- <%
- hits = cache.getCacheHits();
- misses = cache.getCacheMisses();
- if (hits + misses == 0) { hitPercent = 0.0; }
- else { hitPercent = 100*(double)hits/(hits+misses); }
- %>
- <td><%= formatter.format(hitPercent)%>% (<%= hits %>命中,<%= misses %>错失)</td>
- <form action="cache.jsp">
- <input type="hidden" name="doEdit" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.FORUM_CACHE %>">
- </form>
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.FORUM_CACHE %>">
- <td><input type="submit" value="清理缓存"></td>
- </form>
- </tr>
- <% if( doEdit && cacheID==DbCacheManager.FORUM_CACHE ) { %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doSave" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.FORUM_CACHE %>">
- <td colspan="4">
- 设置帖子大小:
- <input type="text" value="<%= cache.getMaxSize()/1024 %>" size="6"
- name="cacheMaxSize">K
- <br>
- 1024 K = 1 MB, 2048 K = 2 MB, 3072 K = 3 MB
- </td>
- <td colspan="2" align="center"><input type="submit" value="保存"></td>
- </form>
- </tr>
- <% } %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.USER_CACHE %>">
- <% cache = cacheManager.getCache(DbCacheManager.USER_CACHE); %>
- <td>用户</td>
- <%
- memUsed = (double)cache.getSize()/(1024*1024);
- totalMem = (double)cache.getMaxSize()/(1024*1024);
- freeMem = 100 - 100*memUsed/totalMem;
- %>
- <td><%= formatter.format(totalMem) %> MB,
- <%= formatter.format(freeMem)%>%空闲
- </td>
- <td align=right> <%= cache.getNumElements() %> </td>
- <%
- hits = cache.getCacheHits();
- misses = cache.getCacheMisses();
- if (hits + misses == 0) { hitPercent = 0.0; }
- else { hitPercent = 100*(double)hits/(hits+misses); }
- %>
- <td><%= formatter.format(hitPercent)%>% (<%= hits %>命中,<%= misses %>错失)</td>
- <form action="cache.jsp">
- <input type="hidden" name="doEdit" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.USER_CACHE %>">
- </form>
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.USER_CACHE %>">
- <td><input type="submit" value="清理缓存"></td>
- </form>
- </tr>
- <% if( doEdit && cacheID==DbCacheManager.USER_CACHE ) { %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doSave" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.USER_CACHE %>">
- <td colspan="4">
- 设置帖子大小:
- <input type="text" value="<%= cache.getMaxSize()/1024 %>" size="6"
- name="cacheMaxSize">K
- <br>
- 1024 K = 1 MB, 2048 K = 2 MB, 3072 K = 3 MB
- </td>
- <td colspan="2" align="center"><input type="submit" value="保存"></td>
- </form>
- </tr>
- <% } %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.GROUP_CACHE %>">
- <% cache = cacheManager.getCache(DbCacheManager.GROUP_CACHE); %>
- <td>用户组</td>
- <%
- memUsed = (double)cache.getSize()/(1024*1024);
- totalMem = (double)cache.getMaxSize()/(1024*1024);
- freeMem = 100 - 100*memUsed/totalMem;
- %>
- <td><%= formatter.format(totalMem) %> MB,
- <%= formatter.format(freeMem)%>%空闲
- </td>
- <td align=right> <%= cache.getNumElements() %> </td>
- <%
- hits = cache.getCacheHits();
- misses = cache.getCacheMisses();
- if (hits + misses == 0) { hitPercent = 0.0; }
- else { hitPercent = 100*(double)hits/(hits+misses); }
- %>
- <td><%= formatter.format(hitPercent)%>% (<%= hits %>命中,<%= misses %>错失)</td>
- <form action="cache.jsp">
- <input type="hidden" name="doEdit" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.GROUP_CACHE %>">
- </form>
- <form action="cache.jsp">
- <input type="hidden" name="doClear" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.GROUP_CACHE %>">
- <td><input type="submit" value="清理缓存"></td>
- </form>
- </tr>
- <% if( doEdit && cacheID==DbCacheManager.GROUP_CACHE ) { %>
- <tr bgcolor="#ffffff">
- <form action="cache.jsp">
- <input type="hidden" name="doSave" value="true">
- <input type="hidden" name="cacheID" value="<%= DbCacheManager.GROUP_CACHE %>">
- <td colspan="4">
- 设置帖子大小:
- <input type="text" value="<%= cache.getMaxSize()/1024 %>" size="6"
- name="cacheMaxSize">K
- <br>
- 1024 K = 1 MB, 2048 K = 2 MB, 3072 K = 3 MB
- </td>
- <td colspan="2" align="center"><input type="submit" value="保存"></td>
- </form>
- </tr>
- <% } %>
- </table>
- </td>
- </table>
- </ul>
- <p>
- <b>Java虚拟机内存</b>
- <ul>
- <%
- double freeMemory = (double)runtime.freeMemory()/(1024*1024);
- double totalMemory = (double)runtime.totalMemory()/(1024*1024);
- double usedMemory = totalMemory - freeMemory;
- double percentFree = ((double)freeMemory/(double)totalMemory)*100.0;
- %>
- <table border=0>
- <tr><td>使用的内存:</td><td><%= formatter.format(usedMemory) %> MB</td></tr>
- <tr><td>内存总额:</td><td><%= formatter.format(totalMemory) %> MB</td></tr>
- </table>
- <br>
- <!--
- <table bgcolor="#000000" cellpadding="1" cellspacing="0" border="0" width="300">
- <td>
- <table bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%">
- <td width="<%= percentFree %>%" background="images/cache.gif"><img src="images/blank.gif" width="<%= percentFree %>" height="20" border="0"></td>
- <td width="<%= 100-percentFree %>%"></td>
- </table>
- </td>
- </table>
- <b><%= formatter.format(percentFree) %>% free</b>
- <p>
- -->
- <% int free = 100-(int)Math.round(percentFree); %>
- <% int tableWidth = 200; %>
- <% int numBlocks = 50; %>
- <table border=0><td>
- <table bgcolor="#000000" cellpadding="1" cellspacing="0" border="0" width="<%= tableWidth %>" align=left>
- <td>
- <table bgcolor="#000000" cellpadding="1" cellspacing="1" border="0" width="100%">
- <% for( int i=0; i<numBlocks; i++ ) { %>
- <% if( (i*(100/numBlocks)) < free ) { %>
- <td bgcolor="#00ff00" width="<%= (100/numBlocks) %>%"><img src="blank.gif" width="1" height="15" border="0"></td>
- <% } else { %>
- <td bgcolor="#006600" width="<%= (100/numBlocks) %>%"><img src="blank.gif" width="1" height="15" border="0"></td>
- <% } %>
- <% } %>
- </table>
- </td>
- </table></td><td> <b><%= formatter.format(percentFree) %>% 空闲</b> </td></table>
- </ul>
- <p>
- <b>缓存状态</b>
- <ul>
- <form action="cache.jsp">
- <input type="hidden" name="doCache" value="true">
- <table bgcolor="#666666" cellpadding="0" cellspacing="0" border="0" width="300">
- <td>
- <table bgcolor="#666666" cellpadding="3" cellspacing="1" border="0" width="100%">
- <tr bgcolor="#ffffff">
- <td align="center"<%= (cacheEnabled)?" bgcolor="#99cc99"":"" %>>
- <input type="radio" name="cacheEnabled" value="true" id="rb01"
- <%= (cacheEnabled)?"checked":"" %>>
- <label for="rb01"><%= (cacheEnabled)?"<b>开</b>":"开" %></label>
- </td>
- <td align="center"<%= (!cacheEnabled)?" bgcolor="#cc6666"":"" %>>
- <input type="radio" name="cacheEnabled" value="false" id="rb02"
- <%= (!cacheEnabled)?"checked":"" %>>
- <label for="rb02"><%= (!cacheEnabled)?"<b>关</b>":"关" %></label>
- </td>
- <td align="center">
- <input type="submit" value="修改">
- </td>
- </tr>
- </table>
- </td>
- </table>
- </ul>
- </body>
- </html>