提交 60ffb8c7 编写于 作者: Y You Yong

modify some small bug

上级 9b08ac4b
......@@ -87,7 +87,7 @@ public class IpAnalyzer extends AbstractMessageAnalyzer<IpReport> implements Log
for (Message child : children) {
if (child instanceof Event && child.getType().equals("URL") && child.getName().equals("ClientInfo")) {
// URL:ClientInfo RemoteIp=<ip>&...
// URL:ClientInfo RemoteIP=<ip>&...
String data = child.getData().toString();
int off = data.indexOf(TOKEN);
......@@ -97,6 +97,11 @@ public class IpAnalyzer extends AbstractMessageAnalyzer<IpReport> implements Log
if (pos > 0) {
return data.substring(off + TOKEN.length(), pos);
}
} else {
//TODO remove it after mobileApi upgrade
off = data.indexOf("RemoteIp=");
int pos = data.indexOf("VirtualIP=");
return data.substring(off + "RemoteIp=".length(), pos);
}
break;
......
......@@ -87,7 +87,7 @@ public class CatFilter implements Filter {
ip = ips[ips.length - 1].trim();
}
sb.append("RemoteIp=").append(ip);
sb.append("RemoteIP=").append(ip);
sb.append("&VirtualIP=").append(req.getRemoteAddr());
sb.append("&Server=").append(req.getServerName());
sb.append("&Referer=").append(req.getHeader("referer"));
......
package com.dianping.cat.helper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class MapUtils {
public static <K, V> Map<K, V> sortMap(Map<K, V> map, Comparator<Entry<K, V>> compator) {
Map<K, V> result = new LinkedHashMap<K, V>();
List<Entry<K, V>> entries = new ArrayList<Entry<K, V>>(map.entrySet());
Collections.sort(entries,compator);
for(Entry<K,V> entry:entries){
result.put(entry.getKey(), entry.getValue());
}
return result;
}
// public <T,S> List<String> sort(T model, String xpath, Comparator<S> comparator) {
// TransactionReport report = null;
// List<String> keys = sort(report, "/transaction-report/type[@name='URL']/name", new Comparator<TransactionName>() {
// @Override
// public int compare(TransactionName n1, TransactionName n2) {
// return 0;
// }
// });
//
// return null;
// }
}
......@@ -124,8 +124,12 @@ public class Handler implements PageHandler<Context> {
return m2.getLastFifteen() - m1.getLastFifteen(); // desc order
}
});
return displayModels;
if (displayModels.size() > 100) {
return displayModels.subList(0, 100);
} else {
return displayModels;
}
}
static class DisplayModelBuilder extends BaseVisitor {
......
package com.dianping.cat.report.page.problem;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -11,6 +12,7 @@ import com.dianping.cat.consumer.problem.model.entity.JavaThread;
import com.dianping.cat.consumer.problem.model.entity.Machine;
import com.dianping.cat.consumer.problem.model.entity.ProblemReport;
import com.dianping.cat.consumer.problem.model.entity.Segment;
import com.dianping.cat.helper.MapUtils;
public class ProblemStatistics {
......@@ -186,7 +188,14 @@ public class ProblemStatistics {
}
public Map<String, StatusStatistics> getStatus() {
return m_status;
Map<String,StatusStatistics> result = MapUtils.sortMap(m_status, new Comparator<java.util.Map.Entry<String, StatusStatistics>>() {
@Override
public int compare(java.util.Map.Entry<String, StatusStatistics> o1,
java.util.Map.Entry<String, StatusStatistics> o2) {
return o2.getValue().getCount()-o1.getValue().getCount();
}
});
return result;
}
public void setStatus(Map<String, StatusStatistics> status) {
......
......@@ -66,8 +66,6 @@
</table>
<font color="white">${lastIndex+1}</font>
<res:useJs value="${res.js.local.event_js}" target="bottom-js" />
</jsp:body>
</a:report>
<res:useJs value="${res.js.local.event_js}" target="bottom-js" />
\ No newline at end of file
......@@ -16,9 +16,10 @@
<res:useCss value='${res.css.local.ip_css}' target="head-css"/>
<table class="ip-table">
<tr><th>IP</th><th>last 1 min</th><th>last 5 mins</th><th>last 15 mins</th></tr>
<tr><th>No.</th><th>IP</th><th>last 1 min</th><th>last 5 mins</th><th>last 15 mins</th></tr>
<c:forEach var="m" items="${model.displayModels}" varStatus="status">
<tr class="${status.index mod 2 != 0 ? 'odd' : 'even'}">
<td>${status.index+1}</td>
<td>${m.address}</td>
<td>${m.lastOne}</td>
<td>${m.lastFive}</td>
......
......@@ -42,7 +42,9 @@
</tr>
</table>
<br>
<%@ include file="problemTable.jsp" %>
<br>
<table class="problem">
<tr>
......
......@@ -37,7 +37,9 @@
</tr>
</table>
<br>
<%@ include file="problemTable.jsp" %>
<br>
<table class="problem">
<tr><td title="time\group">T\G</td>
......
......@@ -66,8 +66,7 @@
</table>
<font color="white">${lastIndex+1}</font>
<res:useJs value="${res.js.local.transaction_js}" target="bottom-js" />
</jsp:body>
</a:report>
<res:useJs value="${res.js.local.transaction_js}" target="bottom-js" />
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册