Search in sources :

Example 31 with LinkDataDuplexMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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);
}
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) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Example 32 with LinkDataDuplexMap

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

the class ApplicationMapBuilderTest method testEmptyCallData.

@Test
public void testEmptyCallData() {
    Range range = Range.newRange(0, 1000);
    LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
    NodeHistogramFactory nodeHistogramFactory = new DefaultNodeHistogramFactory(mapResponseNodeHistogramDataSource);
    ServerInstanceListFactory serverInstanceListFactory = new DefaultServerInstanceListFactory(agentInfoServerInstanceListDataSource);
    ApplicationMapBuilder applicationMapBuilder = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, serialExecutor);
    ApplicationMapBuilder applicationMapBuilder_parallelAppenders = ApplicationMapBuilderTestHelper.createApplicationMapBuilder(range, parallelExecutor);
    ApplicationMap applicationMap = applicationMapBuilder.includeNodeHistogram(nodeHistogramFactory).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
    ApplicationMap applicationMap_parallelAppenders = applicationMapBuilder_parallelAppenders.includeNodeHistogram(nodeHistogramFactory).includeServerInfo(serverInstanceListFactory).build(linkDataDuplexMap, buildTimeoutMillis);
    Assert.assertTrue(applicationMap.getNodes().isEmpty());
    Assert.assertTrue(applicationMap.getNodes().isEmpty());
    Assert.assertTrue(applicationMap_parallelAppenders.getNodes().isEmpty());
    Assert.assertTrue(applicationMap.getLinks().isEmpty());
    Assert.assertTrue(applicationMap.getLinks().isEmpty());
    Assert.assertTrue(applicationMap_parallelAppenders.getLinks().isEmpty());
    ApplicationMapVerifier verifier = new ApplicationMapVerifier(applicationMap);
    verifier.verify(applicationMap);
    verifier.verify(applicationMap_parallelAppenders);
}
Also used : DefaultNodeHistogramFactory(com.navercorp.pinpoint.web.applicationmap.appender.histogram.DefaultNodeHistogramFactory) ServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.ServerInstanceListFactory) DefaultServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.DefaultServerInstanceListFactory) DefaultServerInstanceListFactory(com.navercorp.pinpoint.web.applicationmap.appender.server.DefaultServerInstanceListFactory) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) DefaultNodeHistogramFactory(com.navercorp.pinpoint.web.applicationmap.appender.histogram.DefaultNodeHistogramFactory) NodeHistogramFactory(com.navercorp.pinpoint.web.applicationmap.appender.histogram.NodeHistogramFactory) Test(org.junit.Test)

Example 33 with LinkDataDuplexMap

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

the class ServerInfoAppenderTest method nullNodeList.

@Test
public void nullNodeList() {
    // Given
    Range range = Range.newRange(0, 60 * 1000);
    NodeList nodeList = null;
    LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
    // When
    serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
    // Then
    Assert.assertNull(nodeList);
    verifyZeroInteractions(serverInstanceListDataSource);
    verifyZeroInteractions(linkDataDuplexMap);
}
Also used : NodeList(com.navercorp.pinpoint.web.applicationmap.nodes.NodeList) LinkDataDuplexMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap) Range(com.navercorp.pinpoint.web.vo.Range) Test(org.junit.Test)

Example 34 with LinkDataDuplexMap

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

the class ServerInfoAppenderTest method terminalNode.

@Test
public void terminalNode() {
    // Given
    Range range = Range.newRange(0, 60 * 1000);
    NodeList nodeList = new NodeList();
    LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
    ServiceType terminalType = ServiceTypeFactory.of(2000, "TERMINAL", TERMINAL, INCLUDE_DESTINATION_ID);
    Application terminalApplication = new Application("Terminal", terminalType);
    Node terminalNode = new Node(terminalApplication);
    nodeList.addNode(terminalNode);
    Application fromApplication = new Application("FromWas", ServiceType.TEST_STAND_ALONE);
    LinkData linkData = new LinkData(fromApplication, terminalApplication);
    linkData.addLinkData("wasAgent", ServiceType.TEST_STAND_ALONE, "terminalNodeAddress", terminalType, System.currentTimeMillis(), terminalType.getHistogramSchema().getNormalSlot().getSlotTime(), 1);
    linkDataDuplexMap.addSourceLinkData(linkData);
    // When
    serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
    // Then
    Assert.assertEquals(1, terminalNode.getServerInstanceList().getInstanceCount());
}
Also used : LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) 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 35 with LinkDataDuplexMap

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

the class ServerInfoAppenderTest method terminalNode_multipleInstances.

@Test
public void terminalNode_multipleInstances() {
    // Given
    Range range = Range.newRange(0, 60 * 1000);
    NodeList nodeList = new NodeList();
    LinkDataDuplexMap linkDataDuplexMap = new LinkDataDuplexMap();
    ServiceType terminalType = ServiceTypeFactory.of(2000, "TERMINAL", TERMINAL, INCLUDE_DESTINATION_ID);
    Application terminalApplication = new Application("Terminal", terminalType);
    Node terminalNode = new Node(terminalApplication);
    nodeList.addNode(terminalNode);
    Application fromApplication = new Application("FromWas", ServiceType.TEST_STAND_ALONE);
    LinkData linkData = new LinkData(fromApplication, terminalApplication);
    linkData.addLinkData("wasAgent", ServiceType.TEST_STAND_ALONE, "terminalNodeAddress1", terminalType, System.currentTimeMillis(), terminalType.getHistogramSchema().getNormalSlot().getSlotTime(), 1);
    linkData.addLinkData("wasAgent", ServiceType.TEST_STAND_ALONE, "terminalNodeAddress2", terminalType, System.currentTimeMillis(), terminalType.getHistogramSchema().getNormalSlot().getSlotTime(), 1);
    linkDataDuplexMap.addSourceLinkData(linkData);
    // When
    serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
    // Then
    Assert.assertEquals(2, terminalNode.getServerInstanceList().getInstanceCount());
}
Also used : LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) 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)

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