Search in sources :

Example 11 with SpanBo

use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.

the class SpanBitFiledTest method testApplicationServiceTypeEncodingStrategy_PREV_TYPE_EQUALS.

@Test
public void testApplicationServiceTypeEncodingStrategy_PREV_TYPE_EQUALS() {
    SpanBo spanBo = new SpanBo();
    spanBo.setServiceType((short) 1000);
    spanBo.setApplicationServiceType((short) 1000);
    SpanBitFiled spanBitFiled = SpanBitFiled.build(spanBo);
    Assert.assertEquals(spanBitFiled.getApplicationServiceTypeEncodingStrategy(), ServiceTypeEncodingStrategy.PREV_EQUALS);
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 12 with SpanBo

use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.

the class SpanBitFiledTest method testRoot_1.

@Test
public void testRoot_1() throws Exception {
    SpanBo spanBo = new SpanBo();
    spanBo.setParentSpanId(-1);
    SpanBitFiled spanBitFiled = SpanBitFiled.build(spanBo);
    Assert.assertTrue(spanBitFiled.isRoot());
    spanBitFiled.setRoot(false);
    Assert.assertFalse(spanBitFiled.isRoot());
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 13 with SpanBo

use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.

the class SpanBitFiledTest method testHasException_2.

@Test
public void testHasException_2() {
    SpanBo spanBo = new SpanBo();
    SpanBitFiled spanBitFiled = SpanBitFiled.build(spanBo);
    Assert.assertFalse(spanBitFiled.isSetHasException());
    spanBitFiled.maskAll();
    spanBitFiled.setHasException(false);
    Assert.assertFalse(spanBitFiled.isSetHasException());
}
Also used : SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) Test(org.junit.Test)

Example 14 with SpanBo

use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.

the class SpanMapperV2 method bindSpanChunk.

private List<SpanBo> bindSpanChunk(ListMultimap<AgentKey, SpanBo> spanMap, List<SpanChunkBo> spanChunkList) {
    for (SpanChunkBo spanChunkBo : spanChunkList) {
        AgentKey agentKey = newAgentKey(spanChunkBo);
        List<SpanBo> matchedSpanBoList = spanMap.get(agentKey);
        if (matchedSpanBoList != null) {
            final int spanIdCollisionSize = matchedSpanBoList.size();
            if (spanIdCollisionSize > 1) {
                // exceptional case dump
                logger.warn("spanIdCollision {}", matchedSpanBoList);
            }
            int agentLevelCollisionCount = 0;
            for (SpanBo spanBo : matchedSpanBoList) {
                if (StringUtils.equals(spanBo.getAgentId(), spanChunkBo.getAgentId())) {
                    spanBo.addSpanEventBoList(spanChunkBo.getSpanEventBoList());
                    agentLevelCollisionCount++;
                }
            }
            if (agentLevelCollisionCount > 1) {
                // exceptional case dump
                logger.warn("agentLevelCollision {}", matchedSpanBoList);
            }
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Span not exist spanId:{} spanChunk:{}", agentKey, spanChunkBo);
            }
        }
    }
    return Lists.newArrayList(spanMap.values());
}
Also used : SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo)

Example 15 with SpanBo

use of com.navercorp.pinpoint.common.server.bo.SpanBo in project pinpoint by naver.

the class SpanMapperV2 method mapRow.

@Override
public List<SpanBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    byte[] rowKey = result.getRow();
    final TransactionId transactionId = this.rowKeyDecoder.decodeRowKey(rowKey);
    final Cell[] rawCells = result.rawCells();
    ListMultimap<AgentKey, SpanBo> spanMap = LinkedListMultimap.create();
    List<SpanChunkBo> spanChunkList = new ArrayList<>();
    final SpanDecodingContext decodingContext = new SpanDecodingContext();
    decodingContext.setTransactionId(transactionId);
    for (Cell cell : rawCells) {
        SpanDecoder spanDecoder = null;
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HBaseTables.TRACE_V2_CF_SPAN)) {
            decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer columnValue = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            spanDecoder = resolveDecoder(columnValue);
            final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
            if (decodeObject instanceof SpanBo) {
                SpanBo spanBo = (SpanBo) decodeObject;
                if (logger.isDebugEnabled()) {
                    logger.debug("spanBo:{}", spanBo);
                }
                AgentKey agentKey = newAgentKey(spanBo);
                spanMap.put(agentKey, spanBo);
            } else if (decodeObject instanceof SpanChunkBo) {
                SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
                if (logger.isDebugEnabled()) {
                    logger.debug("spanChunkBo:{}", spanChunkBo);
                }
                spanChunkList.add(spanChunkBo);
            }
        } else {
            logger.warn("Unknown ColumnFamily :{}", Bytes.toStringBinary(CellUtil.cloneFamily(cell)));
        }
        nextCell(spanDecoder, decodingContext);
    }
    decodingContext.finish();
    return buildSpanBoList(spanMap, spanChunkList);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) SpanDecoder(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecoder) ArrayList(java.util.ArrayList) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) Cell(org.apache.hadoop.hbase.Cell)

Aggregations

SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)65 Test (org.junit.Test)32 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)14 ArrayList (java.util.ArrayList)10 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)8 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)8 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)7 ByteBuffer (java.nio.ByteBuffer)7 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)4 BasePinpointTest (com.navercorp.pinpoint.test.junit4.BasePinpointTest)4 IsRootSpan (com.navercorp.pinpoint.test.junit4.IsRootSpan)4 List (java.util.List)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.SpanDecodingContext)2 Application (com.navercorp.pinpoint.web.vo.Application)2 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)2 Cell (org.apache.hadoop.hbase.Cell)2 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)1 SpanDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.trace.v1.SpanDecodingContext)1