use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class LinkSelectorTestBase method testVirtual_mixed.
@Test
public void testVirtual_mixed() {
// APP_A ---> APP_B via "api.test.com/test", "b.test.com/test"
// |-> APP_C via "api.test.com/test", "c.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 Application APP_C = new Application("APP_C", ServiceType.TEST_STAND_ALONE);
final String proxyUri = "api.test.com/test";
final String bUri = "b.test.com/test";
final String cUri = "c.test.com/test";
final Application RPC_PROXY = new Application(proxyUri, testRpcServiceType);
final Application RPC_B = new Application(bUri, testRpcServiceType);
final Application RPC_C = new Application(cUri, testRpcServiceType);
final Set<AcceptApplication> acceptApplications = Sets.newHashSet(new AcceptApplication(proxyUri, APP_B), new AcceptApplication(proxyUri, APP_C), new AcceptApplication(bUri, APP_B), new AcceptApplication(cUri, APP_C));
int callCount_proxy_B = 10;
int callCount_proxy_C = 20;
int callCount_B = 4;
int callCount_C = 7;
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(APP_A, "agentA", RPC_PROXY, proxyUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_proxy_B + callCount_proxy_C);
linkDataMap.addLinkData(APP_A, "agentA", RPC_B, bUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B);
linkDataMap.addLinkData(APP_A, "agentA", RPC_C, cUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_C);
LinkDataMap calleeLinkDataMap_B = new LinkDataMap();
calleeLinkDataMap_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_proxy_B + callCount_B);
LinkDataMap calleeLinkDataMap_C = new LinkDataMap();
calleeLinkDataMap_C.addLinkData(APP_A, "agentA", APP_C, "agentC", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_proxy_C + callCount_C);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(linkDataMap);
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(calleeLinkDataMap_B);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(calleeLinkDataMap_C);
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
assertSource_Target_TotalCount("APP_A -> APP_B", linkData, new LinkKey(APP_A, APP_B), callCount_proxy_B + callCount_B);
assertSource_Target_TotalCount("APP_A -> APP_C", linkData, new LinkKey(APP_A, APP_C), callCount_proxy_C + callCount_C);
assertTarget_Source_TotalCount("APP_A -> APP_B", linkData, new LinkKey(APP_A, APP_B), callCount_proxy_B + callCount_B);
assertTarget_Source_TotalCount("APP_A -> APP_C", linkData, new LinkKey(APP_A, APP_C), callCount_proxy_C + callCount_C);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCaller_3tier.
@Test
public void testCaller_3tier() {
// APP_A -> APP_B -> APP_C
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 Application APP_C = new Application("APP_C", ServiceType.TEST_STAND_ALONE);
int callCount_A_B = 10;
LinkDataMap link_A_B = new LinkDataMap();
link_A_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(link_A_B);
LinkDataMap link_B_C = new LinkDataMap();
int callCount_B_C = 20;
link_B_C.addLinkData(APP_B, "agentB", APP_C, "agentC", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_C);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(link_B_C);
when(linkDataMapService.selectCalleeLinkDataMap(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
// depth 1
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 1, 1);
Assert.assertEquals(linkData.size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_A_B);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), 1);
Assert.assertEquals(linkData.getSourceLinkDataMap().getTotalCount(), callCount_A_B);
assertSource_Target_TotalCount("APP_A->APP_B", linkData, new LinkKey(APP_A, APP_B), callCount_A_B);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 0);
// depth 2
LinkSelector linkSelector2 = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData_depth2 = linkSelector2.select(Collections.singletonList(APP_A), range, 2, 2);
Assert.assertEquals(linkData_depth2.size(), 2);
Assert.assertEquals(linkData_depth2.getTotalCount(), callCount_A_B + callCount_B_C);
LinkKey linkKey_A_B = new LinkKey(APP_A, APP_B);
assertSource_Target_TotalCount("APP_A->APP_B", linkData_depth2, linkKey_A_B, callCount_A_B);
LinkKey linkKey_B_C = new LinkKey(APP_B, APP_C);
assertSource_Target_TotalCount("APP_B->APP_C", linkData_depth2, linkKey_B_C, callCount_B_C);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCaller_multiple.
@Test
public void testCaller_multiple() {
// APP_A -> TARGET_1, TARGET_2, ...
final Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
int numTargets = RANDOM.nextInt(100);
int callCount_A_APP = 4;
LinkDataMap linkDataMap = new LinkDataMap();
for (int i = 0; i < numTargets; i++) {
String targetAppName = "TARGET_" + (i + 1);
String targetAppAgentId = "target" + (i + 1);
Application targetApp = new Application(targetAppName, ServiceType.TEST_STAND_ALONE);
linkDataMap.addLinkData(APP_A, "agentA", targetApp, targetAppAgentId, 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_APP);
}
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(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 1, 1);
Assert.assertEquals(linkData.size(), numTargets);
Assert.assertEquals(linkData.getTotalCount(), numTargets * callCount_A_APP);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), numTargets);
Assert.assertEquals(linkData.getSourceLinkDataMap().getTotalCount(), numTargets * callCount_A_APP);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 0);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCaller.
@Test
public void testCaller() {
// APP_A -> APP_B
final Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
final Application APP_B = new Application("APP_B", ServiceType.TEST_STAND_ALONE);
int callCount_A_B = 10;
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.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(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 1, 1);
Assert.assertEquals(linkData.size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_A_B);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), 1);
Assert.assertEquals(linkData.getSourceLinkDataMap().getTotalCount(), callCount_A_B);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 0);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class UnidirectionalLinkSelectorTest method testCalleesOfCallers.
@Test
public void testCalleesOfCallers() {
// 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 -> APP_A(selected) -> APP_OUT -> APP_OUT_OUT
// |-> APP_IN_OUT APP_OUT_IN -^
// 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 should not exist
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.assertNull(linkData_IN_to_IN_OUT);
// 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) should not exist
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.assertNull(linkData_OUT_IN_to_OUT);
}
Aggregations