use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCaller_rpc.
@Test
public void testCaller_rpc() {
// APP_A -> APP_B via "www.test.com/test"
// Given
final Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
final Application APP_B = new Application("APP_B", ServiceType.TEST_STAND_ALONE);
final String rpcUri = "www.test.com/test";
final Application RPC_A_B = new Application(rpcUri, testRpcServiceType);
final Set<AcceptApplication> acceptApplications = new HashSet<AcceptApplication>() {
{
add(new AcceptApplication(rpcUri, APP_B));
}
};
int callCount_A_B = 10;
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(APP_A, "agentA", RPC_A_B, rpcUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(linkDataMap);
when(linkDataMapService.selectCalleeLinkDataMap(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_A), any(Range.class))).thenReturn(acceptApplications);
// When
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 1, 1);
// Then
Assert.assertEquals(1, linkData.size());
Assert.assertEquals(callCount_A_B, linkData.getTotalCount());
Assert.assertEquals(1, linkData.getSourceLinkDataList().size());
Assert.assertEquals(callCount_A_B, linkData.getSourceLinkDataMap().getTotalCount());
Assert.assertEquals(0, linkData.getTargetLinkDataList().size());
LinkData linkData_A_B = linkData.getSourceLinkData(new LinkKey(APP_A, APP_B));
Assert.assertEquals(callCount_A_B, linkData_A_B.getTotalCount());
List<LinkCallData> callDatas = new ArrayList<>(linkData_A_B.getLinkCallDataMap().getLinkDataList());
Assert.assertEquals(1, callDatas.size());
LinkCallData callData = callDatas.get(0);
Assert.assertEquals(rpcUri, callData.getTarget());
Assert.assertEquals(testRpcServiceType, callData.getTargetServiceType());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class BidirectionalLinkSelectorTest method testBidirectionalGraph.
@Test
public void testBidirectionalGraph() {
// APP_IN_IN -> APP_IN -> APP_A(selected) -> APP_OUT -> APP_OUT_OUT
// |-> APP_IN_OUT APP_OUT_IN -^
final Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
final Application APP_IN = new Application("APP_IN", ServiceType.TEST_STAND_ALONE);
final Application APP_IN_IN = new Application("APP_IN_IN", ServiceType.TEST_STAND_ALONE);
final Application APP_IN_OUT = new Application("APP_IN_OUT", ServiceType.TEST_STAND_ALONE);
final Application APP_OUT = new Application("APP_OUT", ServiceType.TEST_STAND_ALONE);
final Application APP_OUT_OUT = new Application("APP_OUT_OUT", ServiceType.TEST_STAND_ALONE);
final Application APP_OUT_IN = new Application("APP_OUT_IN", ServiceType.TEST_STAND_ALONE);
int callCount = 10;
LinkDataMap link_IN_to_A = new LinkDataMap();
link_IN_to_A.addLinkData(APP_IN, "agentIn", APP_A, "agentA", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
LinkDataMap link_IN_IN_to_IN = new LinkDataMap();
link_IN_IN_to_IN.addLinkData(APP_IN_IN, "agentInIn", APP_IN, "agentIn", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
LinkDataMap link_IN_to_IN_OUT = new LinkDataMap();
link_IN_to_IN_OUT.addLinkData(APP_IN, "agentIn", APP_IN_OUT, "agentInOut", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
LinkDataMap link_A_to_OUT = new LinkDataMap();
link_A_to_OUT.addLinkData(APP_A, "agentA", APP_OUT, "agentOut", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
LinkDataMap link_OUT_to_OUT_OUT = new LinkDataMap();
link_OUT_to_OUT_OUT.addLinkData(APP_OUT, "agentOut", APP_OUT_OUT, "agentOutOut", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
LinkDataMap link_OUT_IN_to_OUT = new LinkDataMap();
link_OUT_IN_to_OUT.addLinkData(APP_OUT_IN, "agentOutIn", APP_OUT, "agentOut", 1000, ServiceType.STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount);
when(linkDataMapService.selectCallerLinkDataMap(any(Application.class), any(Range.class))).thenAnswer(new Answer<LinkDataMap>() {
@Override
public LinkDataMap answer(InvocationOnMock invocation) throws Throwable {
Application callerApplication = invocation.getArgument(0);
if (callerApplication.equals(APP_A)) {
return link_A_to_OUT;
} else if (callerApplication.equals(APP_IN)) {
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkDataMap(link_IN_to_A);
linkDataMap.addLinkDataMap(link_IN_to_IN_OUT);
return linkDataMap;
} else if (callerApplication.equals(APP_IN_IN)) {
return link_IN_IN_to_IN;
} else if (callerApplication.equals(APP_OUT)) {
return link_OUT_to_OUT_OUT;
} else if (callerApplication.equals(APP_OUT_IN)) {
return link_OUT_IN_to_OUT;
}
return newEmptyLinkDataMap();
}
});
when(linkDataMapService.selectCalleeLinkDataMap(any(Application.class), any(Range.class))).thenAnswer(new Answer<LinkDataMap>() {
@Override
public LinkDataMap answer(InvocationOnMock invocation) throws Throwable {
Application calleeApplication = invocation.getArgument(0);
if (calleeApplication.equals(APP_A)) {
return link_IN_to_A;
} else if (calleeApplication.equals(APP_IN)) {
return link_IN_IN_to_IN;
} else if (calleeApplication.equals(APP_IN_OUT)) {
return link_IN_to_IN_OUT;
} else if (calleeApplication.equals(APP_OUT)) {
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkDataMap(link_A_to_OUT);
linkDataMap.addLinkDataMap(link_OUT_IN_to_OUT);
return linkDataMap;
} else if (calleeApplication.equals(APP_OUT_OUT)) {
return link_OUT_to_OUT_OUT;
}
return newEmptyLinkDataMap();
}
});
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(Collections.singletonList(APP_A), range, 2, 2);
// APP_IN_IN -> APP_IN (callee)
LinkKey linkKey_IN_IN_to_IN = new LinkKey(APP_IN_IN, APP_IN);
LinkData linkData_IN_IN_to_IN = linkDataDuplexMap.getTargetLinkData(linkKey_IN_IN_to_IN);
Assert.assertNotNull(linkData_IN_IN_to_IN);
Assert.assertEquals(callCount, linkData_IN_IN_to_IN.getTotalCount());
// APP_IN -> APP_A (callee)
LinkKey linkKey_IN_to_A = new LinkKey(APP_IN, APP_A);
LinkData linkData_IN_to_A = linkDataDuplexMap.getTargetLinkData(linkKey_IN_to_A);
Assert.assertNotNull(linkData_IN_to_A);
Assert.assertEquals(callCount, linkData_IN_to_A.getTotalCount());
// APP_IN (caller) -> APP_IN_OUT
LinkKey linkKey_IN_to_IN_OUT = new LinkKey(APP_IN, APP_IN_OUT);
LinkData linkData_IN_to_IN_OUT = linkDataDuplexMap.getSourceLinkData(linkKey_IN_to_IN_OUT);
Assert.assertNotNull(linkData_IN_to_IN_OUT);
Assert.assertEquals(callCount, linkData_IN_to_IN_OUT.getTotalCount());
// APP_A (caller) -> APP_OUT
LinkKey linkKey_A_to_OUT = new LinkKey(APP_A, APP_OUT);
LinkData linkData_A_to_OUT = linkDataDuplexMap.getSourceLinkData(linkKey_A_to_OUT);
Assert.assertNotNull(linkData_A_to_OUT);
Assert.assertEquals(callCount, linkData_A_to_OUT.getTotalCount());
// APP_OUT (caller) -> APP_OUT_OUT
LinkKey linkKey_OUT_to_OUT_OUT = new LinkKey(APP_OUT, APP_OUT_OUT);
LinkData linkData_OUT_to_OUT_OUT = linkDataDuplexMap.getSourceLinkData(linkKey_OUT_to_OUT_OUT);
Assert.assertNotNull(linkData_OUT_to_OUT_OUT);
Assert.assertEquals(callCount, linkData_OUT_to_OUT_OUT.getTotalCount());
// APP_OUT_IN -> APP_OUT (callee)
LinkKey linkKey_OUT_IN_to_OUT = new LinkKey(APP_OUT_IN, APP_OUT);
LinkData linkData_OUT_IN_to_OUT = linkDataDuplexMap.getTargetLinkData(linkKey_OUT_IN_to_OUT);
Assert.assertNotNull(linkData_OUT_IN_to_OUT);
Assert.assertEquals(callCount, linkData_OUT_IN_to_OUT.getTotalCount());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class FilteredMapBuilderTest method twoTier.
/**
* USER -> ROOT_APP -> APP_A -> CACHE
*/
@Test
public void twoTier() {
// Given
final Range range = Range.newRange(1, 200000);
final FilteredMapBuilder builder = new FilteredMapBuilder(applicationFactory, registry, range, VERSION);
// 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
builder.addTransaction(Arrays.asList(rootSpan, appASpan));
FilteredMap filteredMap = builder.build();
// Then
LinkDataDuplexMap linkDataDuplexMap = filteredMap.getLinkDataDuplexMap();
LinkDataMap sourceLinkDataMap = linkDataDuplexMap.getSourceLinkDataMap();
assertSourceLinkData(sourceLinkDataMap, "ROOT_APP", registry.findServiceType(TestTraceUtils.USER_TYPE_CODE), "ROOT_APP", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE));
assertSourceLinkData(sourceLinkDataMap, "ROOT_APP", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE), "www.foo.com/bar", registry.findServiceType(TestTraceUtils.RPC_TYPE_CODE));
assertSourceLinkData(sourceLinkDataMap, "APP_A", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE), "CacheName", registry.findServiceType(TestTraceUtils.CACHE_TYPE_CODE));
LinkDataMap targetLinkDataMap = linkDataDuplexMap.getTargetLinkDataMap();
assertTargetLinkData(targetLinkDataMap, "ROOT_APP", registry.findServiceType(TestTraceUtils.USER_TYPE_CODE), "ROOT_APP", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE));
assertTargetLinkData(targetLinkDataMap, "ROOT_APP", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE), "APP_A", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE));
ResponseHistograms responseHistograms = filteredMap.getResponseHistograms();
Application rootApplication = new Application("ROOT_APP", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE));
List<ResponseTime> rootAppResponseTimes = responseHistograms.getResponseTimeList(rootApplication);
Assert.assertNotNull(rootAppResponseTimes);
Assert.assertEquals(1, rootAppResponseTimes.size());
Application applicationA = new Application("APP_A", registry.findServiceType(TestTraceUtils.TEST_STAND_ALONE_TYPE_CODE));
List<ResponseTime> appAResponseTimes = responseHistograms.getResponseTimeList(applicationA);
Assert.assertNotNull(appAResponseTimes);
Assert.assertEquals(1, appAResponseTimes.size());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class MapServiceImpl method selectApplicationMap.
/**
* Used in the main UI - draws the server map by querying the timeslot by time.
*/
@Override
public ApplicationMap selectApplicationMap(Application sourceApplication, Range range, SearchOption searchOption) {
if (sourceApplication == null) {
throw new NullPointerException("sourceApplication must not be null");
}
if (range == null) {
throw new NullPointerException("range must not be null");
}
logger.debug("SelectApplicationMap");
StopWatch watch = new StopWatch("ApplicationMap");
watch.start("ApplicationMap Hbase Io Fetch(Caller,Callee) Time");
LinkSelector linkSelector = new BFSLinkSelector(this.mapStatisticsCallerDao, this.mapStatisticsCalleeDao, hostApplicationMapDao, serverMapDataFilter);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(sourceApplication, range, searchOption);
watch.stop();
watch.start("ApplicationMap MapBuilding(Response) Time");
ApplicationMapBuilder builder = new ApplicationMapBuilder(range);
ApplicationMap map = builder.build(linkDataDuplexMap, agentInfoService, this.mapResponseDao);
if (map.getNodes().isEmpty()) {
map = builder.build(sourceApplication, agentInfoService);
}
watch.stop();
if (logger.isInfoEnabled()) {
logger.info("ApplicationMap BuildTime: {}", watch.prettyPrint());
}
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 MapServiceImpl method selectApplicationMap.
/**
* Used in the main UI - draws the server map by querying the timeslot by time.
*/
@Override
public ApplicationMap selectApplicationMap(MapServiceOption option) {
logger.debug("SelectApplicationMap");
StopWatch watch = new StopWatch("ApplicationMap");
watch.start("ApplicationMap Hbase Io Fetch(Caller,Callee) Time");
final SearchOption searchOption = option.getSearchOption();
LinkSelectorType linkSelectorType = searchOption.getLinkSelectorType();
int callerSearchDepth = searchOption.getCallerSearchDepth();
int calleeSearchDepth = searchOption.getCalleeSearchDepth();
LinkDataMapProcessor callerLinkDataMapProcessor = LinkDataMapProcessor.NO_OP;
if (searchOption.isWasOnly()) {
callerLinkDataMapProcessor = new WasOnlyProcessor();
}
LinkDataMapProcessor calleeLinkDataMapProcessor = LinkDataMapProcessor.NO_OP;
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(linkSelectorType, callerLinkDataMapProcessor, calleeLinkDataMapProcessor);
LinkDataDuplexMap linkDataDuplexMap = linkSelector.select(Collections.singletonList(option.getSourceApplication()), option.getRange(), callerSearchDepth, calleeSearchDepth);
watch.stop();
if (linkDataLimiter.excess(linkDataDuplexMap.getTotalCount())) {
throw new RuntimeException("Too many link data. Reduce the values of the Inbound/outbound or do not select the bidirectional option. limiter=" + linkDataLimiter.toString(linkDataDuplexMap.getTotalCount()));
}
watch.start("ApplicationMap MapBuilding(Response) Time");
ApplicationMapBuilder builder = createApplicationMapBuilder(option);
ApplicationMap map = builder.build(linkDataDuplexMap, buildTimeoutMillis);
if (map.getNodes().isEmpty()) {
map = builder.build(option.getSourceApplication(), buildTimeoutMillis);
}
watch.stop();
if (logger.isInfoEnabled()) {
logger.info("ApplicationMap BuildTime: {}", watch.prettyPrint());
}
if (serverMapDataFilter != null) {
map = serverMapDataFilter.dataFiltering(map);
}
return map;
}
Aggregations