Search in sources :

Example 21 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.

the class BidirectionalLinkSelectorTest method testBidirectionalGraph.

@Test
public void testBidirectionalGraph() {
    // 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 (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
    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.assertNotNull(linkData_IN_to_IN_OUT);
    Assert.assertEquals(callCount, linkData_IN_to_IN_OUT.getTotalCount());
    // 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)
    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.assertNotNull(linkData_OUT_IN_to_OUT);
    Assert.assertEquals(callCount, linkData_OUT_IN_to_OUT.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) 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 22 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.

the class FilteredMapBuilderTest method assertSourceLinkData.

private void assertSourceLinkData(LinkDataMap sourceLinkDataMap, String fromApplicationName, ServiceType fromServiceType, String toApplicationName, ServiceType toServiceType) {
    LinkKey linkKey = new LinkKey(fromApplicationName, fromServiceType, toApplicationName, toServiceType);
    LinkData sourceLinkData = sourceLinkDataMap.getLinkData(linkKey);
    String assertMessage = String.format("%s[%s] to %s[%s] source link data does not exist", fromApplicationName, fromServiceType.getName(), toApplicationName, toServiceType.getName());
    Assert.assertNotNull(assertMessage, sourceLinkData);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)

Example 23 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.

the class FilteredMapBuilderTest method assertTargetLinkData.

private void assertTargetLinkData(LinkDataMap targetLinkDataMap, String fromApplicationName, ServiceType fromServiceType, String toApplicationName, ServiceType toServiceType) {
    LinkKey linkKey = new LinkKey(fromApplicationName, fromServiceType, toApplicationName, toServiceType);
    LinkData targetLinkData = targetLinkDataMap.getLinkData(linkKey);
    String assertMessage = String.format("%s[%s] from %s[%s] target link data does not exist", toApplicationName, toServiceType.getName(), fromApplicationName, fromServiceType.getName());
    Assert.assertNotNull(assertMessage, targetLinkData);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)

Example 24 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.

the class BFSLinkSelector method getLinkKey.

private LinkKey getLinkKey(LinkData emulationLinkData) {
    Application fromApplication = emulationLinkData.getFromApplication();
    Application toApplication = emulationLinkData.getToApplication();
    return new LinkKey(fromApplication, toApplication);
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) RpcApplication(com.navercorp.pinpoint.web.service.map.RpcApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication)

Example 25 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.

the class BFSLinkSelector method fillEmulationLink.

private void fillEmulationLink(LinkDataDuplexMap linkDataDuplexMap, Range range) {
    // TODO need to be reimplemented - virtual node creation logic needs an overhaul.
    // Currently, only the reversed relationship node is displayed. We need to create a virtual node and convert the rpc data appropriately.
    logger.debug("this.emulationLinkMarker:{}", this.emulationLinkMarker);
    List<LinkData> emulationLinkDataList = findEmulationLinkData(linkDataDuplexMap);
    for (LinkData emulationLinkData : emulationLinkDataList) {
        LinkCallDataMap beforeImage = emulationLinkData.getLinkCallDataMap();
        logger.debug("beforeImage:{}", beforeImage);
        emulationLinkData.resetLinkData();
        LinkKey findLinkKey = new LinkKey(emulationLinkData.getFromApplication(), emulationLinkData.getToApplication());
        LinkData targetLinkData = linkDataDuplexMap.getTargetLinkData(findLinkKey);
        if (targetLinkData == null) {
            // This is a case where the emulation target node has been only "partially" visited, (ie. does not have a target link data)
            // Most likely due to the limit imposed by inbound search depth.
            // Must go fetch the target link data here.
            final Application targetApplication = emulationLinkData.getToApplication();
            final LinkDataMap callee = mapStatisticsCalleeDao.selectCallee(targetApplication, range);
            targetLinkData = callee.getLinkData(findLinkKey);
            if (targetLinkData == null) {
                // There has been a case where targetLinkData was null, but exact event could not be captured for analysis.
                // Logging the case for further analysis should it happen again in the future.
                logger.error("targetLinkData not found findLinkKey:{}", findLinkKey);
                continue;
            }
        }
        // create reversed link data - convert data accepted by the target to target's call data
        LinkCallDataMap targetList = targetLinkData.getLinkCallDataMap();
        Collection<LinkCallData> beforeLinkDataList = beforeImage.getLinkDataList();
        LinkCallData beforeLinkCallData = beforeLinkDataList.iterator().next();
        for (LinkCallData agentHistogram : targetList.getLinkDataList()) {
            Collection<TimeHistogram> timeHistogramList = agentHistogram.getTimeHistogram();
            LinkCallDataMap linkCallDataMap = emulationLinkData.getLinkCallDataMap();
            if (logger.isDebugEnabled()) {
                logger.debug("emulationLink BEFORE:{}", beforeLinkCallData);
                logger.debug("emulationLink agent:{}", agentHistogram);
                logger.debug("emulationLink link:{}/{} -> {}/{}", agentHistogram.getTarget(), agentHistogram.getTargetServiceType(), beforeLinkCallData.getTarget(), beforeLinkCallData.getTargetServiceType().getCode());
            }
            linkCallDataMap.addCallData(agentHistogram.getTarget(), agentHistogram.getTargetServiceType(), beforeLinkCallData.getTarget(), beforeLinkCallData.getTargetServiceType(), timeHistogramList);
        }
    }
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) RpcApplication(com.navercorp.pinpoint.web.service.map.RpcApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) TimeHistogram(com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram)

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