use of com.navercorp.pinpoint.web.vo.LinkKey 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.vo.LinkKey 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());
}
use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.
the class RpcCallProcessorTest method oneAcceptApplication.
@Test
public void oneAcceptApplication() {
// 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 expectedToApplication = new Application("ACCEPT_WAS", ServiceType.TEST_STAND_ALONE);
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Sets.newHashSet(new AcceptApplication(rpcUri, expectedToApplication)));
// 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 replacedLinkKey = new LinkKey(fromApplication, expectedToApplication);
LinkData replacedLinkData = replacedLinkDataMap.getLinkData(replacedLinkKey);
Assert.assertNotNull(replacedLinkData);
Assert.assertEquals(fromApplication, replacedLinkData.getFromApplication());
Assert.assertEquals(expectedToApplication, replacedLinkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.
the class RpcCallProcessorTest method queueWithoutAcceptApplication_shouldNotReplace.
@Test
public void queueWithoutAcceptApplication_shouldNotReplace() {
// Given
ServiceType queueServiceType = mock(ServiceType.class);
when(queueServiceType.isRpcClient()).thenReturn(false);
when(queueServiceType.isQueue()).thenReturn(true);
String queueName = "TestQueue";
Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
Application toApplication = new Application(queueName, queueServiceType);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Collections.emptySet());
// When
VirtualLinkMarker virtualLinkMarker = new VirtualLinkMarker();
RpcCallProcessor rpcCallProcessor = new RpcCallProcessor(hostApplicationMapDao, virtualLinkMarker);
LinkDataMap replacedLinkDataMap = rpcCallProcessor.processLinkDataMap(linkDataMap, testRange);
// Then
LinkKey linkKey = new LinkKey(fromApplication, toApplication);
LinkData linkData = replacedLinkDataMap.getLinkData(linkKey);
Assert.assertEquals(fromApplication, linkData.getFromApplication());
Assert.assertEquals(toApplication, linkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
use of com.navercorp.pinpoint.web.vo.LinkKey in project pinpoint by naver.
the class RpcCallProcessorTest method rpcWithoutAcceptApplication_shouldBeReplacedToUnknown.
@Test
public void rpcWithoutAcceptApplication_shouldBeReplacedToUnknown() {
// 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);
Application expectedToApplication = new Application(rpcUri, ServiceType.UNKNOWN);
LinkDataMap linkDataMap = new LinkDataMap();
linkDataMap.addLinkData(new LinkData(fromApplication, toApplication));
when(hostApplicationMapDao.findAcceptApplicationName(fromApplication, testRange)).thenReturn(Collections.emptySet());
// 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 replacedLinkKey = new LinkKey(fromApplication, expectedToApplication);
LinkData replacedLinkData = replacedLinkDataMap.getLinkData(replacedLinkKey);
Assert.assertEquals(fromApplication, replacedLinkData.getFromApplication());
Assert.assertEquals(expectedToApplication, replacedLinkData.getToApplication());
Assert.assertTrue(virtualLinkMarker.getVirtualLinkData().isEmpty());
}
Aggregations