use of com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram in project pinpoint by naver.
the class ApplicationMapBuilder method appendNodeResponseTime.
public void appendNodeResponseTime(NodeList nodeList, LinkList linkList, NodeHistogramDataSource nodeHistogramDataSource) {
if (nodeHistogramDataSource == null) {
throw new NullPointerException("nodeHistogramDataSource must not be null");
}
final Collection<Node> nodes = nodeList.getNodeList();
for (Node node : nodes) {
final ServiceType nodeType = node.getServiceType();
if (nodeType.isWas()) {
// for WAS nodes, set their own response time histogram
final Application wasNode = node.getApplication();
final NodeHistogram nodeHistogram = nodeHistogramDataSource.createNodeHistogram(wasNode);
node.setNodeHistogram(nodeHistogram);
} else if (nodeType.isTerminal() || nodeType.isUnknown()) {
final NodeHistogram nodeHistogram = createTerminalNodeHistogram(node, linkList);
node.setNodeHistogram(nodeHistogram);
} else if (nodeType.isQueue()) {
// Virtual queue node - queues with agent installed will be handled above as a WAS node
final NodeHistogram nodeHistogram = createTerminalNodeHistogram(node, linkList);
node.setNodeHistogram(nodeHistogram);
} else if (nodeType.isUser()) {
// for User nodes, find its source link and create the histogram
Application userNode = node.getApplication();
final NodeHistogram nodeHistogram = new NodeHistogram(userNode, range);
final List<Link> fromLink = linkList.findFromLink(userNode);
if (fromLink.size() > 1) {
// used first(0) link.
logger.warn("Invalid from UserNode:{}", linkList.getLinkList());
} else if (fromLink.isEmpty()) {
logger.warn("from UserNode not found:{}", userNode);
continue;
}
final Link sourceLink = fromLink.get(0);
nodeHistogram.setApplicationHistogram(sourceLink.getHistogram());
ApplicationTimeHistogram histogramData = sourceLink.getTargetApplicationTimeSeriesHistogramData();
nodeHistogram.setApplicationTimeHistogram(histogramData);
node.setNodeHistogram(nodeHistogram);
} else {
// dummy data
NodeHistogram dummy = new NodeHistogram(node.getApplication(), range);
node.setNodeHistogram(dummy);
}
}
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram in project pinpoint by naver.
the class ApplicationTimeHistogramTest method testViewModel.
@Test
public void testViewModel() throws IOException {
Application app = new Application("test", ServiceType.STAND_ALONE);
ApplicationTimeHistogramBuilder builder = new ApplicationTimeHistogramBuilder(app, new Range(0, 10 * 6000));
List<ResponseTime> responseHistogramList = createResponseTime(app);
ApplicationTimeHistogram histogram = builder.build(responseHistogramList);
List<ResponseTimeViewModel> viewModel = histogram.createViewModel();
logger.debug("{}", viewModel);
ObjectWriter writer = mapper.writer();
String s = writer.writeValueAsString(viewModel);
logger.debug(s);
}
use of com.navercorp.pinpoint.web.applicationmap.histogram.ApplicationTimeHistogram in project pinpoint by naver.
the class ApplicationMapBuilder method createTerminalNodeHistogram.
private NodeHistogram createTerminalNodeHistogram(Node node, LinkList linkList) {
// for Terminal nodes, add all links pointing to iself and create the histogram
final Application nodeApplication = node.getApplication();
final NodeHistogram nodeHistogram = new NodeHistogram(nodeApplication, range);
// create applicationHistogram
final List<Link> toLinkList = linkList.findToLink(nodeApplication);
final Histogram applicationHistogram = new Histogram(node.getServiceType());
for (Link link : toLinkList) {
applicationHistogram.add(link.getHistogram());
}
nodeHistogram.setApplicationHistogram(applicationHistogram);
// create applicationTimeHistogram
LinkCallDataMap linkCallDataMap = new LinkCallDataMap();
for (Link link : toLinkList) {
LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
linkCallDataMap.addLinkDataMap(sourceLinkCallDataMap);
}
ApplicationTimeHistogramBuilder builder = new ApplicationTimeHistogramBuilder(nodeApplication, range);
ApplicationTimeHistogram applicationTimeHistogram = builder.build(linkCallDataMap.getLinkDataList());
nodeHistogram.setApplicationTimeHistogram(applicationTimeHistogram);
// for Terminal nodes, create AgentLevel histogram
if (nodeApplication.getServiceType().isTerminal() || nodeApplication.getServiceType().isQueue()) {
final Map<String, Histogram> agentHistogramMap = new HashMap<>();
for (Link link : toLinkList) {
LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
AgentHistogramList targetList = sourceLinkCallDataMap.getTargetList();
for (AgentHistogram histogram : targetList.getAgentHistogramList()) {
Histogram find = agentHistogramMap.get(histogram.getId());
if (find == null) {
find = new Histogram(histogram.getServiceType());
agentHistogramMap.put(histogram.getId(), find);
}
find.add(histogram.getHistogram());
}
nodeHistogram.setAgentHistogramMap(agentHistogramMap);
}
}
LinkCallDataMap mergeSource = new LinkCallDataMap();
for (Link link : toLinkList) {
LinkCallDataMap sourceLinkCallDataMap = link.getSourceLinkCallDataMap();
mergeSource.addLinkDataMap(sourceLinkCallDataMap);
}
AgentTimeHistogramBuilder agentTimeBuilder = new AgentTimeHistogramBuilder(nodeApplication, range);
AgentTimeHistogram agentTimeHistogram = agentTimeBuilder.buildTarget(mergeSource);
nodeHistogram.setAgentTimeHistogram(agentTimeHistogram);
return nodeHistogram;
}
Aggregations