use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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.LinkDataDuplexMap in project pinpoint by naver.
the class LinkSelectorTestBase method testEmpty.
@Test
public void testEmpty() {
Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
when(linkDataMapService.selectCallerLinkDataMap(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
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 select = linkSelector.select(Collections.singletonList(APP_A), range, 1, 1);
Assert.assertEquals(select.size(), 0);
Assert.assertEquals(select.getTotalCount(), 0);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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.LinkDataDuplexMap 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.LinkDataDuplexMap 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);
}
Aggregations