mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve uriStatView
This commit is contained in:
@@ -100,6 +100,11 @@ public class JSONDruidStatService {
|
||||
if (url.startsWith("/weburi.json")) {
|
||||
return returnJSONResult(RESULT_CODE_SUCCESS, getWebURIStatDataList(parameters));
|
||||
}
|
||||
|
||||
if (url.startsWith("/weburi-") && url.indexOf(".json") > 0) {
|
||||
String uri = StringUtils.subString(url, "weburi-", ".json");
|
||||
return returnJSONResult(RESULT_CODE_SUCCESS, getWebURIStatData(uri));
|
||||
}
|
||||
|
||||
if (url.startsWith("/websession.json")) {
|
||||
return returnJSONResult(RESULT_CODE_SUCCESS, getWebSessionStatDataList(parameters));
|
||||
@@ -107,7 +112,7 @@ public class JSONDruidStatService {
|
||||
|
||||
if (url.startsWith("/websession-") && url.indexOf(".json") > 0) {
|
||||
String id = StringUtils.subString(url, "websession-", ".json");
|
||||
return returnJSONResult(RESULT_CODE_SUCCESS, getWebSessionDetail(id));
|
||||
return returnJSONResult(RESULT_CODE_SUCCESS, getWebSessionStatData(id));
|
||||
}
|
||||
|
||||
if (url.startsWith("/spring.json")) {
|
||||
@@ -126,8 +131,12 @@ public class JSONDruidStatService {
|
||||
List<Map<String, Object>> array = WebAppStatManager.getInstance().getURIStatData();
|
||||
return comparatorOrderBy(array, parameters);
|
||||
}
|
||||
|
||||
private Map<String, Object> getWebURIStatData(String uri) {
|
||||
return WebAppStatManager.getInstance().getURIStatData(uri);
|
||||
}
|
||||
|
||||
private Map<String, Object> getWebSessionDetail(String sessionId) {
|
||||
private Map<String, Object> getWebSessionStatData(String sessionId) {
|
||||
return WebAppStatManager.getInstance().getSessionStat(sessionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,17 @@ public class WebAppStat {
|
||||
}
|
||||
|
||||
public Map<String, Object> getSessionStatData(String sessionId) {
|
||||
WebSessionStat uriStat = sessionStatMap.get(sessionId);
|
||||
WebSessionStat sessionStat = sessionStatMap.get(sessionId);
|
||||
|
||||
if (sessionStat == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return sessionStat.getStatData();
|
||||
}
|
||||
|
||||
public Map<String, Object> getURIStatData(String uri) {
|
||||
WebURIStat uriStat = getURIStat(uri);
|
||||
|
||||
if (uriStat == null) {
|
||||
return null;
|
||||
|
||||
@@ -78,6 +78,19 @@ public class WebAppStatManager {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getURIStatData(String uri) {
|
||||
Set<Object> stats = getWebAppStatSet();
|
||||
|
||||
for (Object stat : stats) {
|
||||
Map<String, Object> statData = WebAppStatUtils.getURIStatData(stat, uri);
|
||||
if (statData != null) {
|
||||
return statData;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addWebAppStatSet(Object webAppStat) {
|
||||
getWebAppStatSet().add(webAppStat);
|
||||
|
||||
@@ -74,6 +74,22 @@ public class WebAppStatUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Object> getURIStatData(Object webStat, String uri) {
|
||||
if (webStat.getClass() == WebAppStat.class) {
|
||||
return ((WebAppStat) webStat).getURIStatData(uri);
|
||||
}
|
||||
|
||||
try {
|
||||
Method method = webStat.getClass().getMethod("getURIStatData", String.class);
|
||||
Object obj = method.invoke(webStat);
|
||||
return (Map<String, Object>) obj;
|
||||
} catch (Exception e) {
|
||||
LOG.error("getURIStatData error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void reset(Object webStat) {
|
||||
if (webStat.getClass() == WebAppStat.class) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
var xmlHttpForDataSourceSqlStatInfo;
|
||||
|
||||
var sqlViewOrderBy = '';
|
||||
@@ -75,8 +74,9 @@ function getSqlViewJsonUrl() {
|
||||
}
|
||||
|
||||
function ajaxRequestForDataSourceSqlStatInfo() {
|
||||
xmlHttpForDataSourceSqlStatInfo = getRequestObject();
|
||||
sendRequest(xmlHttpForDataSourceSqlStatInfo,getSqlViewJsonUrl(),ajaxResponseForDataSourceSqlStatInfo)
|
||||
xmlHttpForDataSourceSqlStatInfo = getRequestObject();
|
||||
sendRequest(xmlHttpForDataSourceSqlStatInfo, getSqlViewJsonUrl(),
|
||||
ajaxResponse)
|
||||
}
|
||||
|
||||
function subSqlString(sql, len) {
|
||||
@@ -84,28 +84,32 @@ function subSqlString(sql, len) {
|
||||
return sql;
|
||||
return sql.substr(0, len) + '...';
|
||||
}
|
||||
function ajaxResponseForDataSourceSqlStatInfo() {
|
||||
var sqlStatList = getJSONResponseContent(xmlHttpForDataSourceSqlStatInfo);
|
||||
if(sqlStatList==null) return;
|
||||
|
||||
|
||||
function ajaxResponse() {
|
||||
var statList = getJSONResponseContent(xmlHttpForDataSourceSqlStatInfo);
|
||||
if (statList == null)
|
||||
return;
|
||||
|
||||
var sqlStatTable = document.getElementById("WebUriStatTable");
|
||||
while (sqlStatTable.rows.length > 1) {
|
||||
sqlStatTable.deleteRow(1);
|
||||
}
|
||||
for ( var i = 0; i < sqlStatList.length; i++) {
|
||||
var sqlStat = sqlStatList[i];
|
||||
|
||||
for ( var i = 0; i < statList.length; i++) {
|
||||
var stat = statList[i];
|
||||
var newRow = sqlStatTable.insertRow(-1);
|
||||
newRow.insertCell(-1).innerHTML = i+1;
|
||||
newRow.insertCell(-1).innerHTML = subSqlString(sqlStat.URI, 64);
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.RequestCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.RequestTimeMillis;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.RunningCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ConcurrentMax;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcExecuteCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcExecuteTimeMillis;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcCommitCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcRollbackCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcFetchRowCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.JdbcUpdateCount;
|
||||
newRow.insertCell(-1).innerHTML = i + 1;
|
||||
newRow.insertCell(-1).innerHTML = '<a target="_blank" href="weburi-detail.html?uri='
|
||||
+ encodeURI(stat.URI) + '">' + subSqlString(stat.URI, 64) + '</a>';
|
||||
newRow.insertCell(-1).innerHTML = stat.RequestCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.RequestTimeMillis;
|
||||
newRow.insertCell(-1).innerHTML = stat.RunningCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.ConcurrentMax;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcExecuteCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcExecuteTimeMillis;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcCommitCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcRollbackCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcFetchRowCount;
|
||||
newRow.insertCell(-1).innerHTML = stat.JdbcUpdateCount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<title>Druid Web Session Stat</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<link href="css/style.css" type="text/css" rel="stylesheet"/>
|
||||
<script src="js/common.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="js/websession-detail.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="js/weburi-detail.js" type="text/javascript" charset="utf8"></script>
|
||||
<script >
|
||||
function init(){
|
||||
ajaxRequestForSqlInfo();
|
||||
@@ -16,7 +16,6 @@
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init();">
|
||||
<br/>
|
||||
<div id="main">
|
||||
<br/>
|
||||
<h2> Web Session View</h2>
|
||||
|
||||
Reference in New Issue
Block a user