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) {
|
||||
|
||||
Reference in New Issue
Block a user