Search in sources :

Example 16 with TransactionId

use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.

the class TransactionIdComparatorTest method order.

@Test
public void order() {
    List<Integer> numbers = new ArrayList<>(10);
    for (int i = 0; i < 10; i++) {
        numbers.add(i);
    }
    Collections.shuffle(numbers);
    List<TransactionId> list = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        list.add(new TransactionId("A", 1, numbers.get(i)));
    }
    logger.debug("{}", list);
    Collections.sort(list, comparator);
    int i = 0;
    for (TransactionId transactionId : list) {
        Assert.assertEquals(i, transactionId.getTransactionSequence());
        i++;
    }
    logger.debug("{}", list);
}
Also used : ArrayList(java.util.ArrayList) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Test(org.junit.Test)

Example 17 with TransactionId

use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.

the class TransactionIdComparatorTest method diffSeqAsc.

@Test
public void diffSeqAsc() {
    TransactionId id1 = new TransactionId("A1", 1, 1);
    TransactionId id2 = new TransactionId("A1", 1, 2);
    Assert.assertEquals(-1, comparator.compare(id1, id2));
}
Also used : TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Test(org.junit.Test)

Example 18 with TransactionId

use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.

the class TransactionIdComparatorTest method diffSeqDesc.

@Test
public void diffSeqDesc() {
    TransactionId id1 = new TransactionId("A1", 1, 2);
    TransactionId id2 = new TransactionId("A1", 1, 1);
    Assert.assertEquals(1, comparator.compare(id1, id2));
}
Also used : TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Test(org.junit.Test)

Example 19 with TransactionId

use of com.navercorp.pinpoint.common.profiler.util.TransactionId 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);
    final BufferFactory bufferFactory = new BufferFactory(cacheSize);
    for (Cell cell : rawCells) {
        SpanDecoder spanDecoder = null;
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HbaseColumnFamily.TRACE_V2_SPAN.getName())) {
            decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
            final Buffer qualifier = bufferFactory.createBuffer(CellUtil.cloneQualifier(cell));
            final Buffer columnValue = bufferFactory.createBuffer(CellUtil.cloneValue(cell));
            spanDecoder = resolveDecoder(columnValue);
            final Object decodeObject = spanDecoder.decode(qualifier, columnValue, decodingContext);
            if (decodeObject instanceof SpanBo) {
                SpanBo spanBo = (SpanBo) decodeObject;
                if (logger.isTraceEnabled()) {
                    logger.trace("spanBo:{}", spanBo);
                }
                AgentKey agentKey = newAgentKey(spanBo);
                spanMap.put(agentKey, spanBo);
            } else if (decodeObject instanceof SpanChunkBo) {
                SpanChunkBo spanChunkBo = (SpanChunkBo) decodeObject;
                if (logger.isTraceEnabled()) {
                    logger.trace("spanChunkBo:{}", spanChunkBo);
                }
                spanChunkList.add(spanChunkBo);
            }
        } else {
            if (logger.isWarnEnabled()) {
                String columnFamily = Bytes.toStringBinary(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength());
                logger.warn("Unknown ColumnFamily :{}", columnFamily);
            }
        }
        nextCell(spanDecoder, decodingContext);
    }
    decodingContext.finish();
    return buildSpanBoList(spanMap, spanChunkList);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ByteBuffer(java.nio.ByteBuffer) StringCacheableBuffer(com.navercorp.pinpoint.common.buffer.StringCacheableBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) 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) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId) Cell(org.apache.hadoop.hbase.Cell)

Example 20 with TransactionId

use of com.navercorp.pinpoint.common.profiler.util.TransactionId in project pinpoint by naver.

the class TransactionIdMapper method parseVarTransactionId.

public static TransactionId parseVarTransactionId(byte[] bytes, int offset, int length) {
    Objects.requireNonNull(bytes, "bytes");
    final Buffer buffer = new OffsetFixedBuffer(bytes, offset, length);
    // skip elapsed time (not used) hbase column prefix - only used for filtering.
    // Not sure if we can reduce the data size any further.
    // buffer.readInt();
    String agentId = buffer.readPrefixedString();
    long agentStartTime = buffer.readSVLong();
    long transactionSequence = buffer.readVLong();
    return new TransactionId(agentId, agentStartTime, transactionSequence);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) TransactionId(com.navercorp.pinpoint.common.profiler.util.TransactionId)

Aggregations

TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)51 Test (org.junit.Test)18 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)15 ArrayList (java.util.ArrayList)12 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)9 ByteBuffer (java.nio.ByteBuffer)6 List (java.util.List)6 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)4 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)4 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)4 ColumnGetCount (com.navercorp.pinpoint.common.hbase.bo.ColumnGetCount)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)3 CallTreeIterator (com.navercorp.pinpoint.web.calltree.span.CallTreeIterator)3 SpanResult (com.navercorp.pinpoint.web.service.SpanResult)3 RecordSet (com.navercorp.pinpoint.web.vo.callstacks.RecordSet)3 TableName (org.apache.hadoop.hbase.TableName)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3