use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class ServerInfoAppenderTest method unknownNode.
@Test
public void unknownNode() {
// Given
Range range = Range.newRange(0, 60 * 1000);
NodeList nodeList = new NodeList();
LinkDataDuplexMap linkDataDuplexMap = mock(LinkDataDuplexMap.class);
Node unknownNode = new Node(new Application("Unknown", ServiceType.UNKNOWN));
nodeList.addNode(unknownNode);
// When
serverInfoAppender.appendServerInfo(range, nodeList, linkDataDuplexMap, timeoutMillis);
// Then
Assert.assertEquals(0, unknownNode.getServerInstanceList().getInstanceCount());
verifyZeroInteractions(linkDataDuplexMap);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class LinkSelectorTestBase method testVirtual_3tier_callee_limited.
/**
* For situations where virtual nodes are visited, but their callee data are not fetched due to callee search limit.
*/
@Test
public void testVirtual_3tier_callee_limited() {
// APP_A ---> APP_B via "gw.test.com/api" ---> APP_D via "api.test.com/test
// |-> APP_C via "gw.test.com/api" -|
// 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 Application APP_D = new Application("APP_D", ServiceType.TEST_STAND_ALONE);
final String gwUri = "gw.test.com/api";
final String apiUri = "api.test.com/test";
final Application RPC_GW = new Application(gwUri, testRpcServiceType);
final Application RPC_API = new Application(apiUri, testRpcServiceType);
final Set<AcceptApplication> gwAcceptApplications = Sets.newHashSet(new AcceptApplication(gwUri, APP_B), new AcceptApplication(gwUri, APP_C));
final Set<AcceptApplication> apiAcceptApplications = Sets.newHashSet(new AcceptApplication(apiUri, APP_D));
final int callCount_A_B = 4, callCount_A_C = 6;
final int callCount_B_D = 4, callCount_C_D = 6;
LinkDataMap callerlinkDataMap_A = new LinkDataMap();
callerlinkDataMap_A.addLinkData(APP_A, "agentA", RPC_GW, gwUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
LinkDataMap callerLinkDataMap_B = new LinkDataMap();
callerLinkDataMap_B.addLinkData(APP_B, "agentB", RPC_API, apiUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_D);
LinkDataMap callerLinkDataMap_C = new LinkDataMap();
callerLinkDataMap_C.addLinkData(APP_C, "agentC", RPC_API, apiUri, 1000, testRpcServiceType.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_C_D);
LinkDataMap calleeLinkDataMap_B = new LinkDataMap();
calleeLinkDataMap_B.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
LinkDataMap calleeLinkDataMap_C = new LinkDataMap();
calleeLinkDataMap_C.addLinkData(APP_A, "agentA", APP_C, "agentC", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_C);
LinkDataMap calleeLinkDataMap_D = new LinkDataMap();
calleeLinkDataMap_D.addLinkData(APP_B, "agentB", APP_D, "agentD", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_B_D);
calleeLinkDataMap_D.addLinkData(APP_C, "agentC", APP_D, "agentD", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_C_D);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(callerlinkDataMap_A);
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_A), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(callerLinkDataMap_B);
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(calleeLinkDataMap_B);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(callerLinkDataMap_C);
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_C), any(Range.class))).thenReturn(calleeLinkDataMap_C);
when(linkDataMapService.selectCallerLinkDataMap(eq(APP_D), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_D), any(Range.class))).thenReturn(calleeLinkDataMap_D);
when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_A), any(Range.class))).thenReturn(gwAcceptApplications);
when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_B), any(Range.class))).thenReturn(apiAcceptApplications);
when(hostApplicationMapDao.findAcceptApplicationName(eq(APP_C), any(Range.class))).thenReturn(apiAcceptApplications);
// When
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_A), range, 2, 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());
LinkData linkData_B_D = linkData.getSourceLinkData(new LinkKey(APP_B, APP_D));
Assert.assertEquals(callCount_B_D, linkData_B_D.getTotalCount());
LinkData linkData_C_D = linkData.getSourceLinkData(new LinkKey(APP_C, APP_D));
Assert.assertEquals(callCount_C_D, linkData_C_D.getTotalCount());
LinkData targetLinkData_A_B = linkData.getTargetLinkData(new LinkKey(APP_A, APP_B));
LinkData targetLinkData_A_C = linkData.getTargetLinkData(new LinkKey(APP_A, APP_C));
Assert.assertEquals(callCount_A_B, targetLinkData_A_B.getTotalCount());
Assert.assertEquals(callCount_A_C, targetLinkData_A_C.getTotalCount());
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap in project pinpoint by naver.
the class LinkSelectorTestBase method testCallee.
@Test
public void testCallee() {
// APP_A -> APP_B
final Application APP_A = new Application("APP_A", ServiceType.TEST_STAND_ALONE);
final Application APP_B = new Application("APP_B", ServiceType.TEST_STAND_ALONE);
int callCount_A_B = 10;
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(APP_A, "agentA", APP_B, "agentB", 1000, ServiceType.TEST_STAND_ALONE.getHistogramSchema().getNormalSlot().getSlotTime(), callCount_A_B);
when(linkDataMapService.selectCallerLinkDataMap(any(Application.class), any(Range.class))).thenReturn(newEmptyLinkDataMap());
when(linkDataMapService.selectCalleeLinkDataMap(eq(APP_B), any(Range.class))).thenReturn(linkDataMap);
when(hostApplicationMapDao.findAcceptApplicationName(any(Application.class), any(Range.class))).thenReturn(new HashSet<>());
LinkSelector linkSelector = linkSelectorFactory.createLinkSelector(getLinkSelectorType());
LinkDataDuplexMap linkData = linkSelector.select(Collections.singletonList(APP_B), range, 1, 1);
Assert.assertEquals(linkData.size(), 1);
Assert.assertEquals(linkData.getTotalCount(), callCount_A_B);
Assert.assertEquals(linkData.getSourceLinkDataList().size(), 0);
Assert.assertEquals(linkData.getTargetLinkDataList().size(), 1);
Assert.assertEquals(linkData.getTargetLinkDataMap().getTotalCount(), callCount_A_B);
}
use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap 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.LinkDataDuplexMap 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());
}
Aggregations