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);
}
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());
}
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;
}
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;
}
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);
}
}
Aggregations