mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
StatViewServlet: add activeConnectionStackTrace support, refactor js
This commit is contained in:
@@ -102,6 +102,16 @@ public class StatViewServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.startsWith("/activeConnectionStackTrace-")) {
|
||||
Integer id = StringUtils.subStringToInteger(path, "activeConnectionStackTrace-", ".");
|
||||
DruidDataSource datasource = getDruidDataSourceById(id);
|
||||
|
||||
if (path.endsWith(".json")) returnJSONActiveConnectionStackTrace(datasource, request, response);
|
||||
if (path.endsWith(".html")) returnViewActiveConnectionStackTrace(datasource, request, response);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.equals("/sql.json")) {
|
||||
returnJSONResult(request, response, RESULT_CODE_SUCCESS, getSqlStatDataList(request));
|
||||
return;
|
||||
@@ -127,6 +137,30 @@ public class StatViewServlet extends HttpServlet {
|
||||
returnResourceFile(path, response);
|
||||
}
|
||||
|
||||
private void returnJSONActiveConnectionStackTrace(DruidDataSource datasource, HttpServletRequest request,
|
||||
HttpServletResponse response) throws IOException {
|
||||
if (datasource.isRemoveAbandoned()) {
|
||||
List<String> result = datasource.getActiveConnectionStackTrace();
|
||||
returnJSONResult(request, response, RESULT_CODE_SUCCESS, result);
|
||||
} else {
|
||||
returnJSONResult(request, response, RESULT_CODE_ERROR, "require set removeAbandoned=true");
|
||||
}
|
||||
}
|
||||
|
||||
private void returnViewActiveConnectionStackTrace(DruidDataSource datasource, HttpServletRequest request,
|
||||
HttpServletResponse response) throws IOException {
|
||||
if (datasource == null) return;
|
||||
|
||||
if (!datasource.isRemoveAbandoned()) {
|
||||
response.getWriter().print(mergeTemplatePage("ERROR", "require set removeAbandoned=true"));
|
||||
return;
|
||||
}
|
||||
|
||||
String text = IOUtils.readFromResource(RESOURCE_PATH + "/activeConnectionStackTrace.html");
|
||||
text = text.replaceAll("\\{datasourceId\\}", String.valueOf(System.identityHashCode(datasource)));
|
||||
response.getWriter().print(text);
|
||||
}
|
||||
|
||||
private void returnViewSqlStat(JdbcSqlStat sqlStat, HttpServletResponse response) throws IOException {
|
||||
if (sqlStat == null) return;
|
||||
|
||||
@@ -343,6 +377,9 @@ public class StatViewServlet extends HttpServlet {
|
||||
|
||||
dataMap.put("StartTransactionCount", dataSource.getStartTransactionCount());
|
||||
dataMap.put("TransactionHistogramValues", dataSource.getTransactionHistogramValues());
|
||||
|
||||
dataMap.put("RemoveAbandoned", dataSource.isRemoveAbandoned());
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.druid.util;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.text.Collator;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -11,9 +12,9 @@ import java.util.Map;
|
||||
public class MapComparator<K extends Object, V extends Object> implements Comparator<Map<K, V>> {
|
||||
|
||||
private boolean isDesc;
|
||||
private String orderByKey;
|
||||
private K orderByKey;
|
||||
|
||||
public MapComparator(String orderByKey, boolean isDesc) {
|
||||
public MapComparator(K orderByKey, boolean isDesc) {
|
||||
this.orderByKey = orderByKey;
|
||||
this.isDesc = isDesc;
|
||||
}
|
||||
@@ -39,9 +40,24 @@ public class MapComparator<K extends Object, V extends Object> implements Compar
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object getValueByKey(Map<K, V> map, K key) {
|
||||
if (key instanceof String) {
|
||||
String keyStr = (String) key;
|
||||
if (keyStr.matches(".+\\[[0-9]+\\]")) {
|
||||
Object value = map.get(keyStr.substring(0, keyStr.indexOf("[")));
|
||||
Integer index = StringUtils.subStringToInteger(keyStr, "[", "]");
|
||||
if (value.getClass().isArray() && Array.getLength(value) >= index) {
|
||||
return Array.get(value, index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public int compare_0(Map<K, V> o1, Map<K, V> o2) {
|
||||
Object v1 = o1.get(orderByKey);
|
||||
Object v2 = o2.get(orderByKey);
|
||||
Object v1 = getValueByKey(o1, orderByKey);
|
||||
Object v2 = getValueByKey(o2, orderByKey);
|
||||
|
||||
if (v1 == null && v2 == null) return 0;
|
||||
if (v1 == null) return -1;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<!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>Druid ActiveConnection StackTrace</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="activeConnectionStackTrace.js" type="text/javascript" charset="utf8"></script>
|
||||
<script >
|
||||
function init(){
|
||||
ajaxRequestForActiveConnectionStackTrace({datasourceId});
|
||||
var time2=setInterval("ajaxRequestForActiveConnectionStackTrace({datasourceId});",2000);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<br />
|
||||
<div id="menu" >
|
||||
<a href="index.html">Index</a> | <a href="datasource.html">DataSource</a> | <a href="sql.html">Sql</a> | <a href="#" onclick="ajaxRequestForReset()">Reset All</a> | <a href="api.html">JSON API</a>
|
||||
</div>
|
||||
<br />
|
||||
<div id="main">
|
||||
<h2>ActiveConnection StackTrace <a href="activeConnectionStackTrace-{datasourceId}.json" target="_blank">[View JSON API]</a></h2>
|
||||
<div id="activeConnectionStackTraceDiv">
|
||||
<table id="activeConnectionStackTraceTable" cellpadding="5" cellspacing="1" width="99%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
function ajaxRequestForActiveConnectionStackTrace(datasourceId) {
|
||||
var xmlHttpForActiveConnectionStackTrace=getRequestObject();
|
||||
sendRequest(xmlHttpForActiveConnectionStackTrace,'activeConnectionStackTrace-' + datasourceId + '.json', function() {
|
||||
ajaxResponseForActiveConnectionStackTrace(xmlHttpForActiveConnectionStackTrace, datasourceId);
|
||||
});
|
||||
}
|
||||
|
||||
function ajaxResponseForActiveConnectionStackTrace(xmlHttpForActiveConnectionStackTrace, datasourceId) {
|
||||
var conntionStackTraceList = getJSONResponseContent(xmlHttpForActiveConnectionStackTrace);
|
||||
if (conntionStackTraceList == null)
|
||||
return;
|
||||
|
||||
var activeConnectionStackTraceTable = document.getElementById("activeConnectionStackTraceTable");
|
||||
while (activeConnectionStackTraceTable.rows.length > 0) {
|
||||
activeConnectionStackTraceTable.deleteRow(0);
|
||||
}
|
||||
for ( var i = 0; i < conntionStackTraceList.length; i++) {
|
||||
var conntionStackTrace = conntionStackTraceList[i];
|
||||
var newRow = activeConnectionStackTraceTable.insertRow(-1);
|
||||
newRow.insertCell(-1).innerHTML = conntionStackTrace;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>Druid Stat JSON API</title>
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<script src="js.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
</head>
|
||||
<body>
|
||||
@@ -43,17 +43,27 @@
|
||||
DatasourceStat for id={id},id is DatsSourceStat.ID<br />
|
||||
Example: druid/datasource-1.json
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
activeConnectionStackTrace-{datasourceId}.json
|
||||
</td>
|
||||
<td>
|
||||
StrackTrace for activeConnection in datasource which datasource.id={datasourceId},id is DatsSourceStat.ID<br />
|
||||
Required: set removeAbandoned=true<br />
|
||||
Example: druid/activeConnectionStackTrace-1.json
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="sql.json" target="_blank">sql.json</a>
|
||||
</td>
|
||||
<td>
|
||||
<p>SqlStat info List.</p>
|
||||
<p>orderBy=[ID|ExecuteCount|...|](every property without histogram in sqlstat object)</p>
|
||||
<p>orderType=[asc|desc] default is desc</p>
|
||||
<p>page=page count start with 1</p>
|
||||
<p>perPageCount=item count in one page,default is IN</p>
|
||||
SqlStat info List.<br />
|
||||
orderBy=[ID|ExecuteCount|...|](every property without histogram in sqlstat object)<br />
|
||||
orderType=[asc|desc] default is desc<br />
|
||||
page=page count start with 1<br />
|
||||
perPageCount=item count in one page,default is INTEGER.MAX_VALUE
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -75,5 +85,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
var xmlHttpForBasicInfo;
|
||||
|
||||
function ajaxRequestForBasicInfo() {
|
||||
xmlHttpForBasicInfo = getRequestObject();
|
||||
sendRequest(xmlHttpForBasicInfo,'basic.json',ajaxResponseForBasicInfo);
|
||||
}
|
||||
|
||||
function ajaxResponseForBasicInfo() {
|
||||
var jsonContent = getJSONResponseContent(xmlHttpForBasicInfo);
|
||||
if(jsonContent==null) return;
|
||||
|
||||
document.getElementById("DruidVersion").innerHTML = jsonContent.Version;
|
||||
|
||||
var driversList = jsonContent.Drivers;
|
||||
if (driversList) {
|
||||
var driverHtml = '';
|
||||
for ( var i = 0; i < driversList.length; i++) {
|
||||
var driver = driversList[i];
|
||||
driverHtml += driver + ' , ';
|
||||
}
|
||||
document.getElementById("DruidDrivers").innerHTML = driverHtml;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
function changeInnerHtml(id, divHtml) {
|
||||
var divObj = document.getElementById(id);
|
||||
if (divHtml == undefined)
|
||||
divHtml = '';
|
||||
if (divObj) {
|
||||
divObj.innerHTML = divHtml;
|
||||
}
|
||||
}
|
||||
|
||||
function checkResoponse(xmlHttpForRequest){
|
||||
if (xmlHttpForRequest.readyState != 4) {
|
||||
return false;
|
||||
}
|
||||
if (xmlHttpForRequest.status != 200) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getJSONResponseContent(xmlHttpForRequest){
|
||||
if(checkResoponse(xmlHttpForRequest)){
|
||||
var jsonResp = eval("(" + xmlHttpForRequest.responseText + ")");
|
||||
if (jsonResp.ResultCode == 1) {
|
||||
return jsonResp.Content;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function sendRequest(requestObject,url,callBack){
|
||||
requestObject.onreadystatechange = callBack;
|
||||
requestObject.open("GET", url, true);
|
||||
requestObject.send(null);
|
||||
}
|
||||
|
||||
function getRequestObject(){
|
||||
var requestObject;
|
||||
if (window.XMLHttpRequest)
|
||||
requestObject = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
requestObject = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
return requestObject;
|
||||
}
|
||||
|
||||
|
||||
function ajaxRequestForReset() {
|
||||
xmlHttpForReset = getRequestObject();
|
||||
sendRequest(xmlHttpForReset,'reset-all.json',ajaxResponseForReset)
|
||||
}
|
||||
|
||||
function ajaxResponseForReset() {
|
||||
if (!checkResoponse(xmlHttpForReset)) {
|
||||
return;
|
||||
}
|
||||
var jsonResp = eval("(" + xmlHttpForReset.responseText + ")");
|
||||
if (jsonResp.ResultCode == 1) {
|
||||
alert("already reset all stat");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
<title>Druid DataSourceStat</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<script src="js.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="datasource.js" type="text/javascript" charset="utf8"></script>
|
||||
<script >
|
||||
function init(){
|
||||
ajaxRequestForDataSourceInfo();
|
||||
@@ -23,5 +24,6 @@
|
||||
<div id="dataSourceStatList">
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
</body>
|
||||
</html>
|
||||
+14
-187
@@ -1,129 +1,10 @@
|
||||
var xmlHttpForBasicInfo;
|
||||
var xmlHttpForDataSourceInfo;
|
||||
var xmlHttpForDataSourceSqlStatInfo;
|
||||
var xmlHttpForReset;
|
||||
|
||||
var sqlViewOrderBy = 'ID';
|
||||
var sqlViewOrderType = 'asc';
|
||||
|
||||
// only one page for now
|
||||
var sqlViewPage = 1;
|
||||
var sqlViewPerPageCount = 1000000;
|
||||
|
||||
function setOrderBy(orderBy) {
|
||||
if (sqlViewOrderBy != orderBy) {
|
||||
sqlViewOrderBy = orderBy;
|
||||
sqlViewOrderType = 'desc'
|
||||
return;
|
||||
}
|
||||
|
||||
if (sqlViewOrderType == 'asc')
|
||||
sqlViewOrderType = 'desc'
|
||||
else
|
||||
sqlViewOrderType = 'asc'
|
||||
}
|
||||
|
||||
function getSqlViewJsonUrl() {
|
||||
var result = 'sql.json?';
|
||||
|
||||
if (sqlViewOrderBy != undefined)
|
||||
result += 'orderBy=' + sqlViewOrderBy + '&';
|
||||
|
||||
if (sqlViewOrderType != undefined)
|
||||
result += 'orderType=' + sqlViewOrderType + '&';
|
||||
|
||||
if (sqlViewPage != undefined)
|
||||
result += 'page=' + sqlViewPage + '&';
|
||||
|
||||
if (sqlViewPerPageCount != undefined)
|
||||
result += 'perPageCount=' + sqlViewPerPageCount + '&';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function ajaxRequestForReset() {
|
||||
if (window.XMLHttpRequest)
|
||||
xmlHttpForReset = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlHttpForReset = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlHttpForReset.onreadystatechange = ajaxResponseForReset;
|
||||
xmlHttpForReset.open("GET", 'reset-all.json', true);
|
||||
xmlHttpForReset.send(null);
|
||||
return false;
|
||||
}
|
||||
function ajaxRequestForBasicInfo() {
|
||||
if (window.XMLHttpRequest)
|
||||
xmlHttpForBasicInfo = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlHttpForBasicInfo = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlHttpForBasicInfo.onreadystatechange = ajaxResponseForBasicInfo;
|
||||
xmlHttpForBasicInfo.open("GET", 'basic.json', true);
|
||||
xmlHttpForBasicInfo.send(null);
|
||||
}
|
||||
function ajaxRequestForDataSourceSqlStatInfo() {
|
||||
if (window.XMLHttpRequest)
|
||||
xmlHttpForDataSourceSqlStatInfo = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlHttpForDataSourceSqlStatInfo = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlHttpForDataSourceSqlStatInfo.onreadystatechange = ajaxResponseForDataSourceSqlStatInfo;
|
||||
xmlHttpForDataSourceSqlStatInfo.open("GET", getSqlViewJsonUrl(), true);
|
||||
xmlHttpForDataSourceSqlStatInfo.send(null);
|
||||
}
|
||||
function ajaxRequestForDataSourceInfo() {
|
||||
if (window.XMLHttpRequest)
|
||||
xmlHttpForDataSourceInfo = new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlHttpForDataSourceInfo = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlHttpForDataSourceInfo.onreadystatechange = ajaxResponseForDataSourceInfo;
|
||||
xmlHttpForDataSourceInfo.open("GET", 'datasource.json', true);
|
||||
xmlHttpForDataSourceInfo.send(null);
|
||||
xmlHttpForDataSourceInfo = getRequestObject();
|
||||
sendRequest(xmlHttpForDataSourceInfo,'datasource.json',ajaxResponseForDataSourceInfo)
|
||||
}
|
||||
function ajaxResponseForReset() {
|
||||
var html = '';
|
||||
if (xmlHttpForReset.readyState != 4) {
|
||||
return;
|
||||
}
|
||||
if (xmlHttpForReset.status != 200) {
|
||||
return;
|
||||
}
|
||||
var jsonResp = eval("(" + xmlHttpForReset.responseText + ")");
|
||||
if (jsonResp.ResultCode == 1) {
|
||||
alert("already reset all stat");
|
||||
}
|
||||
|
||||
}
|
||||
function ajaxResponseForBasicInfo() {
|
||||
if (xmlHttpForBasicInfo.readyState != 4) {
|
||||
return;
|
||||
}
|
||||
if (xmlHttpForBasicInfo.status != 200) {
|
||||
return;
|
||||
}
|
||||
var jsonResp = eval("(" + xmlHttpForBasicInfo.responseText + ")");
|
||||
if (jsonResp.ResultCode != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("DruidVersion").innerHTML = jsonResp.Content.Version;
|
||||
|
||||
var driversList = jsonResp.Content.Drivers;
|
||||
if (driversList) {
|
||||
var driverHtml = '';
|
||||
for ( var i = 0; i < driversList.length; i++) {
|
||||
var driver = driversList[i];
|
||||
driverHtml += driver + ' , ';
|
||||
}
|
||||
document.getElementById("DruidDrivers").innerHTML = driverHtml;
|
||||
}
|
||||
}
|
||||
function changeInnerHtml(id, divHtml) {
|
||||
var divObj = document.getElementById(id);
|
||||
if (divHtml == undefined)
|
||||
divHtml = '';
|
||||
if (divObj) {
|
||||
divObj.innerHTML = divHtml;
|
||||
}
|
||||
}
|
||||
function fillDataSourceInfo(datasource) {
|
||||
changeInnerHtml("DS-Info-Title" + datasource.Identity, datasource.Name);
|
||||
changeInnerHtml("DS-Info-UserName" + datasource.Identity, datasource.UserName);
|
||||
@@ -165,6 +46,13 @@ function fillDataSourceInfo(datasource) {
|
||||
changeInnerHtml("DS-Info-PSCacheAccessCount" + datasource.Identity, datasource.PSCacheAccessCount);
|
||||
changeInnerHtml("DS-Info-PSCacheHitCount" + datasource.Identity, datasource.PSCacheHitCount);
|
||||
changeInnerHtml("DS-Info-PSCacheMissCount" + datasource.Identity, datasource.PSCacheMissCount);
|
||||
changeInnerHtml("DS-Info-PSCacheMissCount" + datasource.Identity, datasource.PSCacheMissCount);
|
||||
|
||||
if (datasource.RemoveAbandoned == true)
|
||||
changeInnerHtml("DS-Info-ActiveConnectionStackTrace" + datasource.Identity, '<a href="activeConnectionStackTrace-' + datasource.Identity + '.html">View</a>');
|
||||
else
|
||||
changeInnerHtml("DS-Info-ActiveConnectionStackTrace" + datasource.Identity, "require set removeAbandoned=true");
|
||||
|
||||
}
|
||||
function generateDataSourceDiv(datasource) {
|
||||
var listHtml = '';
|
||||
@@ -212,23 +100,17 @@ function generateDataSourceDiv(datasource) {
|
||||
listHtml += '<tr><td class="td_lable">PSCacheAccessCount</td><td id="DS-Info-PSCacheAccessCount' + datasourceId + '"> </td><td>PerpareStatement access count</td></tr>';
|
||||
listHtml += '<tr><td class="td_lable">PSCacheHitCount</td><td id="DS-Info-PSCacheHitCount' + datasourceId + '"> </td><td>PerpareStatement hit count</td></tr>';
|
||||
listHtml += '<tr><td class="td_lable">PSCacheMissCount</td><td id="DS-Info-PSCacheMissCount' + datasourceId + '"> </td><td>PerpareStatement miss count</td></tr>';
|
||||
listHtml += '<tr><td class="td_lable">ActiveConnection StackTrace</td><td id="DS-Info-ActiveConnectionStackTrace' + datasourceId + '"> </td><td>StackTrace for active Connection. <a href="activeConnectionStackTrace-'
|
||||
+ datasourceId + '.json" target="_blank">[View JSON API]</a></td></tr>';
|
||||
listHtml += '</table>';
|
||||
listHtml += '</div>';
|
||||
|
||||
document.getElementById("dataSourceStatList").innerHTML += listHtml;
|
||||
}
|
||||
function ajaxResponseForDataSourceInfo() {
|
||||
if (xmlHttpForDataSourceInfo.readyState != 4) {
|
||||
return;
|
||||
}
|
||||
if (xmlHttpForDataSourceInfo.status != 200) {
|
||||
return;
|
||||
}
|
||||
var jsonResp = eval("(" + xmlHttpForDataSourceInfo.responseText + ")");
|
||||
if (jsonResp.ResultCode != 1) {
|
||||
return;
|
||||
}
|
||||
var datasourceList = jsonResp.Content;
|
||||
var datasourceList = getJSONResponseContent(xmlHttpForDataSourceInfo);
|
||||
if(datasourceList==null) return;
|
||||
|
||||
for ( var i = 0; i < datasourceList.length; i++) {
|
||||
var datasource = datasourceList[i];
|
||||
if (document.getElementById("dataSourceStat" + datasource.Identity)) {
|
||||
@@ -239,58 +121,3 @@ function ajaxResponseForDataSourceInfo() {
|
||||
fillDataSourceInfo(datasource);
|
||||
}
|
||||
}
|
||||
function subSqlString(sql, len) {
|
||||
if (sql.length <= len)
|
||||
return sql;
|
||||
return sql.substr(0, len) + '...';
|
||||
}
|
||||
function ajaxResponseForDataSourceSqlStatInfo() {
|
||||
if (xmlHttpForDataSourceSqlStatInfo.readyState != 4) {
|
||||
return;
|
||||
}
|
||||
if (xmlHttpForDataSourceSqlStatInfo.status != 200) {
|
||||
return;
|
||||
}
|
||||
var jsonResp = eval("(" + xmlHttpForDataSourceSqlStatInfo.responseText + ")");
|
||||
if (jsonResp.ResultCode != 1) {
|
||||
return;
|
||||
}
|
||||
var sqlStatList = jsonResp.Content;
|
||||
var sqlStatTable = document.getElementById("SqlStatTable");
|
||||
while (sqlStatTable.rows.length > 1) {
|
||||
sqlStatTable.deleteRow(1);
|
||||
}
|
||||
for ( var i = 0; i < sqlStatList.length; i++) {
|
||||
var sqlStat = sqlStatList[i];
|
||||
var newRow = sqlStatTable.insertRow(-1);
|
||||
newRow.insertCell(-1).innerHTML = '<a target="_blank" href="sql-' + sqlStat.ID + '.html">' + subSqlString(sqlStat.SQL, 25) + '</a>';
|
||||
// if (sqlStat.File)
|
||||
// newRow.insertCell(-1).innerHTML = sqlStat.File;
|
||||
// else
|
||||
// newRow.insertCell(-1).innerHTML = '';
|
||||
// if (sqlStat.Name)
|
||||
// newRow.insertCell(-1).innerHTML = sqlStat.Name;
|
||||
// else
|
||||
// newRow.insertCell(-1).innerHTML = '';
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ExecuteCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.TotalTime;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.MaxTimespan;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.InTransactionCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ErrorCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.EffectedRowCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.FetchRowCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.RunningCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ConcurrentMax;
|
||||
// hiHtml += '<a href="#' + sqlStat.Histogram + '">ExecHistogram</a> |';
|
||||
// hiHtml += '<a href="#' + sqlStat.FetchRowCountHistogram +
|
||||
// '">FetchRow</a> | ';
|
||||
// hiHtml += '<a href="#' + sqlStat.EffectedRowCountHistogram +
|
||||
// '">UpdateCount</a> | ';
|
||||
// hiHtml += '<a href="#' + sqlStat.ExecuteAndResultHoldTimeHistogram +
|
||||
// '">ExecAndRsHold</a>';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.Histogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.FetchRowCountHistogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.EffectedRowCountHistogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.ExecuteAndResultHoldTimeHistogram + ']';
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
<title>Druid Stat Index</title>
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<script src="js.js" type="text/javascript"></script>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="basicStat.js" type="text/javascript"></script>
|
||||
<script >
|
||||
function init(){
|
||||
ajaxRequestForBasicInfo();
|
||||
@@ -38,5 +39,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,7 +3,8 @@
|
||||
<head>
|
||||
<title>Druid SqlStat</title>
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<script src="js.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
<script src="sql.js" type="text/javascript" charset="utf8"></script>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<script >
|
||||
function init(){
|
||||
@@ -22,22 +23,59 @@
|
||||
<h2>SqlStat List<a href="sql.json" target="_blank">[View JSON API]</a></h2>
|
||||
<table cellspacing="1" cellpadding="5" id="SqlStatTable" width="99%">
|
||||
<thead>
|
||||
<th class="td_lable" ><a href="#" onclick="setOrderBy('SQL');return false;">SQL</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('ExecuteCount');return false;">Execute Count</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('TotalTime');return false;">Execute Millis Total</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('MaxTimespan');return false;">Execute Millis Max</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('InTransactionCount');return false;">InTxn Count</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('ErrorCount');return false;">Error Count</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('EffectedRowCount');return false;">Effected Row Count</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('FetchRowCount');return false;">Fetch Row Count</a></th>
|
||||
<th class="td_lable" width="50"><a href="return false;" onclick="setOrderBy('RunningCount');return false;">Running Count</a></th>
|
||||
<th class="td_lable" width="80"><a href="return false;" onclick="setOrderBy('ConcurrentMax');return false;">Concurrent Max</a></th>
|
||||
<th class="td_lable" width="100">ExecHistogram</th>
|
||||
<th class="td_lable" width="100">FetchRow</th>
|
||||
<th class="td_lable" width="100">UpdateCount</th>
|
||||
<th class="td_lable" width="100">ExecAndRsHold</th>
|
||||
<tr>
|
||||
<th class="td_lable"><a id="th-SQL" href="javascript:void(0)" onclick="setOrderBy('SQL');">SQL</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-ExecuteCount" href="javascript:void(0)" onclick="setOrderBy('ExecuteCount');">Execute Count</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-TotalTime" href="javascript:void(0)" onclick="setOrderBy('TotalTime');">Execute Millis Total</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-MaxTimespan" href="javascript:void(0)" onclick="setOrderBy('MaxTimespan');">Execute Millis Max</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-InTransactionCount" href="javascript:void(0)" onclick="setOrderBy('InTransactionCount');">InTxn Count</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-ErrorCount" href="javascript:void(0)" onclick="setOrderBy('ErrorCount');">Error Count</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-EffectedRowCount" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCount');">Effected Row Count</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-FetchRowCount" href="javascript:void(0)" onclick="setOrderBy('FetchRowCount');">Fetch Row Count</a></th>
|
||||
<th class="td_lable" width="50"><a id="th-RunningCount" href="javascript:void(0)" onclick="setOrderBy('RunningCount');">Running Count</a></th>
|
||||
<th class="td_lable" width="80"><a id="th-ConcurrentMax" href="javascript:void(0)" onclick="setOrderBy('ConcurrentMax');">Concurrent Max</a></th>
|
||||
<th id="th-Histogram" class="td_lable" width="100">ExecHistogram <br />[
|
||||
<a id="th-Histogram[0]" href="javascript:void(0)" onclick="setOrderBy('Histogram[0]');">-</a>
|
||||
<a id="th-Histogram[1]" href="javascript:void(0)" onclick="setOrderBy('Histogram[1]');">-</a>
|
||||
<a id="th-Histogram[2]" href="javascript:void(0)" onclick="setOrderBy('Histogram[2]');">-</a>
|
||||
<a id="th-Histogram[3]" href="javascript:void(0)" onclick="setOrderBy('Histogram[3]');">-</a>
|
||||
<a id="th-Histogram[4]" href="javascript:void(0)" onclick="setOrderBy('Histogram[4]');">-</a>
|
||||
<a id="th-Histogram[5]" href="javascript:void(0)" onclick="setOrderBy('Histogram[5]');">-</a>
|
||||
<a id="th-Histogram[6]" href="javascript:void(0)" onclick="setOrderBy('Histogram[6]');">-</a>
|
||||
<a id="th-Histogram[7]" href="javascript:void(0)" onclick="setOrderBy('Histogram[7]');">-</a> ]
|
||||
</th>
|
||||
<th id="th-FetchRowCountHistogram" class="td_lable" width="100">FetchRow <br />[
|
||||
<a id="th-FetchRowCountHistogram[0]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[0]');">-</a>
|
||||
<a id="th-FetchRowCountHistogram[1]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[1]');">-</a>
|
||||
<a id="th-FetchRowCountHistogram[2]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[2]');">-</a>
|
||||
<a id="th-FetchRowCountHistogram[3]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[3]');">-</a>
|
||||
<a id="th-FetchRowCountHistogram[4]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[4]');">-</a>
|
||||
<a id="th-FetchRowCountHistogram[5]" href="javascript:void(0)" onclick="setOrderBy('FetchRowCountHistogram[5]');">-</a> ]
|
||||
</th>
|
||||
<th id="th-EffectedRowCountHistogram" class="td_lable" width="100">UpdateCount <br />[
|
||||
<a id="th-EffectedRowCountHistogram[0]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[0]');">-</a>
|
||||
<a id="th-EffectedRowCountHistogram[1]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[1]');">-</a>
|
||||
<a id="th-EffectedRowCountHistogram[2]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[2]');">-</a>
|
||||
<a id="th-EffectedRowCountHistogram[3]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[3]');">-</a>
|
||||
<a id="th-EffectedRowCountHistogram[4]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[4]');">-</a>
|
||||
<a id="th-EffectedRowCountHistogram[5]" href="javascript:void(0)" onclick="setOrderBy('EffectedRowCountHistogram[5]');">-</a> ]
|
||||
</th>
|
||||
<th id="th-ExecuteAndResultHoldTimeHistogram" class="td_lable" width="100">ExecAndRsHold <br />[
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[0]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[0]');">-</a>
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[1]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[1]');">-</a>
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[2]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[2]');">-</a>
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[3]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[3]');">-</a>
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[4]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[4]');">-</a>
|
||||
<a id="th-ExecuteAndResultHoldTimeHistogram[5]" href="javascript:void(0)" onclick="setOrderBy('ExecuteAndResultHoldTimeHistogram[5]');">-</a> ]
|
||||
]
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
<script >
|
||||
setOrderBy('SQL');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,127 @@
|
||||
|
||||
var xmlHttpForDataSourceSqlStatInfo;
|
||||
|
||||
var sqlViewOrderBy = '';
|
||||
var sqlViewOrderBy_old = '';
|
||||
var sqlViewOrderType = 'asc';
|
||||
|
||||
// only one page for now
|
||||
var sqlViewPage = 1;
|
||||
var sqlViewPerPageCount = 1000000;
|
||||
|
||||
function resetSortMark() {
|
||||
var divObj = document.getElementById('th-' + sqlViewOrderBy);
|
||||
var old_divObj = document.getElementById('th-' + sqlViewOrderBy_old);
|
||||
var replaceToStr = '';
|
||||
if (old_divObj) {
|
||||
var html = old_divObj.innerHTML;
|
||||
if (sqlViewOrderBy_old.indexOf('[') > 0)
|
||||
replaceToStr = '-';
|
||||
html = html.replace('↑', replaceToStr);
|
||||
html = html.replace('↓', replaceToStr);
|
||||
old_divObj.innerHTML = html
|
||||
}
|
||||
if (divObj) {
|
||||
var html = divObj.innerHTML;
|
||||
if (sqlViewOrderBy.indexOf('[') > 0)
|
||||
html = '';
|
||||
|
||||
if (sqlViewOrderType == 'asc') {
|
||||
html += '↑';
|
||||
} else if (sqlViewOrderType == 'desc') {
|
||||
html += '↓';
|
||||
}
|
||||
divObj.innerHTML = html;
|
||||
}
|
||||
}
|
||||
|
||||
function setOrderBy(orderBy) {
|
||||
if (sqlViewOrderBy != orderBy) {
|
||||
sqlViewOrderBy_old = sqlViewOrderBy;
|
||||
sqlViewOrderBy = orderBy;
|
||||
sqlViewOrderType = 'desc';
|
||||
resetSortMark();
|
||||
return;
|
||||
}
|
||||
|
||||
sqlViewOrderBy_old = sqlViewOrderBy;
|
||||
|
||||
if (sqlViewOrderType == 'asc')
|
||||
sqlViewOrderType = 'desc'
|
||||
else
|
||||
sqlViewOrderType = 'asc';
|
||||
|
||||
resetSortMark();
|
||||
|
||||
}
|
||||
|
||||
function getSqlViewJsonUrl() {
|
||||
var result = 'sql.json?';
|
||||
|
||||
if (sqlViewOrderBy != undefined)
|
||||
result += 'orderBy=' + sqlViewOrderBy + '&';
|
||||
|
||||
if (sqlViewOrderType != undefined)
|
||||
result += 'orderType=' + sqlViewOrderType + '&';
|
||||
|
||||
if (sqlViewPage != undefined)
|
||||
result += 'page=' + sqlViewPage + '&';
|
||||
|
||||
if (sqlViewPerPageCount != undefined)
|
||||
result += 'perPageCount=' + sqlViewPerPageCount + '&';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function ajaxRequestForDataSourceSqlStatInfo() {
|
||||
xmlHttpForDataSourceSqlStatInfo = getRequestObject();
|
||||
sendRequest(xmlHttpForDataSourceSqlStatInfo,getSqlViewJsonUrl(),ajaxResponseForDataSourceSqlStatInfo)
|
||||
}
|
||||
|
||||
function subSqlString(sql, len) {
|
||||
if (sql.length <= len)
|
||||
return sql;
|
||||
return sql.substr(0, len) + '...';
|
||||
}
|
||||
function ajaxResponseForDataSourceSqlStatInfo() {
|
||||
var sqlStatList = getJSONResponseContent(xmlHttpForDataSourceSqlStatInfo);
|
||||
if(sqlStatList==null) return;
|
||||
|
||||
var sqlStatTable = document.getElementById("SqlStatTable");
|
||||
while (sqlStatTable.rows.length > 1) {
|
||||
sqlStatTable.deleteRow(1);
|
||||
}
|
||||
for ( var i = 0; i < sqlStatList.length; i++) {
|
||||
var sqlStat = sqlStatList[i];
|
||||
var newRow = sqlStatTable.insertRow(-1);
|
||||
newRow.insertCell(-1).innerHTML = '<a target="_blank" href="sql-' + sqlStat.ID + '.html">' + subSqlString(sqlStat.SQL, 25) + '</a>';
|
||||
// if (sqlStat.File)
|
||||
// newRow.insertCell(-1).innerHTML = sqlStat.File;
|
||||
// else
|
||||
// newRow.insertCell(-1).innerHTML = '';
|
||||
// if (sqlStat.Name)
|
||||
// newRow.insertCell(-1).innerHTML = sqlStat.Name;
|
||||
// else
|
||||
// newRow.insertCell(-1).innerHTML = '';
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ExecuteCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.TotalTime;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.MaxTimespan;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.InTransactionCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ErrorCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.EffectedRowCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.FetchRowCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.RunningCount;
|
||||
newRow.insertCell(-1).innerHTML = sqlStat.ConcurrentMax;
|
||||
// hiHtml += '<a href="#' + sqlStat.Histogram + '">ExecHistogram</a> |';
|
||||
// hiHtml += '<a href="#' + sqlStat.FetchRowCountHistogram +
|
||||
// '">FetchRow</a> | ';
|
||||
// hiHtml += '<a href="#' + sqlStat.EffectedRowCountHistogram +
|
||||
// '">UpdateCount</a> | ';
|
||||
// hiHtml += '<a href="#' + sqlStat.ExecuteAndResultHoldTimeHistogram +
|
||||
// '">ExecAndRsHold</a>';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.Histogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.FetchRowCountHistogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.EffectedRowCountHistogram + ']';
|
||||
newRow.insertCell(-1).innerHTML = '[' + sqlStat.ExecuteAndResultHoldTimeHistogram + ']';
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,19 @@ body{
|
||||
height:50px;
|
||||
}
|
||||
|
||||
#menu a{
|
||||
#menu a{
|
||||
color: #0082FF;
|
||||
font: 18px 'Microsoft YaHei','Microsoft JhengHei',STHeiti,Georgia,'Times New Roman',Times,serif;
|
||||
}
|
||||
}
|
||||
#footer {
|
||||
height: 50px;
|
||||
border-top: 1px solid #A8C7CE;
|
||||
margin-top: 20px;
|
||||
width: 99%;
|
||||
text-align: center;
|
||||
line-height: 26px;
|
||||
padding-top: 15px;
|
||||
}
|
||||
tr{
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<title>{title}</title>
|
||||
<link href="style.css" type="text/css" rel="stylesheet"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||
<script src="js.js" type="text/javascript"></script>
|
||||
<script src="common.js" type="text/javascript" charset="utf8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
@@ -15,5 +15,6 @@
|
||||
<div id="main">
|
||||
{content}
|
||||
</div>
|
||||
<div id="footer">powered by <a href="mailto:sandzhangtoo@gmail.com">sandzhang</a></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user