⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache.jsp

📁 jive Study
💻 JSP
字号:
<%@ page contentType="text/html;charset=UTF-8" %>
<%
/**
 *	$RCSfile: cache.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:09 $
 */
%>

<%@ page import="java.util.*,
				 java.text.*,
				 com.jivesoftware.util.*,
                 com.jivesoftware.forum.*,
				 com.jivesoftware.forum.database.*,
				 com.jivesoftware.forum.util.*"
%>

<%!	// global variables

	// decimal formatter for cache values
	static final DecimalFormat mbFormat = new DecimalFormat("#0.00");
	static final DecimalFormat percentFormat = new DecimalFormat("#0.0");

	// cache identifiers, names
	static final int[] CACHE_TYPES = {
		DatabaseCacheManager.FORUM_CACHE,
		DatabaseCacheManager.THREAD_CACHE,
		DatabaseCacheManager.MESSAGE_CACHE,
		DatabaseCacheManager.USER_CACHE,
		DatabaseCacheManager.USER_PERMS_CACHE,
		DatabaseCacheManager.GROUP_CACHE
	};
	static final String[] CACHE_NAMES = {
		"论坛",
		"主题",
		"消息",
		"用户",
		"用户许可",
		"用户组"
	};
    // variable for the VM memory monitor box
    static final int NUM_BLOCKS = 50;
%>

<%@ include file="global.jsp" %>

<%	// get parameters
	boolean cacheEnabled = ParamUtils.getBooleanParameter(request,"cacheEnabled");
	boolean doCache = ParamUtils.getBooleanParameter(request,"doCache");
    boolean clearCache = ParamUtils.getBooleanParameter(request,"clearCache");

	// Get the underlying DbForumFactory
	DbForumFactory dbForumFactory = null;
	try {
		dbForumFactory = (DbForumFactory)(((ForumFactoryProxy)forumFactory).getProxiedForumFactory());
	} catch (Exception e) {}

	// Get a cache manager
	DatabaseCacheManager cacheManager = dbForumFactory.getCacheManager();

    if (clearCache) {
        for (int i=0; i<CACHE_TYPES.length; i++) {
            cacheManager.clear(CACHE_TYPES[i]);
        }
        response.sendRedirect("cache.jsp");
        return;
    }

	// turn the cache on or off
	if (doCache) {
		cacheManager.setCacheEnabled(cacheEnabled);
		response.sendRedirect("cache.jsp");
		return;
	}
	cacheEnabled = cacheManager.isCacheEnabled();
%>

<%@ include file="header.jsp" %>

<p>

<%  // Title of this page and breadcrumbs
    String title = "缓存设置";
    String[][] breadcrumbs = {
        {"主页面", "main.jsp"},
        {"缓存设置", "cache.jsp"}
    };
%>
<%@ include file="title.jsp" %>

<font size="-1">
Jive论坛依赖于它的缓存有效的处理论坛数据。使用此面板监视和修改你的缓存设置。只有在非常少见的情况下你需要完全关闭缓存功能。你可以编辑缓存的大小调整成最小的内存使用或者最好的性能。
</font>

<p>

<font size="-1"><b>缓存状态</b></font>
<ul>
    <font size="-1">
    你可以使用下面的表单打开或者关闭Jive的缓存功能。关闭缓存将严重的降低性能!
    </font>
    <form action="cache.jsp">
    <input type="hidden" name="doCache" value="true">
    <table bgcolor="<%= tblBorderColor %>" cellpadding="0" cellspacing="0" border="0" width="300">
    <td>
    <table bgcolor="<%= tblBorderColor %>" cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr bgcolor="#ffffff">
	<td align="center"<%= (cacheEnabled)?" bgcolor=\"#99cc99\"":"" %>>
        <font size="-1">
		<input type="radio" name="cacheEnabled" value="true" id="rb01"
		 <%= (cacheEnabled)?"checked":"" %>>
		<label for="rb01"><%= (cacheEnabled)?"<b>打开</b>":"打开" %></label>
        </font>
	</td>
	<td align="center"<%= (!cacheEnabled)?" bgcolor=\"#cc6666\"":"" %>>
        <font size="-1">
		<input type="radio" name="cacheEnabled" value="false" id="rb02"
		 <%= (!cacheEnabled)?"checked":"" %>>
		<label for="rb02"><%= (!cacheEnabled)?"<b>关闭</b>":"关闭" %></label>
        </font>
	</td>
	<td align="center">
		<font size="-1"><input type="submit" value="更新"></font>
	</td>
    </tr>
    </table>
    </td>
    </table>
    </form>
    <%  if (cacheEnabled) { %>
    <p>
    <font size="-1">
    你可以单击下面的按钮清除所有的缓存内容。
    </font>
    <form action="cache.jsp">
    <input type="hidden" name="clearCache" value="true">
    <input type="submit" value="清除缓存内容">
    </form>
    <%  } %>
</ul>

<%  if (cacheEnabled) { %>
<p>

<font size="-1"><b>缓存性能概览</b></font>
<ul>
    <font size="-1">
    下面是所有缓存的概览。要调整各个缓存的大小,单击下面的“编辑缓存大小”按钮
    <p>
    效力测量告诉你你的缓存工作得如何。如果效力低,那么通常意味着你的缓存太小。各个部分的情况标记于下:
    </font>
    <p>
	<table bgcolor="<%= tblBorderColor %>" cellpadding="0" cellspacing="0" border="0">
	<td>
	<table cellpadding="4" cellspacing="1" border="0" width="100%">
	<tr bgcolor="#eeeeee">
	<td align="center"><font size="-2" face="verdana"><b>缓存类型</b></font></td>
	<td align="center"><font size="-2" face="verdana"><b>大小</b></font></td>
	<td align="center"><font size="-2" face="verdana"><b>对象数</b></font></td>
	<td align="center"><font size="-2" face="verdana"><b>效力</b></font></td>
    </tr>

<%	// cache variables
	double memUsed;
	double totalMem;
	double freeMem;
	double hitPercent;
	long hits;
	long misses;

	// Loop through each cache, print out its info
	for( int i=0; i<CACHE_TYPES.length; i++ ) {
		String name = CACHE_NAMES[i];
		int type = CACHE_TYPES[i];
		memUsed = (double)cacheManager.getSize(type)/(1024*1024);
		totalMem = (double)cacheManager.getMaxSize(type)/(1024*1024);
		freeMem = 100 - 100*memUsed/totalMem;
		hits = cacheManager.getHits(type);
		misses = cacheManager.getMisses(type);
		if (hits + misses == 0) {
			hitPercent = 0.0;
		}
		else {
			hitPercent = 100*(double)hits/(hits+misses);
		}
        boolean lowEffec = (hits > 500 && hitPercent < 85.0 && freeMem < 20.0);
%>
	<tr bgcolor="#ffffff">
		<td><font size="-1"><%= name %></font></td>
		<td align="right">
            <font size="-1">
            &nbsp;
			<%= mbFormat.format(totalMem) %> MB,
			<%= percentFormat.format(freeMem)%>% 空闲
            &nbsp;
            </font>
		</td>
		<td align="right">
			<font size="-1">
            &nbsp;
            <%= cacheManager.getNumElements(type) %>
            &nbsp;
            </font>
		</td>
		<td align="right">
            <font size="-1">
            &nbsp;
            <%  if (lowEffec) { %>
			<font color="#ff0000"><b><%= percentFormat.format(hitPercent)%>%</b></font>
            <%  } else { %>
			<b><%= percentFormat.format(hitPercent)%>%</b>
            <%  } %>
			(<%= hits %> 次点击, <%= misses %> 次未击中)
            &nbsp;
            </font>
		</td>
	</tr>
<%	} %>

	</table>
	</td>
	</table>
    <p>
    <form action="editCache.jsp">
    <input type="submit" value="编辑缓存大小">
    </form>

</ul>
<%  } // end if cacheEnabled %>

<p>

<font size="-1"><b>Java VM (Java虚拟机)内存</b></font>
<ul>

<%	// The java runtime
	Runtime runtime = Runtime.getRuntime();

    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;
    int free = 100-(int)Math.round(percentFree);
%>
	<table border=0>
	<tr><td><font size="-1">已用内存:</font></td>
        <td><font size="-1"><%= mbFormat.format(usedMemory) %> MB</font></td>
    </tr>
	<tr><td><font size="-1">内存总量:</font></td>
        <td><font size="-1"><%= mbFormat.format(totalMemory) %> MB</font></td>
    </tr>
	</table>
	<br>
    <table border=0><td>
    <table bgcolor="#000000" cellpadding="1" cellspacing="0" border="0" width="200" align=left>
    <td>
    <table bgcolor="#000000" cellpadding="1" cellspacing="1" border="0" width="100%">
<%    for (int i=0; i<NUM_BLOCKS; i++) {
        if ((i*(100/NUM_BLOCKS)) < free) {
    %>
    	<td bgcolor="#00ff00" width="<%= (100/NUM_BLOCKS) %>%"><img src="images/blank.gif" width="1" height="15" border="0"></td>
<%		} else { %>
    	<td bgcolor="#006600" width="<%= (100/NUM_BLOCKS) %>%"><img src="images/blank.gif" width="1" height="15" border="0"></td>
<%		}
    }
%>
    </table>
    </td>
    </table></td><td>
        <font size="-1">
        &nbsp;<b><%= percentFormat.format(percentFree) %>% 空闲</b>
        </font>
    </td></table>
</ul>

<%	// Destroy the runtime reference
	runtime = null;
%>

<%@ include file="footer.jsp" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -