use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method oneAcceptApplication.
@Test
public void oneAcceptApplication() {
// Given
ServiceType rpcClientServiceType = mock(ServiceType.class);
when(rpcClientServiceType.isRpcClient()).thenReturn(true);
String rpcUri = "accept.host/foo";
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application(rpcUri, rpcClientServiceType);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
Application expectedToApplication = new Application("ACCEPT_WAS", ServiceType.TEST_STAND_ALONE);
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Sets.newHashSet(new AcceptApplication(rpcUri, expectedToApplication)));
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey originalLinkKey = new LinkKey(fromApplication, toApplication);
Assert.assertNull(replacedLinkDataMap.getLinkData(originalLinkKey));
LinkKey replacedLinkKey = new LinkKey(fromApplication, expectedToApplication);
LinkData replacedLinkData = replacedLinkDataMap.getLinkData(replacedLinkKey);
Assert.assertNotNull(replacedLinkData);
Assert.assertEquals(fromApplication, replacedLinkData.getFromApplication());
Assert.assertEquals(expectedToApplication, replacedLinkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method queueWithoutAcceptApplication_shouldNotReplace.
@Test
public void queueWithoutAcceptApplication_shouldNotReplace() {
// Given
ServiceType queueServiceType = mock(ServiceType.class);
when(queueServiceType.isRpcClient()).thenReturn(false);
when(queueServiceType.isQueue()).thenReturn(true);
String queueName = "TestQueue";
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application(queueName, queueServiceType);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Collections.emptySet());
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey linkKey = new LinkKey(fromApplication, toApplication);
LinkData linkData = replacedLinkDataMap.getLinkData(linkKey);
Assert.assertEquals(fromApplication, linkData.getFromApplication());
Assert.assertEquals(toApplication, linkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method rpcWithoutAcceptApplication_shouldBeReplacedToUnknown.
@Test
public void rpcWithoutAcceptApplication_shouldBeReplacedToUnknown() {
// Given
ServiceType rpcClientServiceType = mock(ServiceType.class);
when(rpcClientServiceType.isRpcClient()).thenReturn(true);
String rpcUri = "accept.host/foo";
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application(rpcUri, rpcClientServiceType);
Application expectedToApplication = new Application(rpcUri, ServiceType.UNKNOWN);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Collections.emptySet());
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey originalLinkKey = new LinkKey(fromApplication, toApplication);
Assert.assertNull(replacedLinkDataMap.getLinkData(originalLinkKey));
LinkKey replacedLinkKey = new LinkKey(fromApplication, expectedToApplication);
LinkData replacedLinkData = replacedLinkDataMap.getLinkData(replacedLinkKey);
Assert.assertEquals(fromApplication, replacedLinkData.getFromApplication());
Assert.assertEquals(expectedToApplication, replacedLinkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap 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.LinkDataMap 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());
}
Aggregations