diff --git a/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/ResultsExtractor.java b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/ResultsExtractor.java index b9c8e5c363a4e..22d44bb1e0b1a 100644 --- a/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/ResultsExtractor.java +++ b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/ResultsExtractor.java @@ -19,7 +19,7 @@ /** * Callback handling scanner results. - * Implementations of this interface perform the actula work of extracting results from the + * Implementations of this interface perform the actual work of extracting results from the * {@link ResultScanner} but without having to worry about exception handling or resource management. * * @author Costin Leau diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/ApplicationMapBuilder.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/ApplicationMapBuilder.java index 7a597f3c27a01..faf204798b279 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/ApplicationMapBuilder.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/ApplicationMapBuilder.java @@ -102,7 +102,7 @@ public ApplicationMap build(Application application, long timeoutMillis) { Node node = new Node(nodeType, application); if (serverInstanceListFactory != null) { - ServerInstanceList runningInstances = serverInstanceListFactory.createWasNodeInstanceList(node, range.getToInstant()); + ServerInstanceList runningInstances = serverInstanceListFactory.createWasNodeInstanceList(node, range); if (runningInstances.getInstanceCount() > 0) { node.setServerInstanceList(runningInstances); nodeList.addNode(node); diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInfoAppender.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInfoAppender.java index 6ab72b73d7a7e..83c4fed601b89 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInfoAppender.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInfoAppender.java @@ -99,14 +99,13 @@ private CompletableFuture getServerInstanceListFuture(Range range, Node no CompletableFuture serverInstanceListFuture; ServiceType nodeServiceType = node.getServiceType(); if (nodeServiceType.isWas()) { - final Instant to = range.getToInstant(); serverInstanceListFuture = CompletableFuture.supplyAsync(new Supplier() { @Override public ServerInstanceList get() { if (Boolean.TRUE == stopSign.get()) { // Stop return serverInstanceListFactory.createEmptyNodeInstanceList(); } - return serverInstanceListFactory.createWasNodeInstanceList(node, to); + return serverInstanceListFactory.createWasNodeInstanceList(node, range); } }, executor); } else if (nodeServiceType.isTerminal() || nodeServiceType.isAlias()) { diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInstanceListFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInstanceListFactory.java index 04172fc2a176e..74a465a120fa4 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInstanceListFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/DefaultServerInstanceListFactory.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList; @@ -24,7 +25,6 @@ import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap; import com.navercorp.pinpoint.web.vo.Application; -import java.time.Instant; import java.util.Objects; /** @@ -39,8 +39,8 @@ public DefaultServerInstanceListFactory(ServerInstanceListDataSource serverInsta } @Override - public ServerInstanceList createWasNodeInstanceList(Node wasNode, Instant timestamp) { - return serverInstanceListDataSource.createServerInstanceList(wasNode, timestamp); + public ServerInstanceList createWasNodeInstanceList(Node wasNode, Range range) { + return serverInstanceListDataSource.createServerInstanceList(wasNode, range); } @Override diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/EmptyServerInstanceListFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/EmptyServerInstanceListFactory.java index 4cf82ff8adc91..859a8bbb71d38 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/EmptyServerInstanceListFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/EmptyServerInstanceListFactory.java @@ -16,19 +16,18 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList; import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap; -import java.time.Instant; - /** * @author HyunGil Jeong */ public class EmptyServerInstanceListFactory implements ServerInstanceListFactory { @Override - public ServerInstanceList createWasNodeInstanceList(Node wasNode, Instant timestamp) { + public ServerInstanceList createWasNodeInstanceList(Node wasNode, Range range) { return new ServerInstanceList(); } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInstanceListFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInstanceListFactory.java index b8ba9a3b765f0..2511be9cc84dd 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInstanceListFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInstanceListFactory.java @@ -16,18 +16,17 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList; import com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap; -import java.time.Instant; - /** * @author HyunGil Jeong */ public interface ServerInstanceListFactory { - ServerInstanceList createWasNodeInstanceList(Node wasNode, Instant timestamp); + ServerInstanceList createWasNodeInstanceList(Node wasNode, Range range); ServerInstanceList createTerminalNodeInstanceList(Node terminalNode, LinkDataDuplexMap linkDataDuplexMap); diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/StatisticsServerInstanceListFactory.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/StatisticsServerInstanceListFactory.java index 4de48b8d64242..622b7d1daafc1 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/StatisticsServerInstanceListFactory.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/StatisticsServerInstanceListFactory.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.appender.server.datasource.ServerInstanceListDataSource; import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; @@ -42,11 +43,11 @@ public StatisticsServerInstanceListFactory(ServerInstanceListDataSource serverIn } @Override - public ServerInstanceList createWasNodeInstanceList(Node wasNode, Instant timestamp) { - ServerInstanceList serverInstanceList = createWasNodeInstanceListFromHistogram(wasNode, timestamp); + public ServerInstanceList createWasNodeInstanceList(Node wasNode, Range range) { + ServerInstanceList serverInstanceList = createWasNodeInstanceListFromHistogram(wasNode, range.getToInstant()); if (serverInstanceList.getServerInstanceList().isEmpty()) { // When there is no transaction information, agentInfo information is used. - serverInstanceList = createWasNodeInstanceListFromAgentInfo(wasNode, timestamp); + serverInstanceList = createWasNodeInstanceListFromAgentInfo(wasNode, range); } return serverInstanceList; } @@ -74,8 +75,8 @@ ServerInstanceList createWasNodeInstanceListFromHistogram(Node wasNode, Instant return builder.build(); } - ServerInstanceList createWasNodeInstanceListFromAgentInfo(Node wasNode, Instant timestamp) { - return serverInstanceListDataSource.createServerInstanceList(wasNode, timestamp); + ServerInstanceList createWasNodeInstanceListFromAgentInfo(Node wasNode, Range range) { + return serverInstanceListDataSource.createServerInstanceList(wasNode, range); } @Override diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/AgentInfoServerInstanceListDataSource.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/AgentInfoServerInstanceListDataSource.java index 8e0911c547ce7..cbe12c288b1a5 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/AgentInfoServerInstanceListDataSource.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/AgentInfoServerInstanceListDataSource.java @@ -16,27 +16,26 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server.datasource; -import com.navercorp.pinpoint.common.server.util.AgentLifeCycleState; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerBuilder; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList; -import com.navercorp.pinpoint.web.applicationmap.histogram.Histogram; -import com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram; import com.navercorp.pinpoint.web.service.AgentInfoService; import com.navercorp.pinpoint.web.vo.AgentInfo; +import com.navercorp.pinpoint.web.vo.AgentInfoFilter; +import com.navercorp.pinpoint.web.vo.AgentInfoFilterChain; import com.navercorp.pinpoint.web.vo.AgentStatus; import com.navercorp.pinpoint.web.vo.AgentStatusQuery; import com.navercorp.pinpoint.web.vo.Application; +import com.navercorp.pinpoint.web.vo.DefaultAgentInfoFilter; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.springframework.util.CollectionUtils; import java.time.Instant; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -54,9 +53,10 @@ public AgentInfoServerInstanceListDataSource(AgentInfoService agentInfoService) this.agentInfoService = Objects.requireNonNull(agentInfoService, "agentInfoService"); } - public ServerInstanceList createServerInstanceList(Node node, Instant timestamp) { + public ServerInstanceList createServerInstanceList(Node node, Range range) { Objects.requireNonNull(node, "node"); - Objects.requireNonNull(timestamp, "timestamp"); + Objects.requireNonNull(range, "timestamp"); + Instant timestamp = range.getToInstant(); if (timestamp.toEpochMilli() < 0) { return new ServerInstanceList(); } @@ -69,7 +69,7 @@ public ServerInstanceList createServerInstanceList(Node node, Instant timestamp) } logger.debug("unfiltered agentInfos {}", agentInfos); - agentInfos = filterAgentInfos(agentInfos, timestamp, node); + agentInfos = filterAgentInfos(agentInfos, range, node); logger.debug("add agentInfos {} : {}", application, agentInfos); ServerBuilder builder = new ServerBuilder(); @@ -78,29 +78,21 @@ public ServerInstanceList createServerInstanceList(Node node, Instant timestamp) } // TODO Change to list of filters? - private Set filterAgentInfos(Set agentInfos, Instant timestamp, Node node) { - - final Map agentHistogramMap = getAgentHistogramMap(node); - + private Set filterAgentInfos(Set agentInfos, Range range, Node node) { Set filteredAgentInfos = new HashSet<>(); - List agentsToCheckStatus = new ArrayList<>(); - for (AgentInfo agentInfo : agentInfos) { - String agentId = agentInfo.getAgentId(); - if (agentHistogramMap.containsKey(agentId)) { - filteredAgentInfos.add(agentInfo); - } else { - agentsToCheckStatus.add(agentInfo); - } - } - AgentStatusQuery query = AgentStatusQuery.buildQuery(agentInfos, timestamp); + List agentsToCheckStatus = new ArrayList<>(agentInfos); + AgentStatusQuery query = AgentStatusQuery.buildQuery(agentInfos, range.getToInstant()); List> agentStatusList = agentInfoService.getAgentStatus(query); + AgentInfoFilter filter = new AgentInfoFilterChain( + new DefaultAgentInfoFilter(range.getFrom()) + ); int idx = 0; for (AgentInfo agentInfo : agentsToCheckStatus) { Optional agentStatus = agentStatusList.get(idx++); if (agentStatus.isPresent()) { - if (agentStatus.get().getState() == AgentLifeCycleState.RUNNING) { + if (filter.filter(agentInfo) == AgentInfoFilter.ACCEPT) { filteredAgentInfos.add(agentInfo); } } @@ -108,12 +100,4 @@ private Set filterAgentInfos(Set agentInfos, Instant times return filteredAgentInfos; } - - private Map getAgentHistogramMap(Node node) { - NodeHistogram nodeHistogram = node.getNodeHistogram(); - if (nodeHistogram != null) { - return nodeHistogram.getAgentHistogramMap(); - } - return Collections.emptyMap(); - } } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/ServerInstanceListDataSource.java b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/ServerInstanceListDataSource.java index aecf19a1758e4..0e6fbc4b2ed36 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/ServerInstanceListDataSource.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/applicationmap/appender/server/datasource/ServerInstanceListDataSource.java @@ -16,11 +16,10 @@ package com.navercorp.pinpoint.web.applicationmap.appender.server.datasource; +import com.navercorp.pinpoint.common.server.util.time.Range; import com.navercorp.pinpoint.web.applicationmap.nodes.Node; import com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList; -import java.time.Instant; - /** * @author emeroad * @author minwoo.jung @@ -28,5 +27,5 @@ */ public interface ServerInstanceListDataSource { - ServerInstanceList createServerInstanceList(Node node, Instant timestamp); + ServerInstanceList createServerInstanceList(Node node, Range range); } diff --git a/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java b/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java index 1920b0dd57ac8..778a13a69bced 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/authorization/controller/AgentInfoController.java @@ -89,7 +89,6 @@ public ApplicationAgentsList getAgentList( @RequestParam("from") long from, @RequestParam("to") long to) { AgentInfoFilter containerFilter = new AgentInfoFilterChain( - AgentInfoFilter::filterServer, new DefaultAgentInfoFilter(from) ); long timestamp = to; @@ -101,7 +100,6 @@ public ApplicationAgentsList getAgentList( @RequestParam("application") String applicationName, @RequestParam("timestamp") long timestamp) { AgentInfoFilter runningContainerFilter = new AgentInfoFilterChain( - AgentInfoFilter::filterServer, new DefaultAgentInfoFilter(Long.MAX_VALUE) ); return this.agentInfoService.getApplicationAgentsList(ApplicationAgentsList.GroupBy.HOST_NAME, runningContainerFilter, applicationName, timestamp); diff --git a/web/src/main/java/com/navercorp/pinpoint/web/service/ResponseTimeHistogramServiceImpl.java b/web/src/main/java/com/navercorp/pinpoint/web/service/ResponseTimeHistogramServiceImpl.java index 405f902f2fca2..8f1cf744163bf 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/service/ResponseTimeHistogramServiceImpl.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/service/ResponseTimeHistogramServiceImpl.java @@ -119,7 +119,7 @@ public NodeHistogramSummary selectNodeHistogramData(ResponseTimeHistogramService if (applicationServiceType.isWas()) { NodeHistogram nodeHistogram = nodeHistogramFactory.createWasNodeHistogram(option.getApplication(), option.getRange()); node.setNodeHistogram(nodeHistogram); - ServerInstanceList serverInstanceList = serverInstanceListFactory.createWasNodeInstanceList(node, option.getRange().getToInstant()); + ServerInstanceList serverInstanceList = serverInstanceListFactory.createWasNodeInstanceList(node, option.getRange()); return new NodeHistogramSummary(serverInstanceList, nodeHistogram); } else if (applicationServiceType.isTerminal() || applicationServiceType.isUnknown() || applicationServiceType.isAlias()) { if (sourceApplications.isEmpty()) { diff --git a/web/src/test/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInfoAppenderTest.java b/web/src/test/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInfoAppenderTest.java index e733ab27e14e4..64dfa2decf7a1 100644 --- a/web/src/test/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInfoAppenderTest.java +++ b/web/src/test/java/com/navercorp/pinpoint/web/applicationmap/appender/server/ServerInfoAppenderTest.java @@ -115,7 +115,7 @@ public void wasNode() { nodeList.addNode(wasNode); ServerInstanceList serverInstanceList = new ServerInstanceList(); - when(serverInstanceListDataSource.createServerInstanceList(wasNode, range.getToInstant())).thenReturn(serverInstanceList); + when(serverInstanceListDataSource.createServerInstanceList(wasNode, range)).thenReturn(serverInstanceList); // When serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis); // Then @@ -136,9 +136,9 @@ public void wasNodes() { nodeList.addNode(wasNode2); ServerInstanceList serverInstanceList1 = new ServerInstanceList(); - when(serverInstanceListDataSource.createServerInstanceList(wasNode1, range.getToInstant())).thenReturn(serverInstanceList1); + when(serverInstanceListDataSource.createServerInstanceList(wasNode1, range)).thenReturn(serverInstanceList1); ServerInstanceList serverInstanceList2 = new ServerInstanceList(); - when(serverInstanceListDataSource.createServerInstanceList(wasNode2, range.getToInstant())).thenReturn(serverInstanceList2); + when(serverInstanceListDataSource.createServerInstanceList(wasNode2, range)).thenReturn(serverInstanceList2); // When serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis); // Then