diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMap.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMap.java index 80f108496..507b2f872 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMap.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMap.java @@ -30,11 +30,11 @@ public class ApplicationMap { } - public List getNodes() { + public Collection getNodes() { return this.nodeList.getNodeList(); } - public List getLinks() { + public Collection getLinks() { return this.linkList.getLinks(); } @@ -111,7 +111,7 @@ public class ApplicationMap { throw new NullPointerException("responseDataSource must not be null"); } - final List nodes = this.nodeList.getNodeList(); + final Collection 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 linkList = this.linkList.getLinks(); + Collection 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 linkList = this.linkList.getLinks(); + Collection linkList = this.linkList.getLinks(); for (Link link : linkList) { Node fromNode = link.getFrom(); String applicationName = fromNode.getApplicationName(); diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMapBuilder.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMapBuilder.java index b45f4d8e2..4d05ff459 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMapBuilder.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/ApplicationMapBuilder.java @@ -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) { + public ApplicationMap build(Collection 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())) { diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/Link.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/Link.java index 68a75f943..46f6752d6 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/Link.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/Link.java @@ -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 + "]"; } } diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/LinkList.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/LinkList.java index 3cc693e1b..32b7cb221 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/LinkList.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/LinkList.java @@ -10,8 +10,8 @@ import java.util.*; public class LinkList { private final Map linkMap = new HashMap(); - public List getLinks() { - return new ArrayList(this.linkMap.values()); + public Collection getLinks() { + return this.linkMap.values(); } public void buildLink(List relationList) { diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/Node.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/Node.java index ed73349f7..e60e936f9 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/Node.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/Node.java @@ -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 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 agentSet) { + Node(Application application, CallHistogramList callHistogramList, Set 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(); - 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(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); diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/NodeList.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/NodeList.java index a47d0c223..4ddb36625 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/NodeList.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/NodeList.java @@ -11,8 +11,8 @@ public class NodeList { private final Map nodeMap = new HashMap(); - public List getNodeList() { - return new ArrayList(this.nodeMap.values()); + public Collection getNodeList() { + return this.nodeMap.values(); } public void markSequence() { diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/ServerInstanceList.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/ServerInstanceList.java index 9f51ee80c..4a2c6a148 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/ServerInstanceList.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/ServerInstanceList.java @@ -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 find = serverInstanceList.get(hostName); if (find == null) { diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Host.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogram.java similarity index 59% rename from src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Host.java rename to src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogram.java index c81b9b730..11bec0db1 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Host.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogram.java @@ -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('}'); diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramList.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramList.java new file mode 100644 index 000000000..3a94f1cba --- /dev/null +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramList.java @@ -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 callHistogramMap = new HashMap(); + + public CallHistogramList() { + } + + public CallHistogramList(CallHistogramList copyCallHistogramList) { + if (copyCallHistogramList == null) { + throw new NullPointerException("copyCallHistogramList must not be null"); + } + + for (Map.Entry 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 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 + + '}'; + } +} diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Histogram.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Histogram.java index f1363ebb8..4212e45f5 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Histogram.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/Histogram.java @@ -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 diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostList.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostList.java deleted file mode 100644 index 9401a9a9b..000000000 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostList.java +++ /dev/null @@ -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 hostMap = new HashMap(); - - public HostList() { - } - - public HostList(HostList copyHostList) { - if (copyHostList == null) { - throw new NullPointerException("copyHostList must not be null"); - } - - for (Map.Entry 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 getHostList() { - final Collection values = hostMap.values(); - return new ArrayList(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 + - '}'; - } -} diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatistics.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatistics.java index 50a658abb..38a049897 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatistics.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatistics.java @@ -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(); } diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatisticsData.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatisticsData.java index 7536668ab..ea72700d1 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatisticsData.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/LinkStatisticsData.java @@ -7,16 +7,16 @@ import com.nhn.pinpoint.web.vo.Application; public class LinkStatisticsData { - private final List linkStatData; + private final Collection linkStatData; - public LinkStatisticsData(List linkStatData) { + public LinkStatisticsData(Collection linkStatData) { if (linkStatData == null) { throw new NullPointerException("linkStatData must not be null"); } this.linkStatData = linkStatData; } - public List getLinkStatData() { + public Collection getLinkStatData() { return linkStatData; } diff --git a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/RawCallDataMap.java b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/RawCallDataMap.java index aed1576de..ed9c5b84c 100644 --- a/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/RawCallDataMap.java +++ b/src/main/java/com/nhn/pinpoint/web/applicationmap/rawdata/RawCallDataMap.java @@ -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 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 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; } diff --git a/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCalleeDao.java b/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCalleeDao.java index 267a7b476..55c4510fa 100644 --- a/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCalleeDao.java +++ b/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCalleeDao.java @@ -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 selectCallee(Application calleeApplication, Range range); + public Collection selectCallee(Application calleeApplication, Range range); public List>> selectCalleeStatistics(Application callerApplication, Application calleeApplication, Range range); } diff --git a/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCallerDao.java b/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCallerDao.java index b99c99438..5aa413303 100644 --- a/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCallerDao.java +++ b/src/main/java/com/nhn/pinpoint/web/dao/MapStatisticsCallerDao.java @@ -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 selectCaller(Application callerApplication, Range range); + public Collection selectCaller(Application callerApplication, Range range); public List>> selectCallerStatistics(Application callerApplication, Application calleeApplication, Range range); } diff --git a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseAgentStatDao.java b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseAgentStatDao.java index 4150aaaed..833602fd1 100644 --- a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseAgentStatDao.java +++ b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseAgentStatDao.java @@ -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; diff --git a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCalleeDao.java b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCalleeDao.java index 8f7f105ee..c5a36805c 100644 --- a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCalleeDao.java +++ b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCalleeDao.java @@ -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> mapStatisticsCalleeMapper; + private RowMapper> mapStatisticsCalleeMapper; @Override - public List selectCallee(Application calleeApplication, Range range) { + public Collection 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> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLER, scan, mapStatisticsCalleeMapper); + List> 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 merge(List> foundListList) { + private Collection merge(List> foundListList) { final Map result = new HashMap(); - for (List foundList : foundListList) { + for (Collection 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(result.values()); + return result.values(); } diff --git a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCallerDao.java b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCallerDao.java index 0da1ec4f7..8c773e00f 100644 --- a/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCallerDao.java +++ b/src/main/java/com/nhn/pinpoint/web/dao/hbase/HbaseMapStatisticsCallerDao.java @@ -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> mapStatisticsCallerMapper; + private RowMapper> mapStatisticsCallerMapper; @Override - public List selectCaller(Application callerApplication, Range range) { + public Collection selectCaller(Application callerApplication, Range range) { Scan scan = createScan(callerApplication, range); - final List> foundListList = hbaseOperations2.find(HBaseTables.MAP_STATISTICS_CALLEE, scan, mapStatisticsCallerMapper); + final List> 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 merge(List> foundListList) { + private Collection merge(List> foundListList) { final Map result = new HashMap(); - for (List foundList : foundListList) { + for (Collection 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(result.values()); + return result.values(); } /** diff --git a/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCalleeMapper.java b/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCalleeMapper.java index 2af56f299..bdc6f06a2 100644 --- a/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCalleeMapper.java +++ b/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCalleeMapper.java @@ -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> { +public class MapStatisticsCalleeMapper implements RowMapper> { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Override - public List mapRow(Result result, int rowNum) throws Exception { + public Collection 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 linkStatisticsMap = new HashMap(); - - 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 } } - return new ArrayList(linkStatisticsMap.values()); + return linkStatisticsMap.values(); } private LinkStatistics getLinkStatics(Map linkStatisticsMap, Application callerApplication, Application calleeApplication, long timestamp) { @@ -82,9 +83,9 @@ public class MapStatisticsCalleeMapper implements RowMapper 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); } } diff --git a/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCallerMapper.java b/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCallerMapper.java index d81ae3e7a..bca9a0fdb 100644 --- a/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCallerMapper.java +++ b/src/main/java/com/nhn/pinpoint/web/mapper/MapStatisticsCallerMapper.java @@ -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> { +public class MapStatisticsCallerMapper implements RowMapper> { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Override - public List mapRow(Result result, int rowNum) throws Exception { + public Collection 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 linkStatisticsMap = new HashMap(); - 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 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 } - return new ArrayList(linkStatisticsMap.values()); + return linkStatisticsMap.values(); } private long getValueToLong(KeyValue kv) { @@ -116,9 +117,9 @@ public class MapStatisticsCallerMapper implements RowMapper 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); } } diff --git a/src/main/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapper.java b/src/main/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapper.java index 110058380..86d90ad7e 100644 --- a/src/main/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapper.java +++ b/src/main/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapper.java @@ -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 { 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 { 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); } + } diff --git a/src/main/java/com/nhn/pinpoint/web/service/FilteredMapServiceImpl.java b/src/main/java/com/nhn/pinpoint/web/service/FilteredMapServiceImpl.java index e55152f26..82f238357 100755 --- a/src/main/java/com/nhn/pinpoint/web/service/FilteredMapServiceImpl.java +++ b/src/main/java/com/nhn/pinpoint/web/service/FilteredMapServiceImpl.java @@ -239,7 +239,7 @@ public class FilteredMapServiceImpl implements FilteredMapService { fillAdditionalInfo(stat); } - List linkStatisticsList = new ArrayList(linkStatMap.values()); + Collection linkStatisticsList = linkStatMap.values(); ApplicationMap map = new ApplicationMapBuilder().build(linkStatisticsList); map.setTimeSeriesStore(timeSeriesStore); map.appendResponseTime(mapHistogramSummary); diff --git a/src/main/java/com/nhn/pinpoint/web/service/MapServiceImpl.java b/src/main/java/com/nhn/pinpoint/web/service/MapServiceImpl.java index 50dbe2ed0..a11416f01 100644 --- a/src/main/java/com/nhn/pinpoint/web/service/MapServiceImpl.java +++ b/src/main/java/com/nhn/pinpoint/web/service/MapServiceImpl.java @@ -74,7 +74,7 @@ public class MapServiceImpl implements MapService { return Collections.emptySet(); } - List caller = mapStatisticsCallerDao.selectCaller(callerApplication, range); + Collection 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 callee = mapStatisticsCalleeDao.selectCallee(calleeApplication, range); + final Collection callee = mapStatisticsCalleeDao.selectCallee(calleeApplication, range); logger.debug("Found Callee. count={}, callee={}", callee.size(), calleeApplication); final Set calleeSet = new HashSet(); diff --git a/src/main/java/com/nhn/pinpoint/web/vo/MapResponseHistogramSummary.java b/src/main/java/com/nhn/pinpoint/web/vo/MapResponseHistogramSummary.java index 0eb2653c7..d4e339b36 100644 --- a/src/main/java/com/nhn/pinpoint/web/vo/MapResponseHistogramSummary.java +++ b/src/main/java/com/nhn/pinpoint/web/vo/MapResponseHistogramSummary.java @@ -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); diff --git a/src/main/java/com/nhn/pinpoint/web/vo/ResponseHistogramSummary.java b/src/main/java/com/nhn/pinpoint/web/vo/ResponseHistogramSummary.java index 8da531cdd..82cdca33c 100644 --- a/src/main/java/com/nhn/pinpoint/web/vo/ResponseHistogramSummary.java +++ b/src/main/java/com/nhn/pinpoint/web/vo/ResponseHistogramSummary.java @@ -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 responseHistogram) { for (ResponseTime responseTime : responseHistogram) { - final List histogramList = responseTime.getResponseHistogramList(); + final Collection histogramList = responseTime.getResponseHistogramList(); for (Histogram histogram : histogramList) { this.addApplicationLevelHistogram(histogram); } diff --git a/src/main/java/com/nhn/pinpoint/web/vo/ResponseTime.java b/src/main/java/com/nhn/pinpoint/web/vo/ResponseTime.java index 7d05d0b81..e2a363367 100644 --- a/src/main/java/com/nhn/pinpoint/web/vo/ResponseTime.java +++ b/src/main/java/com/nhn/pinpoint/web/vo/ResponseTime.java @@ -42,8 +42,12 @@ public class ResponseTime { return newHistogram; } - public List getResponseHistogramList() { - return new ArrayList(responseHistogramMap.values()); + public void addResponseTime(String agentId, short slotNumber, long count) { + getHistogram(agentId).addCallCount(slotNumber, count); + } + + public Collection getResponseHistogramList() { + return responseHistogramMap.values(); } public Set> getAgentHistogram() { @@ -59,4 +63,5 @@ public class ResponseTime { ", responseHistogramMap=" + responseHistogramMap + '}'; } + } diff --git a/src/main/webapp/WEB-INF/views/applicationmap.filtered.jsp b/src/main/webapp/WEB-INF/views/applicationmap.filtered.jsp index c8aa6ceea..d031961a9 100644 --- a/src/main/webapp/WEB-INF/views/applicationmap.filtered.jsp +++ b/src/main/webapp/WEB-INF/views/applicationmap.filtered.jsp @@ -75,8 +75,8 @@ "slow" : ${link.histogram.verySlowCount}, "histogram" : ${link.histogram.json}, "targetHosts" : { - - "${host.host}" : { + + "${host.id}" : { "histogram" : ${host.histogram.json} }, diff --git a/src/main/webapp/WEB-INF/views/applicationmap.jsp b/src/main/webapp/WEB-INF/views/applicationmap.jsp index cd138e44d..0b08e0ecf 100644 --- a/src/main/webapp/WEB-INF/views/applicationmap.jsp +++ b/src/main/webapp/WEB-INF/views/applicationmap.jsp @@ -75,13 +75,13 @@ "histogram" : ${link.histogram.json}, "sourceHistogram" : { - "${linkAgentHistogram.host}" : ${linkAgentHistogram.histogram.json} + "${linkAgentHistogram.id}" : ${linkAgentHistogram.histogram.json} , }, "targetHosts" : { - - "${host.host}" : { + + "${host.id}" : { "histogram" : ${host.histogram.json} }, diff --git a/src/main/webapp/WEB-INF/views/transactionInfoJson.jsp b/src/main/webapp/WEB-INF/views/transactionInfoJson.jsp index a30454b5f..df8442a6f 100644 --- a/src/main/webapp/WEB-INF/views/transactionInfoJson.jsp +++ b/src/main/webapp/WEB-INF/views/transactionInfoJson.jsp @@ -119,8 +119,8 @@ ${record.hasException} "slow" : ${link.histogram.verySlowCount}, "histogram" : ${link.histogram.json}, "targetHosts" : { - - "${host.host}" : { + + "${host.id}" : { "histogram" : ${host.histogram.json} }, diff --git a/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramTest.java b/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramTest.java new file mode 100644 index 000000000..df3d83d57 --- /dev/null +++ b/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/CallHistogramTest.java @@ -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); + + } +} diff --git a/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HistogramTest.java b/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HistogramTest.java index c8619ac4e..393b7ae98 100644 --- a/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HistogramTest.java +++ b/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HistogramTest.java @@ -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); diff --git a/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostTest.java b/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostTest.java deleted file mode 100644 index bd58eda95..000000000 --- a/src/test/java/com/nhn/pinpoint/web/applicationmap/rawdata/HostTest.java +++ /dev/null @@ -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); - - } -} diff --git a/src/test/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapperTest.java b/src/test/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapperTest.java index c091a7339..376e2ba93 100644 --- a/src/test/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapperTest.java +++ b/src/test/java/com/nhn/pinpoint/web/mapper/ResponseTimeMapperTest.java @@ -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();