use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap 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);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap 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());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCaller_rpc.
@Test
public void testCaller_rpc() {
// APP_A -> APP_B 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 String rpcUri = "www.test.com/test";
final Application RPC_A_B = new Application(rpcUri, testRpcServiceType);
final Set<AcceptApplication> acceptApplications = new HashSet<AcceptApplication>() {
{
add(new AcceptApplication(rpcUri, APP_B));
}
};
int callCount_A_B = 10;
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(APP_A, "agentA", RPC_A_B, rpcUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(linkDataMap);
when(linkDataMapService.selectCalleeLinkDataMap(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
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
Assert.assertEquals(1, linkData.size());
Assert.assertEquals(callCount_A_B, linkData.getTotalCount());
Assert.assertEquals(1, linkData.getSourceLinkDataList().size());
Assert.assertEquals(callCount_A_B, linkData.getSourceLinkDataMap().getTotalCount());
Assert.assertEquals(0, linkData.getTargetLinkDataList().size());
LinkData linkData_A_B = linkData.getSourceLinkData(new LinkKey(APP_A, APP_B));
Assert.assertEquals(callCount_A_B, linkData_A_B.getTotalCount());
List<LinkCallData> callDatas = new ArrayList<>(linkData_A_B.getLinkCallDataMap().getLinkDataList());
Assert.assertEquals(1, callDatas.size());
LinkCallData callData = callDatas.get(0);
Assert.assertEquals(rpcUri, callData.getTarget());
Assert.assertEquals(testRpcServiceType, callData.getTargetServiceType());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method multipleAcceptApplications.
@Test
public void multipleAcceptApplications() {
// 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("ACCEPT_WAS1", ServiceType.TEST_STAND_ALONE);
Application expectedToApplication2 = new Application("ACCEPT_WAS2", ServiceType.TEST_STAND_ALONE);
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 replacedLinkKey1 = new LinkKey(fromApplication, expectedToApplication1);
LinkData replacedLinkData1 = replacedLinkDataMap.getLinkData(replacedLinkKey1);
Assert.assertNotNull(replacedLinkData1);
Assert.assertEquals(fromApplication, replacedLinkData1.getFromApplication());
Assert.assertEquals(expectedToApplication1, replacedLinkData1.getToApplication());
LinkKey replacedLinkKey2 = new LinkKey(fromApplication, expectedToApplication2);
LinkData replacedLinkData2 = replacedLinkDataMap.getLinkData(replacedLinkKey2);
Assert.assertNotNull(replacedLinkData2);
Assert.assertEquals(fromApplication, replacedLinkData2.getFromApplication());
Assert.assertEquals(expectedToApplication2, replacedLinkData2.getToApplication());
Set<LinkData> virtualLinkDatas = virtualLinkMarker.getVirtualLinkData();
Assert.assertTrue(virtualLinkDatas.contains(replacedLinkData1));
Assert.assertTrue(virtualLinkDatas.contains(replacedLinkData2));
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.
the class RpcCallProcessorTest method nonRpcClientOrQueueCallsShouldNotBeReplaced.
@Test
public void nonRpcClientOrQueueCallsShouldNotBeReplaced() {
// Given
ServiceType nonRpcClientOrQueueServiceType = mock(ServiceType.class);
when(nonRpcClientOrQueueServiceType.isRpcClient()).thenReturn(false);
when(nonRpcClientOrQueueServiceType.isQueue()).thenReturn(false);
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application("NON_RPC_OR_QUEUE", nonRpcClientOrQueueServiceType);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey linkKey = new LinkKey(fromApplication, toApplication);
Assert.assertNotNull(replacedLinkDataMap.getLinkData(linkKey));
Assert.assertEquals(linkDataMap.size(), replacedLinkDataMap.size());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
Aggregations