use of com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory in project pinpoint by naver.
the class ApplicationMapBuilderTest method runTest.
private void runTest(int callerDepth, int calleeDepth) {
Range range = Range.newRange(0, 1000);
int expectedNumNodes = ApplicationMapBuilderTestHelper.getExpectedNumNodes(calleeDepth, callerDepth);
int expectedNumLinks = ApplicationMapBuilderTestHelper.getExpectedNumLinks(calleeDepth, callerDepth);
NodeHistogramFactory nodeHistogramFactory_MapResponseDao = new DefaultNodeHistogramFactory(mapResponseNodeHistogramDataSource);
NodeHistogramFactory nodeHistogramFactory_ResponseHistogramBuilder = new DefaultNodeHistogramFactory(responseHistogramBuilderNodeHistogramDataSource);
ServerInstanceListFactory serverInstanceListFactory = new DefaultServerInstanceListFactory(agentInfoServerInstanceListDataSource);
LinkDataDuplexMap linkDataDuplexMap = ApplicationMapBuilderTestHelper.createLinkDataDuplexMap(calleeDepth, callerDepth);
ApplicationMapBuilder applicationMapBuilder = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, serialExecutor);
ApplicationMapBuilder applicationMapBuilder_parallelAppenders = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, parallelExecutor);
// test builder using MapResponseDao
ApplicationMap applicationMap_MapResponseDao = applicationMapBuilder.includeNodeHistogram(nodeHistogramFactory_MapResponseDao).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
ApplicationMap applicationMap_MapResponseDao_parallelAppenders = applicationMapBuilder_parallelAppenders.includeNodeHistogram(nodeHistogramFactory_MapResponseDao).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
Assert.assertEquals(expectedNumNodes, applicationMap_MapResponseDao.getNodes().size());
Assert.assertEquals(expectedNumNodes, applicationMap_MapResponseDao_parallelAppenders.getNodes().size());
Assert.assertEquals(expectedNumLinks, applicationMap_MapResponseDao.getLinks().size());
Assert.assertEquals(expectedNumLinks, applicationMap_MapResponseDao_parallelAppenders.getLinks().size());
ApplicationMapVerifier verifier_MapResponseDao = new ApplicationMapVerifier(applicationMap_MapResponseDao);
verifier_MapResponseDao.verify(applicationMap_MapResponseDao);
verifier_MapResponseDao.verify(applicationMap_MapResponseDao_parallelAppenders);
// test builder using ResponseHistogramBuilder
ApplicationMap applicationMap_ResponseHistogramBuilder = applicationMapBuilder.includeNodeHistogram(nodeHistogramFactory_ResponseHistogramBuilder).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
ApplicationMap applicationMap_ResponseHistogramBuilder_parallelAppenders = applicationMapBuilder_parallelAppenders.includeNodeHistogram(nodeHistogramFactory_ResponseHistogramBuilder).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
Assert.assertEquals(expectedNumNodes, applicationMap_ResponseHistogramBuilder.getNodes().size());
Assert.assertEquals(expectedNumNodes, applicationMap_ResponseHistogramBuilder_parallelAppenders.getNodes().size());
Assert.assertEquals(expectedNumLinks, applicationMap_ResponseHistogramBuilder.getLinks().size());
Assert.assertEquals(expectedNumLinks, applicationMap_ResponseHistogramBuilder_parallelAppenders.getLinks().size());
ApplicationMapVerifier verifier_ResponseHistogramBuilder = new ApplicationMapVerifier(applicationMap_ResponseHistogramBuilder);
verifier_ResponseHistogramBuilder.verify(applicationMap_ResponseHistogramBuilder);
verifier_ResponseHistogramBuilder.verify(applicationMap_ResponseHistogramBuilder_parallelAppenders);
}
use of com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory in project pinpoint by naver.
the class ResponseTimeHistogramServiceImpl method selectNodeHistogramData.
@Override
public NodeHistogramSummary selectNodeHistogramData(ResponseTimeHistogramServiceOption option) {
Node node = new Node(option.getApplication());
ServiceType applicationServiceType = option.getApplication().getServiceType();
List<Application> sourceApplications = option.getFromApplications();
List<Application> destinationApplications = option.getToApplications();
final NodeHistogramFactory nodeHistogramFactory = createNodeHistogramFactory();
final ServerInstanceListFactory serverInstanceListFactory = createServerInstanceListFactory(option);
if (applicationServiceType.isWas()) {
NodeHistogram nodeHistogram = nodeHistogramFactory.createWasNodeHistogram(option.getApplication(), option.getRange());
node.setNodeHistogram(nodeHistogram);
ServerInstanceList serverInstanceList = serverInstanceListFactory.createWasNodeInstanceList(node, option.getRange().getTo());
return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
} else if (applicationServiceType.isTerminal() || applicationServiceType.isUnknown() || applicationServiceType.isAlias()) {
if (sourceApplications.isEmpty()) {
return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
}
LinkDataMapProcessor destinationApplicationFilter = new DestinationApplicationFilter(option.getApplication());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, destinationApplicationFilter, LinkDataMapProcessor.NO_OP);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 1, 0);
ServerInstanceList serverInstanceList = serverInstanceListFactory.createEmptyNodeInstanceList();
if (applicationServiceType.isTerminal() || applicationServiceType.isAlias()) {
serverInstanceList = serverInstanceListFactory.createTerminalNodeInstanceList(node, linkDataDuplexMap);
}
NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
NodeHistogram nodeHistogram = nodeHistogramFactory.createTerminalNodeHistogram(option.getApplication(), option.getRange(), linkList);
return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
} else if (applicationServiceType.isQueue()) {
LinkDataMapProcessor destinationApplicationFilter = new DestinationApplicationFilter(option.getApplication());
if (sourceApplications.isEmpty()) {
if (destinationApplications.isEmpty()) {
return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
}
// Retrieve callers
LinkDataMapProcessor applicationFilter = new ApplicationFilter(option.getApplication());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, LinkDataMapProcessor.NO_OP, applicationFilter);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 0, 2);
LinkDataMap linkDataMap = destinationApplicationFilter.processLinkDataMap(linkDataDuplexMap.getTargetLinkDataMap(), option.getRange());
for (LinkData linkData : linkDataMap.getLinkDataList()) {
sourceApplications.add(linkData.getFromApplication());
}
}
// Check using from applications first for caller's link data
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, destinationApplicationFilter, LinkDataMapProcessor.NO_OP);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplications, option.getRange(), 1, 0);
ServerInstanceList serverInstanceList = serverInstanceListFactory.createQueueNodeInstanceList(node, linkDataDuplexMap);
NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
NodeHistogram nodeHistogram = nodeHistogramFactory.createQueueNodeHistogram(option.getApplication(), option.getRange(), linkList);
return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
} else if (applicationServiceType.isUser()) {
if (destinationApplications.isEmpty()) {
return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
}
LinkDataMapProcessor sourceApplicationFilter = new SourceApplicationFilter(option.getApplication());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, LinkDataMapProcessor.NO_OP, sourceApplicationFilter);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(destinationApplications, option.getRange(), 0, 1);
ServerInstanceList serverInstanceList = serverInstanceListFactory.createUserNodeInstanceList();
NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, option.getRange());
NodeHistogram nodeHistogram = nodeHistogramFactory.createUserNodeHistogram(option.getApplication(), option.getRange(), linkList);
return new NodeHistogramSummary(serverInstanceList, nodeHistogram);
} else {
return createEmptyNodeHistogramSummary(serverInstanceListFactory, option.getApplication(), option.getRange());
}
}
use of com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory in project pinpoint by naver.
the class ApplicationMapBuilder method build.
public ApplicationMap build(LinkDataDuplexMap linkDataDuplexMap, long timeoutMillis) {
Objects.requireNonNull(linkDataDuplexMap, "linkDataDuplexMap");
logger.info("Building application map");
NodeType nodeType = this.nodeType;
if (nodeType == null) {
nodeType = NodeType.DETAILED;
}
LinkType linkType = this.linkType;
if (linkType == null) {
linkType = LinkType.DETAILED;
}
NodeList nodeList = NodeListFactory.createNodeList(nodeType, linkDataDuplexMap);
LinkList linkList = LinkListFactory.createLinkList(linkType, nodeList, linkDataDuplexMap, range);
NodeHistogramFactory nodeHistogramFactory = this.nodeHistogramFactory;
if (nodeHistogramFactory == null) {
nodeHistogramFactory = new EmptyNodeHistogramFactory();
}
NodeHistogramAppender nodeHistogramAppender = nodeHistogramAppenderFactory.create(nodeHistogramFactory);
final TimeoutWatcher timeoutWatcher = new TimeoutWatcher(timeoutMillis);
nodeHistogramAppender.appendNodeHistogram(range, nodeList, linkList, timeoutWatcher.remainingTimeMillis());
ServerInstanceListFactory serverInstanceListFactory = this.serverInstanceListFactory;
if (serverInstanceListFactory == null) {
serverInstanceListFactory = new EmptyServerInstanceListFactory();
}
ServerInfoAppender serverInfoAppender = serverInfoAppenderFactory.create(serverInstanceListFactory);
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutWatcher.remainingTimeMillis());
MetricInfoAppender metricInfoAppender = metricInfoAppenderFactory.create();
metricInfoAppender.appendMetricInfo(range, nodeList, linkDataDuplexMap);
return new DefaultApplicationMap(range, nodeList, linkList);
}
use of com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory in project pinpoint by naver.
the class ApplicationMapBuilderTest method testEmptyCallData.
@Test
public void testEmptyCallData() {
Range range = Range.newRange(0, 1000);
LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
NodeHistogramFactory nodeHistogramFactory = new DefaultNodeHistogramFactory(mapResponseNodeHistogramDataSource);
ServerInstanceListFactory serverInstanceListFactory = new DefaultServerInstanceListFactory(agentInfoServerInstanceListDataSource);
ApplicationMapBuilder applicationMapBuilder = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, serialExecutor);
ApplicationMapBuilder applicationMapBuilder_parallelAppenders = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, parallelExecutor);
ApplicationMap applicationMap = applicationMapBuilder.includeNodeHistogram(nodeHistogramFactory).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
ApplicationMap applicationMap_parallelAppenders = applicationMapBuilder_parallelAppenders.includeNodeHistogram(nodeHistogramFactory).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
Assert.assertTrue(applicationMap.getNodes().isEmpty());
Assert.assertTrue(applicationMap.getNodes().isEmpty());
Assert.assertTrue(applicationMap_parallelAppenders.getNodes().isEmpty());
Assert.assertTrue(applicationMap.getLinks().isEmpty());
Assert.assertTrue(applicationMap.getLinks().isEmpty());
Assert.assertTrue(applicationMap_parallelAppenders.getLinks().isEmpty());
ApplicationMapVerifier verifier = new ApplicationMapVerifier(applicationMap);
verifier.verify(applicationMap);
verifier.verify(applicationMap_parallelAppenders);
}
use of com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory in project pinpoint by naver.
the class ApplicationMapBuilderTest method testNoCallData.
@Test
public void testNoCallData() {
Range range = Range.newRange(0, 1000);
Application application = ApplicationMapBuilderTestHelper.createApplicationFromDepth(0);
ServerInstanceListFactory serverInstanceListFactory = new DefaultServerInstanceListFactory(agentInfoServerInstanceListDataSource);
ApplicationMapBuilder applicationMapBuilder = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, serialExecutor);
ApplicationMapBuilder applicationMapBuilder_parallelAppenders = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, parallelExecutor);
ApplicationMap applicationMap = applicationMapBuilder.includeServerInfo(serverInstanceListFactory).build(application, buildTimeoutMillis);
ApplicationMap applicationMap_parallelAppenders = applicationMapBuilder_parallelAppenders.includeServerInfo(serverInstanceListFactory).build(application, buildTimeoutMillis);
Assert.assertEquals(1, applicationMap.getNodes().size());
Assert.assertEquals(1, applicationMap.getNodes().size());
Assert.assertEquals(1, applicationMap_parallelAppenders.getNodes().size());
Assert.assertEquals(0, applicationMap.getLinks().size());
Assert.assertEquals(0, applicationMap.getLinks().size());
Assert.assertEquals(0, applicationMap_parallelAppenders.getLinks().size());
ApplicationMapVerifier verifier = new ApplicationMapVerifier(applicationMap);
verifier.verify(applicationMap);
verifier.verify(applicationMap_parallelAppenders);
}
Aggregations