mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 08:46:22 +10:00
[강운덕] [WEB-49] Collection을 List로 copy하는 작업을 최소화 하도록 함. Host 클래스의 key를 정확하게 id + serviceType으로 구성하도록 리팩토링.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-web/trunk@3375 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -30,11 +30,11 @@ public class ApplicationMap {
|
||||
}
|
||||
|
||||
|
||||
public List<Node> getNodes() {
|
||||
public Collection<Node> getNodes() {
|
||||
return this.nodeList.getNodeList();
|
||||
}
|
||||
|
||||
public List<Link> getLinks() {
|
||||
public Collection<Link> getLinks() {
|
||||
return this.linkList.getLinks();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ApplicationMap {
|
||||
throw new NullPointerException("responseDataSource must not be null");
|
||||
}
|
||||
|
||||
final List<Node> nodes = this.nodeList.getNodeList();
|
||||
final Collection<Node> nodes = this.nodeList.getNodeList();
|
||||
for (Node node : nodes) {
|
||||
if (node.getServiceType().isWas()) {
|
||||
// was일 경우 자신의 response 히스토그램을 조회하여 채운다.
|
||||
@@ -123,7 +123,7 @@ public class ApplicationMap {
|
||||
Application nodeApplication = new Application(node.getApplicationName(), node.getServiceType());
|
||||
final ResponseHistogramSummary summary = new ResponseHistogramSummary(nodeApplication);
|
||||
|
||||
List<Link> linkList = this.linkList.getLinks();
|
||||
Collection<Link> linkList = this.linkList.getLinks();
|
||||
for (Link link : linkList) {
|
||||
Node toNode = link.getTo();
|
||||
String applicationName = toNode.getApplicationName();
|
||||
@@ -142,7 +142,7 @@ public class ApplicationMap {
|
||||
Application nodeApplication = new Application(node.getApplicationName(), node.getServiceType());
|
||||
final ResponseHistogramSummary summary = new ResponseHistogramSummary(nodeApplication);
|
||||
|
||||
List<Link> linkList = this.linkList.getLinks();
|
||||
Collection<Link> linkList = this.linkList.getLinks();
|
||||
for (Link link : linkList) {
|
||||
Node fromNode = link.getFrom();
|
||||
String applicationName = fromNode.getApplicationName();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.nhn.pinpoint.web.applicationmap;
|
||||
|
||||
import com.nhn.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.HostList;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogramList;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.LinkStatistics;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.LinkStatisticsData;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
@@ -20,7 +20,7 @@ public class ApplicationMapBuilder {
|
||||
public ApplicationMapBuilder() {
|
||||
}
|
||||
|
||||
public ApplicationMap build(List<LinkStatistics> linkStatistics) {
|
||||
public ApplicationMap build(Collection<LinkStatistics> linkStatistics) {
|
||||
if (linkStatistics == null) {
|
||||
throw new NullPointerException("linkStatData must not be null");
|
||||
}
|
||||
@@ -63,8 +63,8 @@ public class ApplicationMapBuilder {
|
||||
}
|
||||
|
||||
// RPC client인 경우 dest application이 이미 있으면 삭제, 없으면 unknown cloud로 변경.
|
||||
HostList toHostList = linkStat.getToHostList();
|
||||
Link link = new Link(fromNode, toNode, toHostList);
|
||||
CallHistogramList toCallHistogramList = linkStat.getToHostList();
|
||||
Link link = new Link(fromNode, toNode, toCallHistogramList);
|
||||
link.setSourceList(linkStat.getSourceList());
|
||||
if (toNode.getServiceType().isRpcClient()) {
|
||||
if (!nodeMap.containsApplicationName(toNode.getApplicationName())) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.nhn.pinpoint.web.applicationmap;
|
||||
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogram;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogramList;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.Histogram;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.Host;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.HostList;
|
||||
import com.nhn.pinpoint.web.vo.LinkKey;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
import org.slf4j.Logger;
|
||||
@@ -22,12 +22,12 @@ public class Link {
|
||||
private final Node fromNode;
|
||||
private final Node toNode;
|
||||
|
||||
private final HostList hostList;
|
||||
private HostList sourceList;
|
||||
private final CallHistogramList tagetList;
|
||||
private CallHistogramList sourceList;
|
||||
|
||||
|
||||
public Link(Node from, Node to, HostList hostList) {
|
||||
this(createLinkKey(from, to), from, to, hostList);
|
||||
public Link(Node from, Node to, CallHistogramList tagetList) {
|
||||
this(createLinkKey(from, to), from, to, tagetList);
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Link {
|
||||
return new LinkKey(fromApplication, toApplication);
|
||||
}
|
||||
|
||||
Link(LinkKey linkKey, Node fromNode, Node toNode, HostList hostList) {
|
||||
Link(LinkKey linkKey, Node fromNode, Node toNode, CallHistogramList tagetList) {
|
||||
if (fromNode == null) {
|
||||
throw new NullPointerException("fromNode must not be null");
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class Link {
|
||||
this.linkKey = linkKey;
|
||||
this.fromNode = fromNode;
|
||||
this.toNode = toNode;
|
||||
this.hostList = hostList;
|
||||
this.tagetList = tagetList;
|
||||
}
|
||||
|
||||
public Link(Link copyLink) {
|
||||
@@ -66,8 +66,8 @@ public class Link {
|
||||
this.linkKey = copyLink.linkKey;
|
||||
this.fromNode = copyLink.fromNode;
|
||||
this.toNode = copyLink.toNode;
|
||||
this.hostList = new HostList(copyLink.hostList);
|
||||
this.sourceList = new HostList(copyLink.sourceList);
|
||||
this.tagetList = new CallHistogramList(copyLink.tagetList);
|
||||
this.sourceList = new CallHistogramList(copyLink.sourceList);
|
||||
}
|
||||
|
||||
public LinkKey getLinkKey() {
|
||||
@@ -82,30 +82,30 @@ public class Link {
|
||||
return toNode;
|
||||
}
|
||||
|
||||
public HostList getHostList() {
|
||||
return hostList;
|
||||
public CallHistogramList getTargetList() {
|
||||
return tagetList;
|
||||
}
|
||||
|
||||
|
||||
public Histogram getHistogram() {
|
||||
Histogram result = null;
|
||||
|
||||
for (Host host : hostList.getHostList()) {
|
||||
for (CallHistogram callHistogram : tagetList.getHostList()) {
|
||||
if (result == null) {
|
||||
// FIXME 뭔가 괴상한 방식이긴 하지만..
|
||||
Histogram histogram = host.getHistogram();
|
||||
Histogram histogram = callHistogram.getHistogram();
|
||||
result = new Histogram(histogram.getServiceType());
|
||||
}
|
||||
result.add(host.getHistogram());
|
||||
result.add(callHistogram.getHistogram());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setSourceList(HostList sourceList) {
|
||||
public void setSourceList(CallHistogramList sourceList) {
|
||||
this.sourceList = sourceList;
|
||||
}
|
||||
|
||||
public HostList getSourceList() {
|
||||
public CallHistogramList getSourceList() {
|
||||
return sourceList;
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ public class Link {
|
||||
throw new IllegalArgumentException("Can't merge.");
|
||||
}
|
||||
|
||||
HostList linkHostList = link.getHostList();
|
||||
this.hostList.addHostList(linkHostList);
|
||||
CallHistogramList linkCallHistogramList = link.getTargetList();
|
||||
this.tagetList.addHostList(linkCallHistogramList);
|
||||
this.sourceList.addHostList(link.getSourceList());
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class Link {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Link [linkKey=" + linkKey + ", fromNode=" + fromNode + ", toNode=" + toNode + ", hostList=" + hostList + "]";
|
||||
return "Link [linkKey=" + linkKey + ", fromNode=" + fromNode + ", toNode=" + toNode + ", tagetList=" + tagetList + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.*;
|
||||
public class LinkList {
|
||||
private final Map<LinkKey, Link> linkMap = new HashMap<LinkKey, Link>();
|
||||
|
||||
public List<Link> getLinks() {
|
||||
return new ArrayList<Link>(this.linkMap.values());
|
||||
public Collection<Link> getLinks() {
|
||||
return this.linkMap.values();
|
||||
}
|
||||
|
||||
public void buildLink(List<Link> relationList) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.nhn.pinpoint.web.applicationmap;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.HostList;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogramList;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
import com.nhn.pinpoint.web.vo.ResponseHistogramSummary;
|
||||
import org.slf4j.Logger;
|
||||
@@ -27,7 +27,7 @@ public class Node implements JsonSerializable {
|
||||
|
||||
private final ServerInstanceList serverInstanceList = new ServerInstanceList();
|
||||
|
||||
private final HostList hostList;
|
||||
private final CallHistogramList callHistogramList;
|
||||
private final Set<AgentInfoBo> agentSet;
|
||||
|
||||
private ResponseHistogramSummary responseHistogramSummary;
|
||||
@@ -37,24 +37,24 @@ public class Node implements JsonSerializable {
|
||||
this(application, null, agentSet);
|
||||
}
|
||||
|
||||
public Node(Application application, HostList hostList) {
|
||||
this(application, hostList, null);
|
||||
public Node(Application application, CallHistogramList callHistogramList) {
|
||||
this(application, callHistogramList, null);
|
||||
}
|
||||
|
||||
Node(Application application, HostList hostList, Set<AgentInfoBo> agentSet) {
|
||||
Node(Application application, CallHistogramList callHistogramList, Set<AgentInfoBo> agentSet) {
|
||||
if (application == null) {
|
||||
throw new NullPointerException("application must not be null");
|
||||
}
|
||||
|
||||
logger.debug("create node application={}, agentSet={}", application, agentSet);
|
||||
this.application = application;
|
||||
this.hostList = new HostList();
|
||||
this.callHistogramList = new CallHistogramList();
|
||||
this.agentSet = new HashSet<AgentInfoBo>();
|
||||
|
||||
if (hostList != null) {
|
||||
if (callHistogramList != null) {
|
||||
// 이 put은 정확하지 않음.
|
||||
// this.hostList.addHostList(hostList);
|
||||
this.hostList.put(hostList);
|
||||
// this.callHistogramList.addHostList(callHistogramList);
|
||||
this.callHistogramList.put(callHistogramList);
|
||||
}
|
||||
|
||||
if (agentSet != null) {
|
||||
@@ -67,7 +67,7 @@ public class Node implements JsonSerializable {
|
||||
throw new NullPointerException("copyNode must not be null");
|
||||
}
|
||||
this.application = copyNode.application;
|
||||
this.hostList = new HostList(copyNode.hostList);
|
||||
this.callHistogramList = new CallHistogramList(copyNode.callHistogramList);
|
||||
this.agentSet = new HashSet<AgentInfoBo>(copyNode.agentSet);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Node implements JsonSerializable {
|
||||
if (!agentSet.isEmpty()) {
|
||||
serverInstanceList.fillServerInstanceList(agentSet);
|
||||
} else {
|
||||
serverInstanceList.fillServerInstanceList(hostList);
|
||||
serverInstanceList.fillServerInstanceList(callHistogramList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ public class Node implements JsonSerializable {
|
||||
logger.trace("merge node this={}, node={}", this.application, node.application);
|
||||
|
||||
// 리얼 application을 실제빌드할때 copy하여 만들기 때문에. add할때 데이터를 hostList를 add해도 된다.
|
||||
this.hostList.addHostList(node.hostList);
|
||||
// this.hostList.put(node.hostList);
|
||||
this.callHistogramList.addHostList(node.callHistogramList);
|
||||
// this.callHistogramList.put(node.callHistogramList);
|
||||
|
||||
if (node.agentSet != null) {
|
||||
this.agentSet.addAll(node.agentSet);
|
||||
|
||||
@@ -11,8 +11,8 @@ public class NodeList {
|
||||
|
||||
private final Map<Application, Node> nodeMap = new HashMap<Application, Node>();
|
||||
|
||||
public List<Node> getNodeList() {
|
||||
return new ArrayList<Node>(this.nodeMap.values());
|
||||
public Collection<Node> getNodeList() {
|
||||
return this.nodeMap.values();
|
||||
}
|
||||
|
||||
public void markSequence() {
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.nhn.pinpoint.web.applicationmap;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.common.bo.AgentInfoBo;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.Host;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.HostList;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogram;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.CallHistogramList;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -25,15 +25,15 @@ public class ServerInstanceList {
|
||||
*
|
||||
* @param hostHistogram
|
||||
*/
|
||||
public void fillServerInstanceList(final HostList hostHistogram) {
|
||||
public void fillServerInstanceList(final CallHistogramList hostHistogram) {
|
||||
if (hostHistogram == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Host host : hostHistogram.getHostList()) {
|
||||
final String instanceName = host.getHost();
|
||||
final String hostName = getHostName(host.getHost());
|
||||
final ServiceType serviceType = host.getServiceType();
|
||||
for (CallHistogram callHistogram : hostHistogram.getHostList()) {
|
||||
final String instanceName = callHistogram.getId();
|
||||
final String hostName = getHostName(callHistogram.getId());
|
||||
final ServiceType serviceType = callHistogram.getServiceType();
|
||||
|
||||
final List<ServerInstance> find = serverInstanceList.get(hostName);
|
||||
if (find == null) {
|
||||
|
||||
+17
-17
@@ -7,39 +7,39 @@ import com.nhn.pinpoint.common.ServiceType;
|
||||
* @author netspider
|
||||
* @author emeroad
|
||||
*/
|
||||
public class Host {
|
||||
public class CallHistogram {
|
||||
/**
|
||||
* UI에서 호스트를 구분하기 위한 목적으로 hostname, agentid, endpoint등 구분할 수 있는 아무거나 넣으면 됨.
|
||||
*/
|
||||
private final String host;
|
||||
private final String id;
|
||||
private final ServiceType serviceType;
|
||||
private final Histogram histogram;
|
||||
|
||||
public Host(String host, ServiceType serviceType) {
|
||||
if (host == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
public CallHistogram(String agent, ServiceType serviceType) {
|
||||
if (agent == null) {
|
||||
throw new NullPointerException("agent must not be null");
|
||||
}
|
||||
if (serviceType == null) {
|
||||
throw new NullPointerException("serviceType must not be null");
|
||||
}
|
||||
this.host = host;
|
||||
this.id = agent;
|
||||
this.serviceType = serviceType;
|
||||
this.histogram = new Histogram(serviceType);
|
||||
}
|
||||
|
||||
public Host(Host copyHost) {
|
||||
if (copyHost == null) {
|
||||
throw new NullPointerException("copyHost must not be null");
|
||||
public CallHistogram(CallHistogram copyCallHistogram) {
|
||||
if (copyCallHistogram == null) {
|
||||
throw new NullPointerException("copyCallHistogram must not be null");
|
||||
}
|
||||
|
||||
this.host = copyHost.host;
|
||||
this.serviceType = copyHost.serviceType;
|
||||
this.id = copyCallHistogram.id;
|
||||
this.serviceType = copyCallHistogram.serviceType;
|
||||
this.histogram = new Histogram(serviceType);
|
||||
this.histogram.add(copyHost.histogram);
|
||||
this.histogram.add(copyCallHistogram.histogram);
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ServiceType getServiceType() {
|
||||
@@ -53,7 +53,7 @@ public class Host {
|
||||
public String getJson() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("{");
|
||||
sb.append("\"name\":\"").append(host).append("\",");
|
||||
sb.append("\"name\":\"").append(id).append("\",");
|
||||
sb.append("\"histogram\":").append(histogram.getJson());
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
@@ -61,8 +61,8 @@ public class Host {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("Host{");
|
||||
sb.append("host='").append(host).append('\'');
|
||||
final StringBuilder sb = new StringBuilder("CallHistogram{");
|
||||
sb.append("agent='").append(id).append('\'');
|
||||
sb.append(", serviceType=").append(serviceType);
|
||||
sb.append(", ").append(histogram);
|
||||
sb.append('}');
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.nhn.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class CallHistogramList {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Map<Application, CallHistogram> callHistogramMap = new HashMap<Application, CallHistogram>();
|
||||
|
||||
public CallHistogramList() {
|
||||
}
|
||||
|
||||
public CallHistogramList(CallHistogramList copyCallHistogramList) {
|
||||
if (copyCallHistogramList == null) {
|
||||
throw new NullPointerException("copyCallHistogramList must not be null");
|
||||
}
|
||||
|
||||
for (Map.Entry<Application, CallHistogram> copyEntry : copyCallHistogramList.callHistogramMap.entrySet()) {
|
||||
Application copyKey = copyEntry.getKey();
|
||||
CallHistogram copyValue = new CallHistogram(copyEntry.getValue());
|
||||
this.callHistogramMap.put(copyKey, copyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addHost(String agentName, ServiceType serviceType, Histogram histogram) {
|
||||
if (agentName == null) {
|
||||
throw new NullPointerException("agent must not be null");
|
||||
}
|
||||
if (serviceType == null) {
|
||||
throw new NullPointerException("serviceType must not be null");
|
||||
}
|
||||
|
||||
CallHistogram callHistogram = getCallHistogram(agentName, serviceType);
|
||||
final Histogram hostHistogram = callHistogram.getHistogram();
|
||||
hostHistogram.add(histogram);
|
||||
}
|
||||
|
||||
public void addHostUncheck(String hostName, ServiceType serviceType, Histogram histogram) {
|
||||
if (hostName == null) {
|
||||
throw new NullPointerException("callHistogram must not be null");
|
||||
}
|
||||
if (serviceType == null) {
|
||||
throw new NullPointerException("serviceType must not be null");
|
||||
}
|
||||
CallHistogram callHistogram = getCallHistogram(hostName, serviceType);
|
||||
final Histogram hostHistogram = callHistogram.getHistogram();
|
||||
hostHistogram.addUncheckType(histogram);
|
||||
}
|
||||
|
||||
|
||||
private CallHistogram getCallHistogram(String agent, ServiceType serviceType) {
|
||||
Application agentId = new Application(agent, serviceType);
|
||||
CallHistogram callHistogram = callHistogramMap.get(agentId);
|
||||
if (callHistogram == null) {
|
||||
callHistogram = new CallHistogram(agent, serviceType);
|
||||
callHistogramMap.put(agentId, callHistogram);
|
||||
}
|
||||
return callHistogram;
|
||||
}
|
||||
|
||||
|
||||
public void addCallHistogram(CallHistogram callHistogram) {
|
||||
if (callHistogram == null) {
|
||||
throw new NullPointerException("callHistogram must not be null");
|
||||
}
|
||||
final String hostName = callHistogram.getId();
|
||||
ServiceType serviceType = callHistogram.getServiceType();
|
||||
|
||||
CallHistogram findCallHistogram = getCallHistogram(hostName, serviceType);
|
||||
Histogram histogram = findCallHistogram.getHistogram();
|
||||
histogram.add(callHistogram.getHistogram());
|
||||
}
|
||||
|
||||
public void addHostList(CallHistogramList addCallHistogramList) {
|
||||
if (addCallHistogramList == null) {
|
||||
throw new NullPointerException("callHistogram must not be null");
|
||||
}
|
||||
for (CallHistogram callHistogram : addCallHistogramList.callHistogramMap.values()) {
|
||||
addCallHistogram(callHistogram);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<CallHistogram> getHostList() {
|
||||
return callHistogramMap.values();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void put(CallHistogramList addCallHistogramList) {
|
||||
if (addCallHistogramList == null) {
|
||||
throw new NullPointerException("callHistogram must not be null");
|
||||
}
|
||||
// 이 메소드를 문제가 있음 put정책이 정확하지 않음.
|
||||
for (CallHistogram callHistogram : addCallHistogramList.callHistogramMap.values()) {
|
||||
final String hostName = callHistogram.getId();
|
||||
ServiceType serviceType = callHistogram.getServiceType();
|
||||
Application agentId = new Application(hostName, serviceType);
|
||||
final CallHistogram old = this.callHistogramMap.put(agentId, callHistogram);
|
||||
if (old != null) {
|
||||
logger.warn("old key exist. key:{}, new:{} old:{}", agentId, callHistogram, old);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CallHistogram{"
|
||||
+ callHistogramMap +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,10 @@ public class Histogram implements JsonSerializable {
|
||||
this.histogramSchema = serviceType.getHistogramSchema();
|
||||
}
|
||||
|
||||
public void addElapsedTime(int elapsedTime) {
|
||||
public void addCallCountByElapsedTime(int elapsedTime) {
|
||||
HistogramSlot histogramSlot = histogramSchema.findHistogramSlot(elapsedTime);
|
||||
short slotTime = histogramSlot.getSlotTime();
|
||||
addSample(slotTime, 1);
|
||||
addCallCount(slotTime, 1);
|
||||
}
|
||||
|
||||
public Histogram(final short serviceType) {
|
||||
@@ -49,7 +49,7 @@ public class Histogram implements JsonSerializable {
|
||||
}
|
||||
|
||||
// TODO slot번호를 이 클래스에서 추출해야 할 것 같긴 함.
|
||||
public void addSample(final short slotTime, final long count) {
|
||||
public void addCallCount(final short slotTime, final long count) {
|
||||
this.totalCount += count;
|
||||
|
||||
if (slotTime == histogramSchema.getVerySlowSlot().getSlotTime()) { // 0 is slow slotTime
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package com.nhn.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class HostList {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final Map<String, Host> hostMap = new HashMap<String, Host>();
|
||||
|
||||
public HostList() {
|
||||
}
|
||||
|
||||
public HostList(HostList copyHostList) {
|
||||
if (copyHostList == null) {
|
||||
throw new NullPointerException("copyHostList must not be null");
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Host> copyEntry : copyHostList.hostMap.entrySet()) {
|
||||
String copyKey = copyEntry.getKey();
|
||||
Host copyValue = new Host(copyEntry.getValue());
|
||||
this.hostMap.put(copyKey, copyValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addHost(String hostName, short serviceTypeCode, Histogram histogram) {
|
||||
if (hostName == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
}
|
||||
Host host = getHost(hostName, serviceTypeCode);
|
||||
|
||||
final Histogram hostHistogram = host.getHistogram();
|
||||
hostHistogram.add(histogram);
|
||||
}
|
||||
|
||||
public void addHostUncheck(String hostName, short serviceTypeCode, Histogram histogram) {
|
||||
if (hostName == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
}
|
||||
Host host = getHost(hostName, serviceTypeCode);
|
||||
|
||||
final Histogram hostHistogram = host.getHistogram();
|
||||
hostHistogram.addUncheckType(histogram);
|
||||
}
|
||||
|
||||
private Host getHost(String hostName, short serviceTypeCode) {
|
||||
Host host = hostMap.get(hostName);
|
||||
if (host == null) {
|
||||
host = new Host(hostName, ServiceType.findServiceType(serviceTypeCode));
|
||||
hostMap.put(hostName, host);
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
public void addHost(Host host) {
|
||||
if (host == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
}
|
||||
final String hostName = host.getHost();
|
||||
final Host find = this.hostMap.get(hostName);
|
||||
if (find != null) {
|
||||
final Histogram histogram = find.getHistogram();
|
||||
histogram.add(host.getHistogram());
|
||||
} else {
|
||||
// WARN 이것도 copy해야 함.
|
||||
Host copy = new Host(host);
|
||||
hostMap.put(hostName, copy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addHostList(HostList addHostList) {
|
||||
if (addHostList == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
}
|
||||
for (Host host : addHostList.hostMap.values()) {
|
||||
addHost(host);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Host> getHostList() {
|
||||
final Collection<Host> values = hostMap.values();
|
||||
return new ArrayList<Host>(values);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void put(HostList addHostList) {
|
||||
if (addHostList == null) {
|
||||
throw new NullPointerException("host must not be null");
|
||||
}
|
||||
// 이 메소드를 문제가 있음 put정책이 정확하지 않음.
|
||||
for (Host host : addHostList.hostMap.values()) {
|
||||
final String hostName = host.getHost();
|
||||
final Host old = this.hostMap.put(hostName, host);
|
||||
if (old != null) {
|
||||
logger.warn("old key exist. key:{}, new:{} old:{}", hostName, host, old);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HostList{"
|
||||
+ hostMap +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -101,11 +101,11 @@ public class LinkStatistics {
|
||||
this.toApplication = toApplication;
|
||||
}
|
||||
|
||||
public HostList getToHostList() {
|
||||
public CallHistogramList getToHostList() {
|
||||
return callDataMap.getTargetList();
|
||||
}
|
||||
|
||||
public HostList getSourceList() {
|
||||
public CallHistogramList getSourceList() {
|
||||
return callDataMap.getSourceList();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@ import com.nhn.pinpoint.web.vo.Application;
|
||||
|
||||
public class LinkStatisticsData {
|
||||
|
||||
private final List<LinkStatistics> linkStatData;
|
||||
private final Collection<LinkStatistics> linkStatData;
|
||||
|
||||
public LinkStatisticsData(List<LinkStatistics> linkStatData) {
|
||||
public LinkStatisticsData(Collection<LinkStatistics> linkStatData) {
|
||||
if (linkStatData == null) {
|
||||
throw new NullPointerException("linkStatData must not be null");
|
||||
}
|
||||
this.linkStatData = linkStatData;
|
||||
}
|
||||
|
||||
public List<LinkStatistics> getLinkStatData() {
|
||||
public Collection<LinkStatistics> getLinkStatData() {
|
||||
return linkStatData;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RawCallDataMap {
|
||||
RawCallData rawCallData = getRawCallData(linkKey);
|
||||
|
||||
final Histogram histogram = rawCallData.getHistogram();
|
||||
histogram.addSample(slot, count);
|
||||
histogram.addCallCount(slot, count);
|
||||
}
|
||||
|
||||
public LinkKey createLinkKey(String sourceAgentId, ServiceType sourceServiceType, String targetId, ServiceType targetServiceType) {
|
||||
@@ -52,22 +52,22 @@ public class RawCallDataMap {
|
||||
return rawCallData;
|
||||
}
|
||||
|
||||
public HostList getTargetList() {
|
||||
HostList targetList = new HostList();
|
||||
public CallHistogramList getTargetList() {
|
||||
CallHistogramList targetList = new CallHistogramList();
|
||||
for (Map.Entry<LinkKey, RawCallData> linkKeyRawCallDataEntry : rawCallDataMap.entrySet()) {
|
||||
final LinkKey key = linkKeyRawCallDataEntry.getKey();
|
||||
final RawCallData value = linkKeyRawCallDataEntry.getValue();
|
||||
targetList.addHost(key.getToApplication(), key.getToServiceType().getCode(), value.getHistogram());
|
||||
final RawCallData rawCallData = linkKeyRawCallDataEntry.getValue();
|
||||
targetList.addHost(key.getToApplication(), key.getToServiceType(), rawCallData.getHistogram());
|
||||
}
|
||||
return targetList;
|
||||
}
|
||||
|
||||
public HostList getSourceList() {
|
||||
HostList sourceList = new HostList();
|
||||
public CallHistogramList getSourceList() {
|
||||
CallHistogramList sourceList = new CallHistogramList();
|
||||
for (Map.Entry<LinkKey, RawCallData> linkKeyRawCallDataEntry : rawCallDataMap.entrySet()) {
|
||||
final LinkKey key = linkKeyRawCallDataEntry.getKey();
|
||||
final RawCallData value = linkKeyRawCallDataEntry.getValue();
|
||||
sourceList.addHostUncheck(key.getFromApplication(), key.getFromServiceType().getCode(), value.getHistogram());
|
||||
final RawCallData rawCallData = linkKeyRawCallDataEntry.getValue();
|
||||
sourceList.addHostUncheck(key.getFromApplication(), key.getFromServiceType(), rawCallData.getHistogram());
|
||||
}
|
||||
return sourceList;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nhn.pinpoint.web.dao;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +14,7 @@ import com.nhn.pinpoint.web.vo.Range;
|
||||
*
|
||||
*/
|
||||
public interface MapStatisticsCalleeDao {
|
||||
public List<LinkStatistics> selectCallee(Application calleeApplication, Range range);
|
||||
public Collection<LinkStatistics> selectCallee(Application calleeApplication, Range range);
|
||||
|
||||
public List<Map<Long, Map<Short, Long>>> selectCalleeStatistics(Application callerApplication, Application calleeApplication, Range range);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.nhn.pinpoint.web.dao;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +14,7 @@ import com.nhn.pinpoint.web.vo.Range;
|
||||
*
|
||||
*/
|
||||
public interface MapStatisticsCallerDao {
|
||||
public List<LinkStatistics> selectCaller(Application callerApplication, Range range);
|
||||
public Collection<LinkStatistics> selectCaller(Application callerApplication, Range range);
|
||||
|
||||
public List<Map<Long, Map<Short, Long>>> selectCallerStatistics(Application callerApplication, Application calleeApplication, Range range);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.nhn.pinpoint.web.dao.hbase;
|
||||
import static com.nhn.pinpoint.common.hbase.HBaseTables.AGENT_NAME_MAX_LEN;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
|
||||
@@ -2,10 +2,7 @@ package com.nhn.pinpoint.web.dao.hbase;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import com.nhn.pinpoint.web.dao.MapStatisticsCalleeDao;
|
||||
@@ -44,10 +41,10 @@ public class HbaseMapStatisticsCalleeDao implements MapStatisticsCalleeDao {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mapStatisticsCalleeMapper")
|
||||
private RowMapper<List<LinkStatistics>> mapStatisticsCalleeMapper;
|
||||
private RowMapper<Collection<LinkStatistics>> mapStatisticsCalleeMapper;
|
||||
|
||||
@Override
|
||||
public List<LinkStatistics> selectCallee(Application calleeApplication, Range range) {
|
||||
public Collection<LinkStatistics> selectCallee(Application calleeApplication, Range range) {
|
||||
if (calleeApplication == null) {
|
||||
throw new NullPointerException("calleeApplication must not be null");
|
||||
}
|
||||
@@ -55,7 +52,7 @@ public class HbaseMapStatisticsCalleeDao implements MapStatisticsCalleeDao {
|
||||
throw new NullPointerException("range must not be null");
|
||||
}
|
||||
Scan scan = createScan(calleeApplication, range);
|
||||
final List<List<LinkStatistics>> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLER, scan, mapStatisticsCalleeMapper);
|
||||
List<Collection<LinkStatistics>> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLER, scan, mapStatisticsCalleeMapper);
|
||||
|
||||
if (foundListList.isEmpty()) {
|
||||
logger.debug("There's no caller data. {}, {}", calleeApplication, range);
|
||||
@@ -64,10 +61,10 @@ public class HbaseMapStatisticsCalleeDao implements MapStatisticsCalleeDao {
|
||||
return merge(foundListList);
|
||||
}
|
||||
|
||||
private List<LinkStatistics> merge(List<List<LinkStatistics>> foundListList) {
|
||||
private Collection<LinkStatistics> merge(List<Collection<LinkStatistics>> foundListList) {
|
||||
final Map<LinkKey, LinkStatistics> result = new HashMap<LinkKey, LinkStatistics>();
|
||||
|
||||
for (List<LinkStatistics> foundList : foundListList) {
|
||||
for (Collection<LinkStatistics> foundList : foundListList) {
|
||||
for (LinkStatistics found : foundList) {
|
||||
final LinkKey key = new LinkKey(found.getFromApplication(), found.getToApplication());
|
||||
final LinkStatistics find = result.get(key);
|
||||
@@ -79,7 +76,7 @@ public class HbaseMapStatisticsCalleeDao implements MapStatisticsCalleeDao {
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<LinkStatistics>(result.values());
|
||||
return result.values();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@ package com.nhn.pinpoint.web.dao.hbase;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import com.nhn.pinpoint.web.dao.MapStatisticsCallerDao;
|
||||
import com.nhn.pinpoint.web.mapper.MapLinkStatisticsMapper;
|
||||
@@ -43,12 +40,12 @@ public class HbaseMapStatisticsCallerDao implements MapStatisticsCallerDao {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mapStatisticsCallerMapper")
|
||||
private RowMapper<List<LinkStatistics>> mapStatisticsCallerMapper;
|
||||
private RowMapper<Collection<LinkStatistics>> mapStatisticsCallerMapper;
|
||||
|
||||
@Override
|
||||
public List<LinkStatistics> selectCaller(Application callerApplication, Range range) {
|
||||
public Collection<LinkStatistics> selectCaller(Application callerApplication, Range range) {
|
||||
Scan scan = createScan(callerApplication, range);
|
||||
final List<List<LinkStatistics>> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLEE, scan, mapStatisticsCallerMapper);
|
||||
final List<Collection<LinkStatistics>> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLEE, scan, mapStatisticsCallerMapper);
|
||||
|
||||
if (foundListList.isEmpty()) {
|
||||
logger.debug("There's no caller data. {}, {}", callerApplication, range);
|
||||
@@ -57,10 +54,10 @@ public class HbaseMapStatisticsCallerDao implements MapStatisticsCallerDao {
|
||||
return merge(foundListList);
|
||||
}
|
||||
|
||||
private List<LinkStatistics> merge(List<List<LinkStatistics>> foundListList) {
|
||||
private Collection<LinkStatistics> merge(List<Collection<LinkStatistics>> foundListList) {
|
||||
final Map<LinkKey, LinkStatistics> result = new HashMap<LinkKey, LinkStatistics>();
|
||||
|
||||
for (List<LinkStatistics> foundList : foundListList) {
|
||||
for (Collection<LinkStatistics> foundList : foundListList) {
|
||||
for (LinkStatistics found : foundList) {
|
||||
final LinkKey key = new LinkKey(found.getFromApplication(), found.getToApplication());
|
||||
final LinkStatistics find = result.get(key);
|
||||
@@ -73,7 +70,7 @@ public class HbaseMapStatisticsCallerDao implements MapStatisticsCallerDao {
|
||||
}
|
||||
|
||||
|
||||
return new ArrayList<LinkStatistics>(result.values());
|
||||
return result.values();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.nhn.pinpoint.web.mapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.nhn.pinpoint.common.buffer.Buffer;
|
||||
import com.nhn.pinpoint.common.buffer.FixedBuffer;
|
||||
import com.nhn.pinpoint.common.util.TimeUtils;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.LinkStatistics;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
import com.nhn.pinpoint.web.vo.LinkKey;
|
||||
@@ -21,26 +24,24 @@ import com.nhn.pinpoint.common.util.ApplicationMapStatisticsUtils;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MapStatisticsCalleeMapper implements RowMapper<List<LinkStatistics>> {
|
||||
public class MapStatisticsCalleeMapper implements RowMapper<Collection<LinkStatistics>> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public List<LinkStatistics> mapRow(Result result, int rowNum) throws Exception {
|
||||
public Collection<LinkStatistics> mapRow(Result result, int rowNum) throws Exception {
|
||||
if (result.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
logger.debug("mapRow:{}", rowNum);
|
||||
final KeyValue[] keyList = result.raw();
|
||||
|
||||
final Buffer row = new FixedBuffer(result.getRow());
|
||||
final Application calleeApplication = readCalleeApplication(row);
|
||||
final long timestamp = TimeUtils.recoveryCurrentTimeMillis(row.readLong());
|
||||
|
||||
|
||||
final Map<LinkKey, LinkStatistics> linkStatisticsMap = new HashMap<LinkKey, LinkStatistics>();
|
||||
|
||||
final byte[] rowKey = result.getRow();
|
||||
final long timestamp = ApplicationMapStatisticsUtils.getTimestampFromRowKey(rowKey);
|
||||
logger.debug("rowKey time:{}", timestamp);
|
||||
Application calleeApplication = readCalleeApplication(rowKey);
|
||||
|
||||
for (KeyValue kv : keyList) {
|
||||
for (KeyValue kv : result.raw()) {
|
||||
|
||||
final byte[] qualifier = kv.getQualifier();
|
||||
Application callerApplication = readCallerApplication(qualifier);
|
||||
@@ -63,7 +64,7 @@ public class MapStatisticsCalleeMapper implements RowMapper<List<LinkStatistics>
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<LinkStatistics>(linkStatisticsMap.values());
|
||||
return linkStatisticsMap.values();
|
||||
}
|
||||
|
||||
private LinkStatistics getLinkStatics(Map<LinkKey, LinkStatistics> linkStatisticsMap, Application callerApplication, Application calleeApplication, long timestamp) {
|
||||
@@ -82,9 +83,9 @@ public class MapStatisticsCalleeMapper implements RowMapper<List<LinkStatistics>
|
||||
return new Application(callerApplicationName, callerServiceType);
|
||||
}
|
||||
|
||||
private Application readCalleeApplication(byte[] row) {
|
||||
String calleeApplicationName = ApplicationMapStatisticsUtils.getApplicationNameFromRowKey(row);
|
||||
short calleeServiceType = ApplicationMapStatisticsUtils.getApplicationTypeFromRowKey(row);
|
||||
private Application readCalleeApplication(Buffer row) {
|
||||
String calleeApplicationName = row.read2PrefixedString();
|
||||
short calleeServiceType = row.readShort();
|
||||
return new Application(calleeApplicationName, calleeServiceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import java.util.*;
|
||||
|
||||
import com.nhn.pinpoint.common.buffer.Buffer;
|
||||
import com.nhn.pinpoint.common.buffer.FixedBuffer;
|
||||
import com.nhn.pinpoint.common.buffer.OffsetFixedBuffer;
|
||||
import com.nhn.pinpoint.common.hbase.HBaseTables;
|
||||
import com.nhn.pinpoint.common.util.TimeUtils;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.LinkStatistics;
|
||||
import com.nhn.pinpoint.web.vo.Application;
|
||||
import com.nhn.pinpoint.web.vo.LinkKey;
|
||||
@@ -25,24 +27,24 @@ import com.nhn.pinpoint.common.util.ApplicationMapStatisticsUtils;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MapStatisticsCallerMapper implements RowMapper<List<LinkStatistics>> {
|
||||
public class MapStatisticsCallerMapper implements RowMapper<Collection<LinkStatistics>> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public List<LinkStatistics> mapRow(Result result, int rowNum) throws Exception {
|
||||
public Collection<LinkStatistics> mapRow(Result result, int rowNum) throws Exception {
|
||||
if (result.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
logger.debug("mapRow:{}", rowNum);
|
||||
final KeyValue[] keyList = result.raw();
|
||||
final byte[] rowKey = result.getRow();
|
||||
|
||||
final long timestamp = ApplicationMapStatisticsUtils.getTimestampFromRowKey(rowKey);
|
||||
Application caller = readCallerApplication(rowKey);
|
||||
final Buffer row = new FixedBuffer(result.getRow());
|
||||
final Application caller = readCallerApplication(row);
|
||||
final long timestamp = TimeUtils.recoveryCurrentTimeMillis(row.readLong());
|
||||
|
||||
// key is destApplicationName.
|
||||
final Map<LinkKey, LinkStatistics> linkStatisticsMap = new HashMap<LinkKey, LinkStatistics>();
|
||||
for (KeyValue kv : keyList) {
|
||||
for (KeyValue kv : result.raw()) {
|
||||
final byte[] family = kv.getFamily();
|
||||
if (Bytes.equals(family, HBaseTables.MAP_STATISTICS_CALLEE_CF_COUNTER)) {
|
||||
final byte[] qualifier = kv.getQualifier();
|
||||
@@ -63,12 +65,11 @@ public class MapStatisticsCallerMapper implements RowMapper<List<LinkStatistics>
|
||||
statistics.addCallData(caller.getName(), caller.getServiceTypeCode(), calleeHost, callee.getServiceTypeCode(), (isError) ? (short) -1 : histogramSlot, requestCount);
|
||||
} else if (Bytes.equals(family, HBaseTables.MAP_STATISTICS_CALLEE_CF_VER2_COUNTER)) {
|
||||
|
||||
final byte[] qualifier = kv.getQualifier();
|
||||
final Buffer buffer = new FixedBuffer(qualifier);
|
||||
final Buffer buffer = new OffsetFixedBuffer(kv.getBuffer(), kv.getQualifierOffset());
|
||||
Application callee = readCalleeApplication(buffer);
|
||||
|
||||
String calleeHost = buffer.readPrefixedString();
|
||||
short histogramSlot = buffer.readShort();
|
||||
|
||||
boolean isError = histogramSlot == (short) -1;
|
||||
|
||||
String callerAgentId = buffer.readPrefixedString();
|
||||
@@ -86,7 +87,7 @@ public class MapStatisticsCallerMapper implements RowMapper<List<LinkStatistics>
|
||||
|
||||
}
|
||||
|
||||
return new ArrayList<LinkStatistics>(linkStatisticsMap.values());
|
||||
return linkStatisticsMap.values();
|
||||
}
|
||||
|
||||
private long getValueToLong(KeyValue kv) {
|
||||
@@ -116,9 +117,9 @@ public class MapStatisticsCallerMapper implements RowMapper<List<LinkStatistics>
|
||||
return new Application(calleeApplicationName, calleeServiceyType);
|
||||
}
|
||||
|
||||
private Application readCallerApplication(byte[] row) {
|
||||
String callerApplicationName = ApplicationMapStatisticsUtils.getApplicationNameFromRowKey(row);
|
||||
short callerServiceType = ApplicationMapStatisticsUtils.getApplicationTypeFromRowKey(row);
|
||||
private Application readCallerApplication(Buffer row) {
|
||||
String callerApplicationName = row.read2PrefixedString();
|
||||
short callerServiceType = row.readShort();
|
||||
return new Application(callerApplicationName, callerServiceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.nhn.pinpoint.web.mapper;
|
||||
|
||||
import com.nhn.pinpoint.common.buffer.Buffer;
|
||||
import com.nhn.pinpoint.common.buffer.FixedBuffer;
|
||||
import com.nhn.pinpoint.common.hbase.HBaseTables;
|
||||
|
||||
import com.nhn.pinpoint.common.util.ApplicationStatisticsUtils;
|
||||
import com.nhn.pinpoint.common.util.TimeUtils;
|
||||
import com.nhn.pinpoint.web.vo.ResponseTime;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
@@ -22,7 +23,7 @@ public class ResponseTimeMapper implements RowMapper<ResponseTime> {
|
||||
return null;
|
||||
}
|
||||
final byte[] rowKey = result.getRow();
|
||||
ResponseTime responseTime = createRawResponseTime(rowKey);
|
||||
ResponseTime responseTime = createResponseTime(rowKey);
|
||||
|
||||
for (KeyValue keyValue : result.raw()) {
|
||||
if (!Bytes.equals(keyValue.getFamily(), HBaseTables.MAP_STATISTICS_SELF_CF_COUNTER)) {
|
||||
@@ -35,22 +36,22 @@ public class ResponseTimeMapper implements RowMapper<ResponseTime> {
|
||||
return responseTime;
|
||||
}
|
||||
|
||||
void recordColumn(ResponseTime responseTime, byte[] qualifier, byte[] value) {
|
||||
recordColumn(responseTime, qualifier, value, 0);
|
||||
}
|
||||
|
||||
|
||||
void recordColumn(ResponseTime responseTime, byte[] qualifier, byte[] value, int valueOffset) {
|
||||
short slotNumber = Bytes.toShort(qualifier);
|
||||
// agentId도 데이터로 같이 엮어야 함.
|
||||
String agentId = Bytes.toString(qualifier, 2, qualifier.length - 2);
|
||||
long count = Bytes.toLong(value, valueOffset);
|
||||
responseTime.getHistogram(agentId).addSample(slotNumber, count);
|
||||
responseTime.addResponseTime(agentId, slotNumber, count);
|
||||
}
|
||||
|
||||
private ResponseTime createRawResponseTime(byte[] rowKey) {
|
||||
|
||||
String applicationName = ApplicationStatisticsUtils.getApplicationNameFromRowKey(rowKey);
|
||||
short serviceType = ApplicationStatisticsUtils.getApplicationTypeFromRowKey(rowKey);
|
||||
long time = TimeUtils.recoveryCurrentTimeMillis(ApplicationStatisticsUtils.getTimestampFromRowKey(rowKey));
|
||||
return new ResponseTime(applicationName, serviceType, time);
|
||||
private ResponseTime createResponseTime(byte[] rowKey) {
|
||||
final Buffer row = new FixedBuffer(rowKey);
|
||||
String applicationName = row.read2PrefixedString();
|
||||
short serviceType = row.readShort();
|
||||
final long timestamp = TimeUtils.recoveryCurrentTimeMillis(row.readLong());
|
||||
return new ResponseTime(applicationName, serviceType, timestamp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ public class FilteredMapServiceImpl implements FilteredMapService {
|
||||
fillAdditionalInfo(stat);
|
||||
}
|
||||
|
||||
List<LinkStatistics> linkStatisticsList = new ArrayList<LinkStatistics>(linkStatMap.values());
|
||||
Collection<LinkStatistics> linkStatisticsList = linkStatMap.values();
|
||||
ApplicationMap map = new ApplicationMapBuilder().build(linkStatisticsList);
|
||||
map.setTimeSeriesStore(timeSeriesStore);
|
||||
map.appendResponseTime(mapHistogramSummary);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MapServiceImpl implements MapService {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
List<LinkStatistics> caller = mapStatisticsCallerDao.selectCaller(callerApplication, range);
|
||||
Collection<LinkStatistics> caller = mapStatisticsCallerDao.selectCaller(callerApplication, range);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found Caller. count={}, caller={}", caller.size(), callerApplication);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class MapServiceImpl implements MapService {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final List<LinkStatistics> callee = mapStatisticsCalleeDao.selectCallee(calleeApplication, range);
|
||||
final Collection<LinkStatistics> callee = mapStatisticsCalleeDao.selectCallee(calleeApplication, range);
|
||||
logger.debug("Found Callee. count={}, callee={}", callee.size(), calleeApplication);
|
||||
|
||||
final Set<LinkStatistics> calleeSet = new HashSet<LinkStatistics>();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nhn.pinpoint.web.vo;
|
||||
|
||||
import com.nhn.pinpoint.common.HistogramSchema;
|
||||
import com.nhn.pinpoint.common.bo.Span;
|
||||
import com.nhn.pinpoint.common.bo.SpanBo;
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.Histogram;
|
||||
|
||||
@@ -22,9 +21,9 @@ public class MapResponseHistogramSummary {
|
||||
|
||||
Histogram histogram = new Histogram(application.getServiceType());
|
||||
if (span.getErrCode() != 0) {
|
||||
histogram.addElapsedTime(HistogramSchema.ERROR_SLOT_TIME);
|
||||
histogram.addCallCountByElapsedTime(HistogramSchema.ERROR_SLOT_TIME);
|
||||
} else {
|
||||
histogram.addElapsedTime(span.getElapsed());
|
||||
histogram.addCallCountByElapsedTime(span.getElapsed());
|
||||
}
|
||||
responseHistogramSummary.addApplicationLevelHistogram(histogram);
|
||||
responseHistogramSummary.addAgentLevelHistogram(span.getAgentId(), histogram);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.nhn.pinpoint.web.vo;
|
||||
|
||||
import com.nhn.pinpoint.web.applicationmap.rawdata.Histogram;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -73,7 +74,7 @@ public class ResponseHistogramSummary {
|
||||
|
||||
private void createApplicationLevelResponseTime(List<ResponseTime> responseHistogram) {
|
||||
for (ResponseTime responseTime : responseHistogram) {
|
||||
final List<Histogram> histogramList = responseTime.getResponseHistogramList();
|
||||
final Collection<Histogram> histogramList = responseTime.getResponseHistogramList();
|
||||
for (Histogram histogram : histogramList) {
|
||||
this.addApplicationLevelHistogram(histogram);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,12 @@ public class ResponseTime {
|
||||
return newHistogram;
|
||||
}
|
||||
|
||||
public List<Histogram> getResponseHistogramList() {
|
||||
return new ArrayList<Histogram>(responseHistogramMap.values());
|
||||
public void addResponseTime(String agentId, short slotNumber, long count) {
|
||||
getHistogram(agentId).addCallCount(slotNumber, count);
|
||||
}
|
||||
|
||||
public Collection<Histogram> getResponseHistogramList() {
|
||||
return responseHistogramMap.values();
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, Histogram>> getAgentHistogram() {
|
||||
@@ -59,4 +63,5 @@ public class ResponseTime {
|
||||
", responseHistogramMap=" + responseHistogramMap +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@
|
||||
"slow" : ${link.histogram.verySlowCount},
|
||||
"histogram" : ${link.histogram.json},
|
||||
"targetHosts" : {
|
||||
<c:forEach items="${link.hostList.hostList}" var="host" varStatus="status2">
|
||||
"${host.host}" : {
|
||||
<c:forEach items="${link.targetList.hostList}" var="host" varStatus="status2">
|
||||
"${host.id}" : {
|
||||
"histogram" : ${host.histogram.json}
|
||||
}<c:if test="${!status2.last}">,</c:if>
|
||||
</c:forEach>
|
||||
|
||||
@@ -75,13 +75,13 @@
|
||||
"histogram" : ${link.histogram.json},
|
||||
"sourceHistogram" : {
|
||||
<c:forEach items="${link.sourceList.hostList}" var="linkAgentHistogram" varStatus="linkAgentHistogramStatus">
|
||||
"${linkAgentHistogram.host}" : ${linkAgentHistogram.histogram.json}
|
||||
"${linkAgentHistogram.id}" : ${linkAgentHistogram.histogram.json}
|
||||
<c:if test="${!linkAgentHistogramStatus.last}">,</c:if>
|
||||
</c:forEach>
|
||||
},
|
||||
"targetHosts" : {
|
||||
<c:forEach items="${link.hostList.hostList}" var="host" varStatus="status2">
|
||||
"${host.host}" : {
|
||||
<c:forEach items="${link.targetList.hostList}" var="host" varStatus="status2">
|
||||
"${host.id}" : {
|
||||
"histogram" : ${host.histogram.json}
|
||||
}<c:if test="${!status2.last}">,</c:if>
|
||||
</c:forEach>
|
||||
|
||||
@@ -119,8 +119,8 @@ ${record.hasException}
|
||||
"slow" : ${link.histogram.verySlowCount},
|
||||
"histogram" : ${link.histogram.json},
|
||||
"targetHosts" : {
|
||||
<c:forEach items="${link.hostList.hostList}" var="host" varStatus="status2">
|
||||
"${host.host}" : {
|
||||
<c:forEach items="${link.targetList.hostList}" var="host" varStatus="status2">
|
||||
"${host.id}" : {
|
||||
"histogram" : ${host.histogram.json}
|
||||
}<c:if test="${!status2.last}">,</c:if>
|
||||
</c:forEach>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.nhn.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.nhn.pinpoint.common.HistogramSchema;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class CallHistogramTest {
|
||||
@Test
|
||||
public void testDeepCopy() throws Exception {
|
||||
CallHistogram callHistogram = new CallHistogram("test", ServiceType.TOMCAT);
|
||||
callHistogram.getHistogram().addCallCount(HistogramSchema.ERROR_SLOT.getSlotTime(), 1);
|
||||
|
||||
CallHistogram copy = new CallHistogram(callHistogram);
|
||||
Assert.assertEquals(copy.getHistogram().getErrorCount(), 1);
|
||||
|
||||
callHistogram.getHistogram().addCallCount(HistogramSchema.ERROR_SLOT.getSlotTime(), 2);
|
||||
Assert.assertEquals(callHistogram.getHistogram().getErrorCount(), 3);
|
||||
|
||||
Assert.assertEquals(copy.getHistogram().getErrorCount(), 1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class HistogramTest {
|
||||
@Test
|
||||
public void testDeepCopy() throws Exception {
|
||||
Histogram original = new Histogram(ServiceType.TOMCAT);
|
||||
original.addSample((short) 1000, 100);
|
||||
original.addCallCount((short) 1000, 100);
|
||||
|
||||
|
||||
Histogram copy = new Histogram(ServiceType.TOMCAT);
|
||||
@@ -27,7 +27,7 @@ public class HistogramTest {
|
||||
copy.add(original);
|
||||
Assert.assertEquals(original.getFastCount(), copy.getFastCount());
|
||||
|
||||
copy.addSample((short) 1000, 100);
|
||||
copy.addCallCount((short) 1000, 100);
|
||||
Assert.assertEquals(original.getFastCount(), 100);
|
||||
Assert.assertEquals(copy.getFastCount(), 200);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class HistogramTest {
|
||||
@Test
|
||||
public void testJson() throws Exception {
|
||||
Histogram original = new Histogram(ServiceType.TOMCAT);
|
||||
original.addSample((short) 1000, 100);
|
||||
original.addCallCount((short) 1000, 100);
|
||||
|
||||
HashMap hashMap = objectMapper.readValue(original.getJson(), HashMap.class);
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.nhn.pinpoint.web.applicationmap.rawdata;
|
||||
|
||||
import com.nhn.pinpoint.common.HistogramSchema;
|
||||
import com.nhn.pinpoint.common.ServiceType;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author emeroad
|
||||
*/
|
||||
public class HostTest {
|
||||
@Test
|
||||
public void testDeepCopy() throws Exception {
|
||||
Host host = new Host("test", ServiceType.TOMCAT);
|
||||
host.getHistogram().addSample(HistogramSchema.ERROR_SLOT.getSlotTime(), 1);
|
||||
|
||||
Host copy = new Host(host);
|
||||
Assert.assertEquals(copy.getHistogram().getErrorCount(), 1);
|
||||
|
||||
host.getHistogram().addSample(HistogramSchema.ERROR_SLOT.getSlotTime(), 2);
|
||||
Assert.assertEquals(host.getHistogram().getErrorCount(), 3);
|
||||
|
||||
Assert.assertEquals(copy.getHistogram().getErrorCount(), 1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class ResponseTimeMapperTest {
|
||||
buffer.put(histogramSlotTime);
|
||||
buffer.put(Bytes.toBytes("agent"));
|
||||
|
||||
responseTimeMapper.recordColumn(responseTime, buffer.getBuffer(), Bytes.toBytes(1L));
|
||||
responseTimeMapper.recordColumn(responseTime, buffer.getBuffer(), Bytes.toBytes(1L), 0);
|
||||
|
||||
Histogram agentHistogram = responseTime.getHistogram("agent");
|
||||
long fastCount = agentHistogram.getFastCount();
|
||||
|
||||
Reference in New Issue
Block a user