Search in sources :

Example 26 with LinkKey

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);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Range(com.navercorp.pinpoint.web.vo.Range) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Test(org.junit.Test)

Example 27 with LinkKey

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);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Range(com.navercorp.pinpoint.web.vo.Range) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Test(org.junit.Test)

Example 28 with LinkKey

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;
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey)

Example 29 with LinkKey

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);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Example 30 with LinkKey

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);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Aggregations

LinkKey (com.navercorp.pinpoint.web.vo.LinkKey)37 Application (com.navercorp.pinpoint.web.vo.Application)20 Test (org.junit.Test)17 LinkData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)16 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)14 AcceptApplication (com.navercorp.pinpoint.web.service.map.AcceptApplication)11 Range (com.navercorp.pinpoint.web.vo.Range)11 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)9 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)7 VirtualLinkMarker (com.navercorp.pinpoint.web.service.map.VirtualLinkMarker)6 TimeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram)3 LinkCallData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallData)3 RpcApplication (com.navercorp.pinpoint.web.service.map.RpcApplication)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Link (com.navercorp.pinpoint.web.applicationmap.link.Link)2 ArrayList (java.util.ArrayList)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 CreateType (com.navercorp.pinpoint.web.applicationmap.link.CreateType)1 LinkHistogramSummary (com.navercorp.pinpoint.web.applicationmap.link.LinkHistogramSummary)1