Search in sources :

Example 31 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap 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());
}
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 32 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.

the class WasOnlyProcessorTest method shouldFilterLinksToTerminalNodes.

@Test
public void shouldFilterLinksToTerminalNodes() {
    // Given
    Application fromApplication = new Application("WAS", ServiceType.TEST_STAND_ALONE);
    ServiceType terminalServiceType = ServiceTypeFactory.of(2222, "TERMINAL", ServiceTypeProperty.TERMINAL);
    Application toApplication = new Application("TERMINAL", terminalServiceType);
    LinkData wasToTerminalLinkData = new LinkData(fromApplication, toApplication);
    LinkDataMap linkDataMap = new LinkDataMap();
    linkDataMap.addLinkData(wasToTerminalLinkData);
    // When
    WasOnlyProcessor wasOnlyProcessor = new WasOnlyProcessor();
    LinkDataMap filteredLinkDataMap = wasOnlyProcessor.processLinkDataMap(linkDataMap, testRange);
    // Then
    Assert.assertTrue(filteredLinkDataMap.getLinkDataList().isEmpty());
}
Also used : WasOnlyProcessor(com.navercorp.pinpoint.web.service.map.processor.WasOnlyProcessor) LinkData(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) Application(com.navercorp.pinpoint.web.vo.Application) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap) Test(org.junit.Test)

Example 33 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.

the class HbaseMapStatisticsCallerDao method selectCaller.

@Override
public LinkDataMap selectCaller(Application callerApplication, Range range) {
    Objects.requireNonNull(callerApplication, "callerApplication");
    Objects.requireNonNull(range, "range");
    final TimeWindow timeWindow = new TimeWindow(range, TimeWindowDownSampler.SAMPLER);
    // find distributed key.
    final Scan scan = createScan(callerApplication, range, DESCRIPTOR.getName());
    ResultsExtractor<LinkDataMap> resultExtractor = new RowMapReduceResultExtractor<>(mapStatisticsCallerMapper, new MapStatisticsTimeWindowReducer(timeWindow));
    TableName mapStatisticsCalleeTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    LinkDataMap linkDataMap = this.hbaseTemplate.findParallel(mapStatisticsCalleeTableName, scan, rowKeyDistributorByHashPrefix, resultExtractor, MAP_STATISTICS_CALLEE_VER2_NUM_PARTITIONS);
    logger.debug("tableInfo({}). Caller data. {}, {} : ", mapStatisticsCalleeTableName.getNameAsString(), linkDataMap, range);
    if (linkDataMap != null && linkDataMap.size() > 0) {
        return linkDataMap;
    }
    return new LinkDataMap();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) MapStatisticsTimeWindowReducer(com.navercorp.pinpoint.web.mapper.MapStatisticsTimeWindowReducer) Scan(org.apache.hadoop.hbase.client.Scan) TimeWindow(com.navercorp.pinpoint.web.util.TimeWindow) RowMapReduceResultExtractor(com.navercorp.pinpoint.web.mapper.RowMapReduceResultExtractor) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 34 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.

the class MapStatisticsCalleeMapper method mapRow.

@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return new LinkDataMap();
    }
    logger.debug("mapRow:{}", rowNum);
    final byte[] rowKey = getOriginalKey(result.getRow());
    final Buffer row = new FixedBuffer(rowKey);
    final Application calleeApplication = readCalleeApplication(row);
    final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
    final LinkDataMap linkDataMap = new LinkDataMap();
    for (Cell cell : result.rawCells()) {
        final byte[] qualifier = CellUtil.cloneQualifier(cell);
        final Application callerApplication = readCallerApplication(qualifier, calleeApplication.getServiceType());
        if (filter.filter(callerApplication)) {
            continue;
        }
        long requestCount = Bytes.toLong(cell.getValueArray(), cell.getValueOffset());
        short histogramSlot = ApplicationMapStatisticsUtils.getHistogramSlotFromColumnName(qualifier);
        String callerHost = ApplicationMapStatisticsUtils.getHost(qualifier);
        // nodes, they would not have reached here in the first place.
        if (calleeApplication.getServiceType().isQueue()) {
            callerHost = StringUtils.defaultString(callerHost);
        }
        boolean isError = histogramSlot == (short) -1;
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Callee. {} callerHost:{} -> {} (slot:{}/{}),  ", callerApplication, callerHost, calleeApplication, histogramSlot, requestCount);
        }
        final short slotTime = (isError) ? (short) -1 : histogramSlot;
        linkDataMap.addLinkData(callerApplication, callerApplication.getName(), calleeApplication, callerHost, timestamp, slotTime, requestCount);
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Callee. statistics:{}", linkDataMap);
        }
    }
    return linkDataMap;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Application(com.navercorp.pinpoint.web.vo.Application) Cell(org.apache.hadoop.hbase.Cell) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Example 35 with LinkDataMap

use of com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap in project pinpoint by naver.

the class MapStatisticsCallerMapper method mapRow.

@Override
public LinkDataMap mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return new LinkDataMap();
    }
    logger.debug("mapRow:{}", rowNum);
    final byte[] rowKey = getOriginalKey(result.getRow());
    final Buffer row = new FixedBuffer(rowKey);
    final Application caller = readCallerApplication(row);
    final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
    // key is destApplicationName.
    final LinkDataMap linkDataMap = new LinkDataMap();
    for (Cell cell : result.rawCells()) {
        final Buffer buffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
        final Application callee = readCalleeApplication(buffer);
        if (filter.filter(callee)) {
            continue;
        }
        String calleeHost = buffer.readPrefixedString();
        short histogramSlot = buffer.readShort();
        boolean isError = histogramSlot == (short) -1;
        String callerAgentId = buffer.readPrefixedString();
        long requestCount = getValueToLong(cell);
        if (logger.isDebugEnabled()) {
            logger.debug("    Fetched Caller.(New) {} {} -> {} (slot:{}/{}) calleeHost:{}", caller, callerAgentId, callee, histogramSlot, requestCount, calleeHost);
        }
        final short slotTime = (isError) ? (short) -1 : histogramSlot;
        if (StringUtils.isEmpty(calleeHost)) {
            calleeHost = callee.getName();
        }
        linkDataMap.addLinkData(caller, callerAgentId, callee, calleeHost, timestamp, slotTime, requestCount);
    }
    return linkDataMap;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Application(com.navercorp.pinpoint.web.vo.Application) Cell(org.apache.hadoop.hbase.Cell) LinkDataMap(com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)

Aggregations

LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)35 Application (com.navercorp.pinpoint.web.vo.Application)30 Test (org.junit.Test)22 LinkData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkData)20 LinkDataDuplexMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataDuplexMap)15 LinkKey (com.navercorp.pinpoint.web.vo.LinkKey)14 Range (com.navercorp.pinpoint.web.vo.Range)14 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)9 AcceptApplication (com.navercorp.pinpoint.web.service.map.AcceptApplication)6 VirtualLinkMarker (com.navercorp.pinpoint.web.service.map.VirtualLinkMarker)6 LinkCallData (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallData)4 WasOnlyProcessor (com.navercorp.pinpoint.web.service.map.processor.WasOnlyProcessor)4 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)3 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)3 TimeWindow (com.navercorp.pinpoint.web.util.TimeWindow)3 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)2 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)2 LinkCallDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkCallDataMap)2 MapStatisticsTimeWindowReducer (com.navercorp.pinpoint.web.mapper.MapStatisticsTimeWindowReducer)2 RowMapReduceResultExtractor (com.navercorp.pinpoint.web.mapper.RowMapReduceResultExtractor)2