Search in sources :

Example 11 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.

the class ServerInfoAppenderTest method unknownNode.

@Test
public void unknownNode() {
    // Given
    Range range = Range.newRange(0, 60 * 1000);
    NodeList nodeList = new NodeList();
    LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
    Node unknownNode = new Node(new Application("Unknown", ServiceType.UNKNOWN));
    nodeList.addNode(unknownNode);
    // When
    serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
    // Then
    Assert.assertEquals(0, unknownNode.getServerInstanceList().getInstanceCount());
    verifyZeroInteractions(linkDataDuplexMap);
}
Also used : NodeList(com.navercorp.pinpoint.web.applicationmap.nodes.NodeList) Node(com.navercorp.pinpoint.web.applicationmap.nodes.Node) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) Test(org.junit.Test)

Example 12 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.

the class LinkSelectorTestBase method testVirtual_3tier_callee_limited.

/**
 * For situations where virtual nodes are visited, but their callee data are not fetched due to callee search limit.
 */
@Test
public void testVirtual_3tier_callee_limited() {
    // APP_A ---> APP_B via "gw.test.com/api" ---> APP_D via "api.test.com/test
    // |-> APP_C via "gw.test.com/api" -|
    // 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 Application APP_D = new Application("APP_D", ServiceType.TEST_STAND_ALONE);
    final String gwUri = "gw.test.com/api";
    final String apiUri = "api.test.com/test";
    final Application RPC_GW = new Application(gwUri, testRpcServiceType);
    final Application RPC_API = new Application(apiUri, testRpcServiceType);
    final Set<AcceptApplication> gwAcceptApplications = Sets.newHashSet(new AcceptApplication(gwUri, APP_B), new AcceptApplication(gwUri, APP_C));
    final Set<AcceptApplication> apiAcceptApplications = Sets.newHashSet(new AcceptApplication(apiUri, APP_D));
    final int callCount_A_B = 4, callCount_A_C = 6;
    final int callCount_B_D = 4, callCount_C_D = 6;
    LinkDataMap callerlinkDataMap_A = new LinkDataMap();
    callerlinkDataMap_A.addLinkData(APP_A, "agentA", RPC_GW, gwUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
    LinkDataMap callerLinkDataMap_B = new LinkDataMap();
    callerLinkDataMap_B.addLinkData(APP_B, "agentB", RPC_API, apiUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_D);
    LinkDataMap callerLinkDataMap_C = new LinkDataMap();
    callerLinkDataMap_C.addLinkData(APP_C, "agentC", RPC_API, apiUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_C_D);
    LinkDataMap calleeLinkDataMap_B = new LinkDataMap();
    calleeLinkDataMap_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
    LinkDataMap calleeLinkDataMap_C = new LinkDataMap();
    calleeLinkDataMap_C.addLinkData(APP_A, "agentA", APP_C, "agentC", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_C);
    LinkDataMap calleeLinkDataMap_D = new LinkDataMap();
    calleeLinkDataMap_D.addLinkData(APP_B, "agentB", APP_D, "agentD", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_D);
    calleeLinkDataMap_D.addLinkData(APP_C, "agentC", APP_D, "agentD", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_C_D);
    when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(callerlinkDataMap_A);
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    when(linkDataMapService.selectCallerLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(callerLinkDataMap_B);
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(calleeLinkDataMap_B);
    when(linkDataMapService.selectCallerLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(callerLinkDataMap_C);
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(calleeLinkDataMap_C);
    when(linkDataMapService.selectCallerLinkDataMap(eq(APP_D), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_D), any(Range.class))).thenReturn(calleeLinkDataMap_D);
    when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_A), any(Range.class))).thenReturn(gwAcceptApplications);
    when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_B), any(Range.class))).thenReturn(apiAcceptApplications);
    when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_C), any(Range.class))).thenReturn(apiAcceptApplications);
    // When
    LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
    LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 2, 1);
    // Then
    LinkData linkData_A_B = linkData.getSourceLinkData(new LinkKey(APP_A, APP_B));
    LinkData linkData_A_C = linkData.getSourceLinkData(new LinkKey(APP_A, APP_C));
    Assert.assertEquals(callCount_A_B, linkData_A_B.getTotalCount());
    Assert.assertEquals(callCount_A_C, linkData_A_C.getTotalCount());
    LinkData linkData_B_D = linkData.getSourceLinkData(new LinkKey(APP_B, APP_D));
    Assert.assertEquals(callCount_B_D, linkData_B_D.getTotalCount());
    LinkData linkData_C_D = linkData.getSourceLinkData(new LinkKey(APP_C, APP_D));
    Assert.assertEquals(callCount_C_D, linkData_C_D.getTotalCount());
    LinkData targetLinkData_A_B = linkData.getTargetLinkData(new LinkKey(APP_A, APP_B));
    LinkData targetLinkData_A_C = linkData.getTargetLinkData(new LinkKey(APP_A, APP_C));
    Assert.assertEquals(callCount_A_B, targetLinkData_A_B.getTotalCount());
    Assert.assertEquals(callCount_A_C, targetLinkData_A_C.getTotalCount());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) 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 13 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.

the class LinkSelectorTestBase method testCallee.

@Test
public void testCallee() {
    // 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(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(linkDataMap);
    when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
    LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
    LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_B), range, 1, 1);
    Assert.assertEquals(linkData.size(), 1);
    Assert.assertEquals(linkData.getTotalCount(), callCount_A_B);
    Assert.assertEquals(linkData.getSourceLinkDataList().size(), 0);
    Assert.assertEquals(linkData.getTargetLinkDataList().size(), 1);
    Assert.assertEquals(linkData.getTargetLinkDataMap().getTotalCount(), callCount_A_B);
}
Also used : 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 14 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.

the class LinkSelectorTestBase method testCallee_3tier.

@Test
public void testCallee_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);
    when(linkDataMapService.selectCalleeLinkDataMap(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, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
    when(linkDataMapService.selectCalleeLinkDataMap(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, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_C);
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(linkDataMap_B_C);
    when(linkDataMapService.selectCallerLinkDataMap(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_C), range, 1, 1);
    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 = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
    LinkDataDuplexMap linkData_depth2 = linkSelector2.select(Collections.singletonList(APP_C), range, 2, 2);
    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) 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 15 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.

the class LinkSelectorTestBase method testVirtual.

@Test
public void testVirtual() {
    // APP_A ---> APP_B via "www.test.com/test"
    // |-> APP_C via "www.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 rpcUri = "www.test.com/test";
    final Application RPC_A = new Application(rpcUri, testRpcServiceType);
    final Set<AcceptApplication> acceptApplications = Sets.newHashSet(new AcceptApplication(rpcUri, APP_B), new AcceptApplication(rpcUri, APP_C));
    int callCount_A_B = 10;
    int callCount_A_C = 20;
    LinkDataMap linkDataMap = new LinkDataMap();
    linkDataMap.addLinkData(APP_A, "agentA", RPC_A, rpcUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B + callCount_A_C);
    LinkDataMap rpc_A_B_calleeLinkDataMap = new LinkDataMap();
    rpc_A_B_calleeLinkDataMap.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
    LinkDataMap rpc_A_C_calleeLinkDataMap = new LinkDataMap();
    rpc_A_C_calleeLinkDataMap.addLinkData(APP_A, "agentA", APP_C, "agentC", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_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(rpc_A_B_calleeLinkDataMap);
    when(linkDataMapService.selectCallerLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(newEmptyLinkDataMap());
    when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(rpc_A_C_calleeLinkDataMap);
    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
    LinkData linkData_A_B = linkData.getSourceLinkData(new LinkKey(APP_A, APP_B));
    LinkData linkData_A_C = linkData.getSourceLinkData(new LinkKey(APP_A, APP_C));
    Assert.assertEquals(callCount_A_B, linkData_A_B.getTotalCount());
    Assert.assertEquals(callCount_A_C, linkData_A_C.getTotalCount());
    List<LinkCallData> callData_A_Bs = new ArrayList<>(linkData_A_B.getLinkCallDataMap().getLinkDataList());
    Assert.assertEquals(1, callData_A_Bs.size());
    LinkCallData callData_A_B = callData_A_Bs.get(0);
    Assert.assertEquals(rpcUri, callData_A_B.getTarget());
    Assert.assertEquals(testRpcServiceType, callData_A_B.getTargetServiceType());
    List<LinkCallData> callData_A_Cs = new ArrayList<>(linkData_A_C.getLinkCallDataMap().getLinkDataList());
    Assert.assertEquals(1, callData_A_Cs.size());
    LinkCallData callData_A_C = callData_A_Cs.get(0);
    Assert.assertEquals(rpcUri, callData_A_C.getTarget());
    Assert.assertEquals(testRpcServiceType, callData_A_C.getTargetServiceType());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ArrayList(java.util.ArrayList) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) Application(com.navercorp.pinpoint.web.vo.Application) LinkCallData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallData) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Aggregations

LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)35 Application (com.navercorp.pinpoint.web.vo.Application)26 Range (com.navercorp.pinpoint.web.vo.Range)24 Test (org.junit.Test)22 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)15 NodeList (com.navercorp.pinpoint.web.applicationmap.nodes.NodeList)10 LinkData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)10 LinkKey (com.navercorp.pinpoint.web.vo.LinkKey)9 Node (com.navercorp.pinpoint.web.applicationmap.nodes.Node)7 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)4 ApplicationMap (com.navercorp.pinpoint.web.applicationmap.ApplicationMap)3 ApplicationMapBuilder (com.navercorp.pinpoint.web.applicationmap.ApplicationMapBuilder)3 DefaultNodeHistogramFactory (com.navercorp.pinpoint.web.applicationmap.appender.histogram.DefaultNodeHistogramFactory)3 NodeHistogramFactory (com.navercorp.pinpoint.web.applicationmap.appender.histogram.NodeHistogramFactory)3 DefaultServerInstanceListFactory (com.navercorp.pinpoint.web.applicationmap.appender.server.DefaultServerInstanceListFactory)3 ServerInstanceListFactory (com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory)3 ServerInstanceList (com.navercorp.pinpoint.web.applicationmap.nodes.ServerInstanceList)3 LinkSelector (com.navercorp.pinpoint.web.service.map.LinkSelector)3 LinkDataMapProcessor (com.navercorp.pinpoint.web.service.map.processor.LinkDataMapProcessor)3 ArrayList (java.util.ArrayList)3