use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class FilteredMapServiceImpl method createMap.
private ApplicationMap createMap(Range range, Range scanRange, List<List<SpanBo>> filterList) {
// TODO inject TimeWindow from elsewhere
final TimeWindow window = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
final LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
final ResponseHistogramBuilder mapHistogramSummary = new ResponseHistogramBuilder(range);
/*
* Convert to statistical data
*/
for (List<SpanBo> transaction : filterList) {
final Map<Long, SpanBo> transactionSpanMap = checkDuplicatedSpanId(transaction);
for (SpanBo span : transaction) {
final Application parentApplication = createParentApplication(span, transactionSpanMap);
final Application spanApplication = this.applicationFactory.createApplication(span.getApplicationId(), span.getApplicationServiceType());
// records the Span's response time statistics
recordSpanResponseTime(spanApplication, span, mapHistogramSummary, span.getCollectorAcceptTime());
if (!spanApplication.getServiceType().isRecordStatistics() || spanApplication.getServiceType().isRpcClient()) {
// span's serviceType is probably not set correctly
logger.warn("invalid span application:{}", spanApplication);
continue;
}
final short slotTime = getHistogramSlotTime(span, spanApplication.getServiceType());
// might need to reconsider using collector's accept time for link statistics.
// we need to convert to time window's timestamp. If not, it may lead to OOM due to mismatch in timeslots.
long timestamp = window.refineTimestamp(span.getCollectorAcceptTime());
if (parentApplication.getServiceType() == ServiceType.USER) {
// Outbound data
if (logger.isTraceEnabled()) {
logger.trace("span user:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
}
final LinkDataMap sourceLinkData = linkDataDuplexMap.getSourceLinkDataMap();
sourceLinkData.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
if (logger.isTraceEnabled()) {
logger.trace("span target user:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
}
// Inbound data
final LinkDataMap targetLinkDataMap = linkDataDuplexMap.getTargetLinkDataMap();
targetLinkDataMap.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
} else {
// Inbound data
if (logger.isTraceEnabled()) {
logger.trace("span target parent:{} {} -> span:{} {}", parentApplication, span.getAgentId(), spanApplication, span.getAgentId());
}
final LinkDataMap targetLinkDataMap = linkDataDuplexMap.getTargetLinkDataMap();
targetLinkDataMap.addLinkData(parentApplication, span.getAgentId(), spanApplication, span.getAgentId(), timestamp, slotTime, 1);
}
if (serverMapDataFilter != null && serverMapDataFilter.filter(spanApplication)) {
continue;
}
addNodeFromSpanEvent(span, window, linkDataDuplexMap, transactionSpanMap);
}
}
ApplicationMapBuilder applicationMapBuilder = new ApplicationMapBuilder(range);
mapHistogramSummary.build();
ApplicationMap map = applicationMapBuilder.build(linkDataDuplexMap, agentInfoService, mapHistogramSummary);
if (serverMapDataFilter != null) {
map = serverMapDataFilter.dataFiltering(map);
}
return map;
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class ResponseTimeHistogramServiceImpl method selectLinkHistogramData.
@Override
public LinkHistogramSummary selectLinkHistogramData(Application fromApplication, Application toApplication, Range range) {
Objects.requireNonNull(fromApplication, "fromApplication");
Objects.requireNonNull(toApplication, "toApplication");
Objects.requireNonNull(range, "range");
LinkDataDuplexMap linkDataDuplexMap;
ServiceType fromApplicationServiceType = fromApplication.getServiceType();
CreateType createType = CreateType.Target;
// For user or queue originating links, we must scan using to applications
if (fromApplicationServiceType.isUser() || fromApplicationServiceType.isQueue()) {
createType = CreateType.Source;
LinkDataMapProcessor sourceApplicationFilter = new SourceApplicationFilter(fromApplication);
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, LinkDataMapProcessor.NO_OP, sourceApplicationFilter);
linkDataDuplexMap = linkSelector.select(Collections.singletonList(toApplication), range, 0, 1);
} else {
LinkDataMapProcessor destinationApplication = new DestinationApplicationFilter(toApplication);
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(LinkSelectorType.UNIDIRECTIONAL, destinationApplication, LinkDataMapProcessor.NO_OP);
linkDataDuplexMap = linkSelector.select(Collections.singletonList(fromApplication), range, 1, 0);
}
NodeList nodeList = NodeListFactory.createNodeList(NodeType.DETAILED, linkDataDuplexMap);
LinkList linkList = LinkListFactory.createLinkList(LinkType.DETAILED, nodeList, linkDataDuplexMap, range);
LinkKey linkKey = new LinkKey(fromApplication, toApplication);
Link link = linkList.getLink(linkKey);
if (link == null) {
return createEmptyLinkHistogramSummary(createType, fromApplication, toApplication, range);
}
return new LinkHistogramSummary(link);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class UnidirectionalLinkSelector method select.
@Override
public LinkDataDuplexMap select(List<Application> sourceApplications, Range range, int callerSearchDepth, int calleeSearchDepth) {
logger.debug("Creating link data map for {}", sourceApplications);
final SearchDepth callerDepth = new SearchDepth(callerSearchDepth);
final SearchDepth calleeDepth = new SearchDepth(calleeSearchDepth);
LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
List<Application> applications = filterApplications(sourceApplications);
List<Application> outboundApplications = Collections.unmodifiableList(applications);
LinkSelectContext outboundLinkSelectContext = new LinkSelectContext(range, callerDepth, new SearchDepth(0), linkVisitChecker);
List<Application> inboundApplications = Collections.unmodifiableList(applications);
LinkSelectContext inboundLinkSelectContext = new LinkSelectContext(range, new SearchDepth(0), calleeDepth, linkVisitChecker);
while (!outboundApplications.isEmpty() || !inboundApplications.isEmpty()) {
logger.info("outbound depth search start. callerDepth:{}, calleeDepth:{}, size:{}, nodes:{}", outboundLinkSelectContext.getCallerDepth(), outboundLinkSelectContext.getCalleeDepth(), outboundApplications.size(), outboundApplications);
LinkDataDuplexMap outboundMap = applicationsMapCreator.createLinkDataDuplexMap(outboundApplications, outboundLinkSelectContext);
logger.info("outbound depth search end. callerDepth:{}, calleeDepth:{}", outboundLinkSelectContext.getCallerDepth(), outboundLinkSelectContext.getCalleeDepth());
logger.info("inbound depth search start. callerDepth:{}, calleeDepth:{}, size:{}, nodes:{}", inboundLinkSelectContext.getCallerDepth(), inboundLinkSelectContext.getCalleeDepth(), inboundApplications.size(), inboundApplications);
LinkDataDuplexMap inboundMap = applicationsMapCreator.createLinkDataDuplexMap(inboundApplications, inboundLinkSelectContext);
logger.info("inbound depth search end. callerDepth:{}, calleeDepth:{}", inboundLinkSelectContext.getCallerDepth(), inboundLinkSelectContext.getCalleeDepth());
linkDataDuplexMap.addLinkDataDuplexMap(outboundMap);
linkDataDuplexMap.addLinkDataDuplexMap(inboundMap);
outboundApplications = filterApplications(outboundLinkSelectContext.getNextApplications());
inboundApplications = filterApplications(inboundLinkSelectContext.getNextApplications());
outboundLinkSelectContext = outboundLinkSelectContext.advance();
inboundLinkSelectContext = inboundLinkSelectContext.advance();
}
return virtualLinkHandler.processVirtualLinks(linkDataDuplexMap, linkVisitChecker, range);
}
Aggregations