Search in sources :

Example 16 with LinkKey

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));
}
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 17 with LinkKey

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());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) 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 18 with LinkKey

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());
}
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 19 with LinkKey

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());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) 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 20 with LinkKey

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());
}
Also used : LinkKey(com.navercorp.pinpoint.web.vo.LinkKey) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) 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)

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