cacheMonitor.jsp
3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ page import="javax.servlet.http.*,javax.servlet.*,java.io.*,java.util.*,weaver.monitor.cache.monitor.*,weaver.monitor.cache.Util.*,weaver.monitor.cache.*" %>
<html>
<%@ include file="commoncache.jsp" %>
<body>
<br/>
<a href = "cacheMonitor.jsp?cachetype=1<%= urlskey%>" >查询缓存次数排序</a>
<a href = "cacheMonitor.jsp?cachetype=2<%= urlskey%>" >查询数据库次数排序</a>
<a href = "cacheMonitor.jsp?cachetype=3<%= urlskey%>" >查询数据库时间排序</a>
<button><a href = "tableCacheMonitor.jsp" >表缓存监控</a> </button>
<button><a href = "export.jsp?type=sql" >导出</a> </button>
<%
final int PAGESIZE = 15;
int pageCount;
int curPage = 1;
String tablesort ="";
String cachetype ="";
final String queryCountStr ="queryCount";
final String queryDbCountStr ="queryDbCount";
final String queryLostTimeStr ="queryLostTime";
CacheFactory sintance = CacheFactory.getInstance();
int size =0;
LRULinkedHashMap<String, Object> cacheMap = sintance.getCacheMap();
List cacheList = ListSorter.converMapToList(cacheMap,searchkey);
size = cacheList.size();
pageCount = (size%PAGESIZE==0)?(size/PAGESIZE):(size/PAGESIZE+1);
long tt = TableCacheBean.sumQueryCount.longValue();
%>
<h1><%= title %> 缓存数量(<%= size %>) <%= tt %></h1>
<table border="1" spacing="2">
<tr>
<td>缓存时间</td>
<td>sql查询数据库次数</td>
<td>sql查询数据库花费时间</td>
<td>sql</td>
<td>sql缓存查询次数</td>
</tr>
<%
//一页放5个
try{
String tmp = request.getParameter("curPage");
tablesort = request.getParameter("tablesort");
cachetype = request.getParameter("cachetype");
if("2".equals(cachetype)){
ListSorter.sort(cacheList,queryDbCountStr);
}else if("1".equals(cachetype)){
ListSorter.sort(cacheList,queryCountStr);
}else if("3".equals(cachetype)){
ListSorter.sort(cacheList,queryLostTimeStr);
}
if(tmp == null){
tmp="1";
}
curPage = Integer.parseInt(tmp);
if(curPage>=pageCount) curPage = pageCount;
int currIndex = (curPage-1)*PAGESIZE;
out.println(curPage);
int count = 0;
do{
if(count>=PAGESIZE || currIndex>= cacheList.size() || currIndex <0)break;
SQLCacheBean bean =(SQLCacheBean) cacheList.get(currIndex);
String tName = new Date(bean.getLastCacheTime()).toLocaleString();
String sql = bean.getSql();
long qCount = bean.getQueryCount();
long rCount = bean.getQueryDbCount();
long lostTime = bean.getQueryLostTime();
count ++;
currIndex ++;
%>
<tr>
<td><%=tName%></td>
<td><%=rCount%></td>
<td><%=lostTime%></td>
<td><%=sql%></td>
<td><%=qCount%></td>
</tr>
<%
}while(currIndex<cacheList.size());
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
<a href = "cacheMonitor.jsp?curPage=1&cachetype=<%=cachetype%><%= urlskey%>" >首页</a>
<a href = "cacheMonitor.jsp?curPage=<%=curPage-1%>&cachetype=<%=cachetype%><%= urlskey%>" >上一页</a>
<a href = "cacheMonitor.jsp?curPage=<%=curPage+1%>&cachetype=<%=cachetype%><%= urlskey%>" >下一页</a>
<a href = "cacheMonitor.jsp?curPage=<%=pageCount%>&cachetype=<%=cachetype%><%= urlskey%>" >尾页</a>
第<%=curPage%>页/共<%=pageCount%>页
</body>
<script>
function dosearch(key){
var searchkey = document.getElementById(key).value;
var url = window.location.href;
url = url.substring(0,url.indexOf('?'));
url = url + "?searchkey="+searchkey;
location.href = url;
}
</script>
</html>