Search in sources :

Example 31 with LinkKey

use of com.navercorp.pinpoint.web.vo.LinkKey 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 LinkKey

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

the class RpcCallProcessorTest method multipleAcceptApplications_with_AliasAndOriginal.

@Test
public void multipleAcceptApplications_with_AliasAndOriginal() {
    ServiceType AliasServiceType = of(1008, "TEST_ALIAS_CLIENT", ALIAS);
    ServiceType ServerServiceType = of(1009, "TEST_ALIAS_SERVER", RECORD_STATISTICS, TERMINAL);
    // Given
    ServiceType rpcClientServiceType = mock(ServiceType.class);
    when(rpcClientServiceType.isRpcClient()).thenReturn(true);
    String rpcUri = "accept.host/foo";
    Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
    Application toApplication = new Application(rpcUri, rpcClientServiceType);
    LinkDataMap linkDataMap = new LinkDataMap();
    linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
    Application expectedToApplication1 = new Application("AliasClient", AliasServiceType);
    Application expectedToApplication2 = new Application("AliasServer", ServerServiceType);
    when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Sets.newHashSet(new AcceptApplication(rpcUri, expectedToApplication1), new AcceptApplication(rpcUri, expectedToApplication2)));
    // When
    VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
    RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
    LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
    // Then
    LinkKey originalLinkKey = new LinkKey(fromApplication, toApplication);
    Assert.assertNull(replacedLinkDataMap.getLinkData(originalLinkKey));
    LinkKey replacedLinkKey2 = new LinkKey(fromApplication, expectedToApplication2);
    LinkData replacedLinkData2 = replacedLinkDataMap.getLinkData(replacedLinkKey2);
    Assert.assertNotNull(replacedLinkData2);
    Assert.assertEquals(fromApplication, replacedLinkData2.getFromApplication());
    Assert.assertEquals(expectedToApplication2, replacedLinkData2.getToApplication());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) Application(com.navercorp.pinpoint.web.vo.Application) AcceptApplication(com.navercorp.pinpoint.web.service.map.AcceptApplication) VirtualLinkMarker(com.navercorp.pinpoint.web.service.map.VirtualLinkMarker) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Example 33 with LinkKey

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

the class LinkCallDataMap method getTargetList.

public AgentHistogramList getTargetList() {
    AgentHistogramList targetList = new AgentHistogramList();
    for (Map.Entry<LinkKey, LinkCallData> linkKeyRawCallDataEntry : linkDataMap.entrySet()) {
        final LinkKey key = linkKeyRawCallDataEntry.getKey();
        final LinkCallData linkCallData = linkKeyRawCallDataEntry.getValue();
        targetList.addAgentHistogram(key.getToApplication(), key.getToServiceType(), linkCallData.getTimeHistogram());
    }
    return targetList;
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Map(java.util.Map) HashMap(java.util.HashMap)

Example 34 with LinkKey

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

the class LinkCallDataMap method getSourceList.

public AgentHistogramList getSourceList() {
    AgentHistogramList sourceList = new AgentHistogramList();
    for (Map.Entry<LinkKey, LinkCallData> linkKeyRawCallDataEntry : linkDataMap.entrySet()) {
        final LinkKey key = linkKeyRawCallDataEntry.getKey();
        final LinkCallData linkCallData = linkKeyRawCallDataEntry.getValue();
        // need target (to) ServiceType
        // the definition of source is data from the source when the source sends a request to a target.
        // Thus ServiceType is the target's ServiceType
        sourceList.addAgentHistogram(key.getFromApplication(), key.getToServiceType(), linkCallData.getTimeHistogram());
    }
    return sourceList;
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Map(java.util.Map) HashMap(java.util.HashMap)

Example 35 with LinkKey

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

the class LinkCallDataMap method addLinkDataMap.

public void addLinkDataMap(LinkCallDataMap target) {
    Objects.requireNonNull(target, "target");
    for (Map.Entry<LinkKey, LinkCallData> copyEntry : target.linkDataMap.entrySet()) {
        final LinkKey key = copyEntry.getKey();
        final LinkCallData copyLinkCallData = copyEntry.getValue();
        LinkCallData linkCallData = getLinkCallData(key);
        linkCallData.addRawCallData(copyLinkCallData);
    }
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) Map(java.util.Map) HashMap(java.util.HashMap)

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