use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.
the class BFSLinkSelectorTest method testCallee_3tier.
@Test
public void testCallee_3tier() throws Exception {
// APP_A -> APP_B -> APP_C
when(calleeDao.selectCallee(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
int callCount_A_B = 30;
LinkDataMap linkDataMap_A_B = new LinkDataMap();
linkDataMap_A_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_A_B);
when(calleeDao.selectCallee(eq(APP_B), any(Range.class))).thenReturn(linkDataMap_A_B);
int callCount_B_C = 40;
LinkDataMap linkDataMap_B_C = new LinkDataMap();
linkDataMap_B_C.addLinkData(APP_B, "agentB", APP_C, "agentC", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_B_C);
when(calleeDao.selectCallee(eq(APP_C), any(Range.class))).thenReturn(linkDataMap_B_C);
when(callerDao.selectCaller(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<AcceptApplication>());
LinkSelector linkSelector = createLinkSelector();
LinkDataDuplexMap linkData = linkSelector.select(APP_C, range, oneDepth);
Assert.assertEquals(linkData.size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), 0);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_B_C);
// depth 2
LinkSelector linkSelector2 = createLinkSelector();
LinkDataDuplexMap linkData_depth2 = linkSelector2.select(APP_C, range, twoDepth);
Assert.assertEquals(linkData_depth2.size(), 2);
LinkKey linkKey_A_B = new LinkKey(APP_A, APP_B);
assertTarget_Source_TotalCount("APP_A->APP_B", linkData_depth2, linkKey_A_B, callCount_A_B);
LinkKey linkKey_B_C = new LinkKey(APP_B, APP_C);
assertTarget_Source_TotalCount("APP_B->APP_C", linkData_depth2, linkKey_B_C, callCount_B_C);
}
use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.
the class BFSLinkSelectorTest method testCaller_3tier.
@Test
public void testCaller_3tier() throws Exception {
// APP_A -> APP_B -> APP_C
int callCount_A_B = 10;
LinkDataMap link_A_B = new LinkDataMap();
link_A_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_A_B);
when(callerDao.selectCaller(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, BaseHistogramSchema.NORMAL_SCHEMA.getNormalSlot().getSlotTime(), callCount_B_C);
when(callerDao.selectCaller(eq(APP_B), any(Range.class))).thenReturn(link_B_C);
when(calleeDao.selectCallee(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<AcceptApplication>());
// depth 1
LinkSelector linkSelector = createLinkSelector();
LinkDataDuplexMap linkData = linkSelector.select(APP_A, range, oneDepth);
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 = createLinkSelector();
LinkDataDuplexMap linkData_depth2 = linkSelector2.select(APP_A, range, twoDepth);
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.vo.LinkKey in project pinpoint by naver.
the class LinkList method addLink.
public boolean addLink(Link link) {
if (link == null) {
throw new NullPointerException("link must not be null");
}
final LinkKey linkId = link.getLinkKey();
final Link find = this.linkMap.get(linkId);
if (find != null) {
return false;
}
return this.linkMap.put(linkId, link) == null;
}
use of com.navercorp.pinpoint.web.vo.LinkKey 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.vo.LinkKey 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);
}
Aggregations