提交 a13e9cc0 编写于 作者: J jialinsun

Merge branch 'master' of https://github.com/dianping/cat

......@@ -9,6 +9,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hsqldb.lib.StringUtil;
import com.dianping.cat.consumer.event.model.entity.EventName;
import com.dianping.cat.consumer.event.model.entity.EventType;
import com.dianping.cat.consumer.transaction.model.entity.TransactionName;
......@@ -37,8 +39,14 @@ public class CacheReport {
private Map<String, CacheTypeItem> m_typeItems = new HashMap<String, CacheTypeItem>();
public void addNewNameItem(TransactionName transactionName, EventName eventName) {
String key = transactionName.getId();
CacheNameItem item = m_nameItems.get(key);
String arrays[] = transactionName.getId().split(":");
String categroy = arrays[0];
String method = "";
if (arrays.length > 1) {
method = arrays[1];
}
CacheNameItem item = m_nameItems.get(categroy);
CacheNameItem all = m_nameItems.get(ALL);
if (all == null) {
......@@ -46,17 +54,14 @@ public class CacheReport {
all.setName(new TransactionName(ALL));
m_nameItems.put(ALL, all);
}
all.add(transactionName, eventName);
all.add(transactionName, eventName, method);
if (item == null) {
item = new CacheNameItem();
item.setName(transactionName);
item.setMissed(eventName.getTotalCount());
item.setHited(1 - (double) eventName.getTotalCount() / transactionName.getTotalCount());
m_nameItems.put(key, item);
} else {
throw new RuntimeException("duplicate transaction name in cache report!");
item.setName(new TransactionName(categroy));
m_nameItems.put(categroy, item);
}
item.add(transactionName, eventName, method);
}
public void addNewTypeItem(TransactionType transactionType, EventType eventType) {
......@@ -98,6 +103,16 @@ public class CacheReport {
return result;
}
public List<String> getAllMethods() {
CacheNameItem allItem = m_nameItems.get(ALL);
if (allItem != null) {
return new ArrayList<String>(allItem.getMethodCounts().keySet());
} else {
return new ArrayList<String>();
}
}
public java.util.Date getStartTime() {
return m_startTime;
}
......@@ -145,15 +160,35 @@ public class CacheReport {
private long m_missed;
private long m_getCount;
private TransactionName m_name;
public void add(TransactionName transactionName, EventName eventName) {
m_name.setTotalCount(m_name.getTotalCount() + transactionName.getTotalCount());
private String m_category;
private Map<String, Long> m_methodCounts = new HashMap<String, Long>();
public void add(TransactionName transactionName, EventName eventName, String method) {
long transactionTotalCount = transactionName.getTotalCount();
m_name.setTotalCount(m_name.getTotalCount() + transactionTotalCount);
m_name.setSum(m_name.getSum() + transactionName.getSum());
m_name.setAvg((double) m_name.getSum() / m_name.getTotalCount());
m_name.setTps(m_name.getTps() + transactionName.getTps());
m_missed = m_missed + eventName.getTotalCount();
m_hited = 1 - (double) m_missed / m_name.getTotalCount();
if (!StringUtil.isEmpty(method)) {
Long value = m_methodCounts.get(method);
if (value == null) {
value = 0L;
}
m_methodCounts.put(method, value + transactionTotalCount);
if ("get".equals(method)) {
m_missed = m_missed + eventName.getTotalCount();
m_getCount = m_getCount + transactionTotalCount;
m_hited = 1 - (double) m_missed / m_getCount;
}
}
}
public double getHited() {
......@@ -168,6 +203,24 @@ public class CacheReport {
return m_name;
}
public String getCategory() {
return m_category;
}
public Map<String, Long> getMethodCounts() {
return m_methodCounts;
}
public long getMethodCount(String method) {
Long count = m_methodCounts.get(method);
if (count == null) {
return 0L;
} else {
return count;
}
}
public void setHited(double hited) {
m_hited = hited;
}
......@@ -207,6 +260,9 @@ public class CacheReport {
return (int) (o2.getName().getAvg() * 1000 - o1.getName().getAvg() * 1000);
} else if (m_sort.equals("name")) {
return o1.getName().getId().compareTo(o2.getName().getId());
} else if (m_sort.startsWith("method:")) {
String method = m_sort.substring(7);
return (int) (o2.getMethodCount(method) - o1.getMethodCount(method));
}
return 0;
}
......
......@@ -4,6 +4,7 @@
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.cache.Context"
scope="request" />
......@@ -85,8 +86,9 @@
<div class="row-fluid">
<div class="span7">
<table class="data">
<c:set var="methods" value="${model.report.allMethods}"/>
<tr>
<th class="left" colspan='6'><input type="text"
<th class="left" colspan='${fn:length(methods) + 6}'><input type="text"
name="queryname" id="queryname" size="40"
value="${model.queryName}">
<input id="queryname" style="WIDTH: 60px"
......@@ -111,6 +113,10 @@
</th>
<th><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}">Total</a></th>
<c:forEach var="method" items="${methods}">
<th><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=method:${method}&queryname=${model.queryName}">${method}</a></th>
</c:forEach>
<th><a
href="?domain=${model.domain}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=missed&queryname=${model.queryName}">Missed</a></th>
<th><a
......@@ -127,6 +133,16 @@
<td
style="text-align: left; word-wrap: break-word; word-break: break-all;">${w:shorten(e.id, 80)}</td>
<td>${w:format(e.totalCount,'#,###,###,###,##0')}</td>
<c:forEach var="method" items="${methods}">
<c:choose>
<c:when test="${empty item.methodCounts[method]}">
<td>0</td>
</c:when>
<c:otherwise>
<td>${w:format(item.methodCounts[method],'#,###,###,###,##0')}</td>
</c:otherwise>
</c:choose>
</c:forEach>
<td>${item.missed}</td>
<td>${w:format(item.hited,'0.0000%')}</td>
<td>${w:format(e.avg,'0.0')}</td>
......
......@@ -4,6 +4,7 @@
<%@ taglib prefix="w" uri="http://www.unidal.org/web/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="res" uri="http://www.unidal.org/webres"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.cache.Context"
scope="request" />
......@@ -76,8 +77,9 @@
<div class="row-fluid">
<div class="span7">
<table>
<c:set var="methods" value="${model.report.allMethods}"/>
<tr>
<th class="left" colspan='6'><input type="text"
<th class="left" colspan='${fn:length(methods) + 6}'><input type="text"
name="queryname" id="queryname" size="40"
value="${model.queryName}">
<input id="queryname" style="WIDTH: 60px"
......@@ -105,6 +107,10 @@
</th>
<th><a
href="?op=history&domain=${model.domain}&reportType=${model.reportType}${model.customDate}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=total&queryname=${model.queryName}">Total</a></th>
<c:forEach var="method" items="${methods}">
<th><a
href="?op=history&domain=${model.domain}&reportType=${model.reportType}${model.customDate}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=method:${method}&queryname=${model.queryName}">${method}</a></th>
</c:forEach>
<th><a
href="?op=history&domain=${model.domain}&reportType=${model.reportType}${model.customDate}&date=${model.date}&ip=${model.ipAddress}&type=${payload.type}&sort=missed&queryname=${model.queryName}">Missed</a></th>
<th><a
......@@ -122,6 +128,16 @@
style="text-align: left; word-wrap: break-word; word-break: break-all;">
${w:shorten(e.id, 80)}</td>
<td>${w:format(e.totalCount,'#,###,###,###,##0')}</td>
<c:forEach var="method" items="${methods}">
<c:choose>
<c:when test="${empty item.methodCounts[method]}">
<td>0</td>
</c:when>
<c:otherwise>
<td>${w:format(item.methodCounts[method],'#,###,###,###,##0')}</td>
</c:otherwise>
</c:choose>
</c:forEach>
<td>${item.missed}</td>
<td>${w:format(item.hited,'0.0000%')}</td>
<td>${w:format(e.avg,'0.0')}</td>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册