tableCacheMonitor.jsp
4.67 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<%@ 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.*,java.util.concurrent.ConcurrentHashMap" %>
<html>
<%@ include file="commoncache.jsp" %>
<body>
<a href = "tableCacheMonitor.jsp?cachetype=1<%= urlskey%>" >查询缓存次数排序</a>
<a href = "tableCacheMonitor.jsp?cachetype=2<%= urlskey%>" >查询数据库次数排序</a>
<a href = "tableCacheMonitor.jsp?cachetype=3<%= urlskey%>" >表清空次数排序</a>
表缓存名称:
<input id="tableName" type="textfield"></input>
<button><a onclick="updateTableCache('tableName')">清空表缓存</a> </button>
<button><a href = "cacheMonitor.jsp" >sql缓存监控</a> </button>
<button><a href = "export.jsp?type=table" >导出</a> </button>
<%
final int PAGESIZE = 15;
int pageCount =0;
int curPage = 1;
String tablesort ="";
String cachetype ="";
final String queryCountStr ="queryCount";
final String delCountStr ="delCount";
final String queryDbCountStr ="queryDbCount";
CacheFactory sintance = CacheFactory.getInstance();
int size =0;
ConcurrentHashMap<String, Object> cacheMap = sintance.getTableMap();
List cacheList = ListSorter.converMapToList(cacheMap,searchkey);
size = cacheList.size();
pageCount = (size%PAGESIZE==0)?(size/PAGESIZE):(size/PAGESIZE+1);
String updatetablecache = request.getParameter("updatetablecache");
if(updatetablecache != null){
String tkey = updatetablecache.trim().toLowerCase();
String [] tables = new String[]{tkey};
sintance.removeCache(tables);
}
%>
<h1><%= title %> 总缓存的数量(<%= size %>)</h1>
<table border="1" spacing="2">
<tr>
<td>表名</td>
<td>缓存时间</td>
<td>表查询数据库次数</td>
<td>表缓存查询次数</td>
<td>表缓存清空次数</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,delCountStr);
}else{
ListSorter.sort(cacheList,queryCountStr);
}
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;
TableCacheBean bean =(TableCacheBean) cacheList.get(currIndex);
String tName = new Date(bean.getTimeflag()).toLocaleString();
String tableName = bean.getTableName();
long qCount = bean.getQueryCount();
long dbCount = bean.getQueryDbCount();
long rCount = bean.getDelCount();
count ++;
currIndex ++;
%>
<tr>
<td><%=tableName%></td>
<td><%=tName%></td>
<td><%=dbCount%></td>
<td><%=qCount%></td>
<td><%=rCount%></td>
</tr>
<%
}while(currIndex<cacheList.size());
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
<a href = "tableCacheMonitor.jsp?curPage=1&cachetype=<%=cachetype%><%= urlskey%>" >首页</a>
<a href = "tableCacheMonitor.jsp?curPage=<%=curPage-1%>&cachetype=<%=cachetype%><%= urlskey%>" >上一页</a>
<a href = "tableCacheMonitor.jsp?curPage=<%=curPage+1%>&cachetype=<%=cachetype%><%= urlskey%>" >下一页</a>
<a href = "tableCacheMonitor.jsp?curPage=<%=pageCount%>&cachetype=<%=cachetype%><%= urlskey%>" >尾页</a>
第<%=curPage%>页/共<%=pageCount%>页
<script>
function updateTableCache(key){
var value = document.getElementById(key).value;
var url = window.location.href;
url = url.substring(0,url.indexOf('?'));
url = url + "?updatetablecache="+value+"&searchkey="+value;
location.href = url;
}
function dosearch(key){
var searchkey = document.getElementById(key).value;
var url = window.location.href;
url = url.substring(0,url.indexOf('?'));
url = url + "?searchkey="+searchkey.toLowerCase();
location.href = url;
}
</script>
</body>
</html>