use of com.navercorp.pinpoint.web.applicationmap.nodes.Node in project pinpoint by naver.
the class ServerInfoAppenderTest method userNode.
@Test
public void userNode() {
// Given
Range range = Range.newRange(0, 60 * 1000);
NodeList nodeList = new NodeList();
LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
Node userNode = new Node(new Application("User", ServiceType.USER));
nodeList.addNode(userNode);
// When
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
// Then
Assert.assertEquals(0, userNode.getServerInstanceList().getInstanceCount());
verifyZeroInteractions(linkDataDuplexMap);
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.Node in project pinpoint by naver.
the class ServerInfoAppenderTest method wasNode.
@Test
public void wasNode() {
// Given
Range range = Range.newRange(0, 60 * 1000);
NodeList nodeList = new NodeList();
LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
Node wasNode = new Node(new Application("Was", ServiceType.TEST_STAND_ALONE));
nodeList.addNode(wasNode);
ServerInstanceList serverInstanceList = new ServerInstanceList();
when(serverInstanceListDataSource.createServerInstanceList(wasNode, range.getTo())).thenReturn(serverInstanceList);
// When
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
// Then
Assert.assertSame(serverInstanceList, wasNode.getServerInstanceList());
verifyZeroInteractions(linkDataDuplexMap);
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.Node in project pinpoint by naver.
the class ServerInfoAppenderTest method wasNodes.
@Test
public void wasNodes() {
// Given
Range range = Range.newRange(0, 60 * 1000);
NodeList nodeList = new NodeList();
LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
Node wasNode1 = new Node(new Application("Was1", ServiceType.TEST_STAND_ALONE));
nodeList.addNode(wasNode1);
Node wasNode2 = new Node(new Application("Was2", ServiceType.TEST_STAND_ALONE));
nodeList.addNode(wasNode2);
ServerInstanceList serverInstanceList1 = new ServerInstanceList();
when(serverInstanceListDataSource.createServerInstanceList(wasNode1, range.getTo())).thenReturn(serverInstanceList1);
ServerInstanceList serverInstanceList2 = new ServerInstanceList();
when(serverInstanceListDataSource.createServerInstanceList(wasNode2, range.getTo())).thenReturn(serverInstanceList2);
// When
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
// Then
Assert.assertSame(serverInstanceList1, wasNode1.getServerInstanceList());
Assert.assertSame(serverInstanceList2, wasNode2.getServerInstanceList());
verifyZeroInteractions(linkDataDuplexMap);
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.Node in project pinpoint by naver.
the class ServerInfoAppenderTest method unknownNode.
@Test
public void unknownNode() {
// Given
Range range = Range.newRange(0, 60 * 1000);
NodeList nodeList = new NodeList();
LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
Node unknownNode = new Node(new Application("Unknown", ServiceType.UNKNOWN));
nodeList.addNode(unknownNode);
// When
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
// Then
Assert.assertEquals(0, unknownNode.getServerInstanceList().getInstanceCount());
verifyZeroInteractions(linkDataDuplexMap);
}
use of com.navercorp.pinpoint.web.applicationmap.nodes.Node in project pinpoint by naver.
the class FilteredMapServiceImplTest method twoTier.
/**
* USER -> ROOT_APP -> APP_A -> CACHE
*/
@Test
public void twoTier() {
// Given
Range originalRange = Range.newRange(1000, 2000);
Range scanRange = Range.newRange(1000, 2000);
final TimeWindow timeWindow = new TimeWindow(originalRange, TimeWindowDownSampler.SAMPLER);
// root app span
long rootSpanId = RANDOM.nextLong();
long rootSpanStartTime = 1000L;
long rootSpanCollectorAcceptTime = 1210L;
int rootSpanElapsed = 200;
SpanBo rootSpan = new TestTraceUtils.SpanBuilder("ROOT_APP", "root-agent").spanId(rootSpanId).startTime(rootSpanStartTime).collectorAcceptTime(rootSpanCollectorAcceptTime).elapsed(rootSpanElapsed).build();
// app A span
long appASpanId = RANDOM.nextLong();
long appASpanStartTime = 1020L;
long appASpanCollectorAcceptTime = 1090L;
int appASpanElapsed = 160;
SpanBo appASpan = new TestTraceUtils.SpanBuilder("APP_A", "app-a").spanId(appASpanId).parentSpan(rootSpan).startTime(appASpanStartTime).collectorAcceptTime(appASpanCollectorAcceptTime).elapsed(appASpanElapsed).build();
// root app -> app A rpc span event
SpanEventBo rootRpcSpanEvent = new TestTraceUtils.RpcSpanEventBuilder("www.foo.com/bar", 10, 190).nextSpanId(appASpanId).build();
rootSpan.addSpanEvent(rootRpcSpanEvent);
// app A -> cache span event
int cacheStartElapsed = 20;
int cacheEndElapsed = 130;
SpanEventBo appACacheSpanEvent = new TestTraceUtils.CacheSpanEventBuilder("CacheName", "1.1.1.1", cacheStartElapsed, cacheEndElapsed).build();
appASpan.addSpanEvent(appACacheSpanEvent);
when(traceDao.selectAllSpans(anyList(), isNull())).thenReturn(Collections.singletonList(Arrays.asList(rootSpan, appASpan)));
// When
final FilteredMapServiceOption option = new FilteredMapServiceOption.Builder(Collections.emptyList(), originalRange, scanRange, 1, 1, Filter.acceptAllFilter(), 0).build();
ApplicationMap applicationMap = filteredMapService.selectApplicationMapWithScatterData(option);
// Then
Collection<Node> nodes = applicationMap.getNodes();
Assert.assertEquals(4, nodes.size());
for (Node node : nodes) {
Application application = node.getApplication();
if (application.getName().equals("ROOT_APP") && application.getServiceType().getCode() == TestTraceUtils.USER_TYPE_CODE) {
// USER node
NodeHistogram nodeHistogram = node.getNodeHistogram();
// histogram
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
assertHistogram(applicationHistogram, 1, 0, 0, 0, 0);
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
Assert.assertTrue(agentHistogramMap.isEmpty());
// time histogram
HistogramSchema histogramSchema = node.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(rootSpanCollectorAcceptTime), 1));
List<TimeViewModel> applicationTimeHistogram = nodeHistogram.getApplicationTimeHistogram(node.getTimeHistogramFormat());
assertTimeHistogram(applicationTimeHistogram, histogramSchema.getFastSlot(), expectedTimeCounts);
AgentResponseTimeViewModelList agentTimeHistogram = nodeHistogram.getAgentTimeHistogram(TimeHistogramFormat.V1);
Assert.assertTrue(agentTimeHistogram.getAgentResponseTimeViewModelList().isEmpty());
} else if (application.getName().equals("ROOT_APP") && application.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE) {
// ROOT_APP node
NodeHistogram nodeHistogram = node.getNodeHistogram();
// histogram
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
assertHistogram(applicationHistogram, 1, 0, 0, 0, 0);
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
assertAgentHistogram(agentHistogramMap, "root-agent", 1, 0, 0, 0, 0);
// time histogram
HistogramSchema histogramSchema = node.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(rootSpanCollectorAcceptTime), 1));
List<TimeViewModel> applicationTimeHistogram = nodeHistogram.getApplicationTimeHistogram(node.getTimeHistogramFormat());
assertTimeHistogram(applicationTimeHistogram, histogramSchema.getFastSlot(), expectedTimeCounts);
AgentResponseTimeViewModelList agentTimeHistogram = nodeHistogram.getAgentTimeHistogram(TimeHistogramFormat.V1);
assertAgentTimeHistogram(agentTimeHistogram.getAgentResponseTimeViewModelList(), "root-agent", histogramSchema.getFastSlot(), expectedTimeCounts);
} else if (application.getName().equals("APP_A") && application.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE) {
// APP_A node
NodeHistogram nodeHistogram = node.getNodeHistogram();
// histogram
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
assertHistogram(applicationHistogram, 1, 0, 0, 0, 0);
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
assertAgentHistogram(agentHistogramMap, "app-a", 1, 0, 0, 0, 0);
// time histogram
HistogramSchema histogramSchema = node.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(appASpanCollectorAcceptTime), 1));
List<TimeViewModel> applicationTimeHistogram = nodeHistogram.getApplicationTimeHistogram(node.getTimeHistogramFormat());
assertTimeHistogram(applicationTimeHistogram, histogramSchema.getFastSlot(), expectedTimeCounts);
AgentResponseTimeViewModelList agentTimeHistogram = nodeHistogram.getAgentTimeHistogram(TimeHistogramFormat.V1);
assertAgentTimeHistogram(agentTimeHistogram.getAgentResponseTimeViewModelList(), "app-a", histogramSchema.getFastSlot(), expectedTimeCounts);
} else if (application.getName().equals("CacheName") && application.getServiceType().getCode() == TestTraceUtils.CACHE_TYPE_CODE) {
// CACHE node
NodeHistogram nodeHistogram = node.getNodeHistogram();
// histogram
Histogram applicationHistogram = nodeHistogram.getApplicationHistogram();
assertHistogram(applicationHistogram, 0, 1, 0, 0, 0);
Map<String, Histogram> agentHistogramMap = nodeHistogram.getAgentHistogramMap();
assertAgentHistogram(agentHistogramMap, "1.1.1.1", 0, 1, 0, 0, 0);
// time histogram
HistogramSchema histogramSchema = node.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(appASpanStartTime + cacheStartElapsed), 1));
List<TimeViewModel> applicationTimeHistogram = nodeHistogram.getApplicationTimeHistogram(node.getTimeHistogramFormat());
assertTimeHistogram(applicationTimeHistogram, histogramSchema.getNormalSlot(), expectedTimeCounts);
AgentResponseTimeViewModelList agentTimeHistogram = nodeHistogram.getAgentTimeHistogram(TimeHistogramFormat.V1);
assertAgentTimeHistogram(agentTimeHistogram.getAgentResponseTimeViewModelList(), "1.1.1.1", histogramSchema.getNormalSlot(), expectedTimeCounts);
} else {
fail("Unexpected node : " + node);
}
}
Collection<Link> links = applicationMap.getLinks();
Assert.assertEquals(3, links.size());
for (Link link : links) {
Application fromApplication = link.getFrom().getApplication();
Application toApplication = link.getTo().getApplication();
if ((fromApplication.getName().equals("ROOT_APP") && fromApplication.getServiceType().getCode() == TestTraceUtils.USER_TYPE_CODE) && (toApplication.getName().equals("ROOT_APP") && toApplication.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE)) {
// histogram
Histogram histogram = link.getHistogram();
assertHistogram(histogram, 1, 0, 0, 0, 0);
// time histogram
List<TimeViewModel> linkApplicationTimeSeriesHistogram = link.getLinkApplicationTimeSeriesHistogram();
HistogramSchema targetHistogramSchema = toApplication.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(rootSpanCollectorAcceptTime), 1));
assertTimeHistogram(linkApplicationTimeSeriesHistogram, targetHistogramSchema.getFastSlot(), expectedTimeCounts);
} else if ((fromApplication.getName().equals("ROOT_APP") && fromApplication.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE) && (toApplication.getName().equals("APP_A") && toApplication.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE)) {
// histogram
Histogram histogram = link.getHistogram();
assertHistogram(histogram, 1, 0, 0, 0, 0);
// time histogram
List<TimeViewModel> linkApplicationTimeSeriesHistogram = link.getLinkApplicationTimeSeriesHistogram();
HistogramSchema targetHistogramSchema = toApplication.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(appASpanCollectorAcceptTime), 1));
assertTimeHistogram(linkApplicationTimeSeriesHistogram, targetHistogramSchema.getFastSlot(), expectedTimeCounts);
} else if ((fromApplication.getName().equals("APP_A") && fromApplication.getServiceType().getCode() == TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE) && (toApplication.getName().equals("CacheName") && toApplication.getServiceType().getCode() == TestTraceUtils.CACHE_TYPE_CODE)) {
// histogram
Histogram histogram = link.getHistogram();
assertHistogram(histogram, 0, 1, 0, 0, 0);
// time histogram
List<TimeViewModel> linkApplicationTimeSeriesHistogram = link.getLinkApplicationTimeSeriesHistogram();
HistogramSchema targetHistogramSchema = toApplication.getServiceType().getHistogramSchema();
List<ResponseTimeViewModel.TimeCount> expectedTimeCounts = Collections.singletonList(new ResponseTimeViewModel.TimeCount(timeWindow.refineTimestamp(appASpanStartTime + cacheStartElapsed), 1));
assertTimeHistogram(linkApplicationTimeSeriesHistogram, targetHistogramSchema.getNormalSlot(), expectedTimeCounts);
} else {
Assert.fail("Unexpected link : " + link);
}
}
}
Aggregations