Search in sources :

Example 11 with TransactionId

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

the class TransactionIdMapper method parseVarTransactionId.

public static TransactionId parseVarTransactionId(byte[] bytes, int offset, int length) {
    if (bytes == null) {
        throw new NullPointerException("bytes must not be null");
    }
    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.util.TransactionId)

Example 12 with TransactionId

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

the class HbaseTraceDaoV2 method select0.

private List<List<SpanBo>> select0(List<TransactionId> transactionIdList, byte[] columnFamily, Filter filter) {
    if (CollectionUtils.isEmpty(transactionIdList)) {
        return Collections.emptyList();
    }
    final List<Get> multiGet = new ArrayList<>(transactionIdList.size());
    for (TransactionId transactionId : transactionIdList) {
        final Get get = createGet(transactionId, columnFamily, filter);
        multiGet.add(get);
    }
    return template2.get(HBaseTables.TRACE_V2, multiGet, spanMapperV2);
}
Also used : Get(org.apache.hadoop.hbase.client.Get) ArrayList(java.util.ArrayList) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 13 with TransactionId

use of com.navercorp.pinpoint.common.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);
    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)

Example 14 with TransactionId

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

the class ScatterDataTest method createDotList.

private List<Dot> createDotList(String agentId, String transactionAgentId, int createSize, long from) {
    long currentTime = System.currentTimeMillis();
    List<TransactionId> transactionIdList = new ArrayList<>(createSize);
    for (int i = 0; i < createSize; i++) {
        transactionIdList.add(new TransactionId(transactionAgentId, currentTime, i));
    }
    long acceptedTime = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
    int executionTime = (int) Math.abs(ThreadLocalRandom.current().nextLong(60 * 1000));
    List<Dot> dotList = new ArrayList<>(createSize);
    for (int i = 0; i < createSize; i++) {
        int exceptionCode = ThreadLocalRandom.current().nextInt(0, 2);
        dotList.add(new Dot(transactionIdList.get(i), Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from), executionTime, exceptionCode, agentId));
    }
    long seed = System.nanoTime();
    Collections.shuffle(dotList, new Random(seed));
    return dotList;
}
Also used : ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Random(java.util.Random) ArrayList(java.util.ArrayList) Dot(com.navercorp.pinpoint.web.vo.scatter.Dot) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 15 with TransactionId

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

the class ScatterDataTest method addDotTest2.

@Test
public void addDotTest2() throws Exception {
    long from = 1000;
    long to = 10000;
    int xGroupUnit = 100;
    int yGroupUnit = 100;
    ScatterData scatterData = new ScatterData(from, to, xGroupUnit, yGroupUnit);
    long currentTime = System.currentTimeMillis();
    TransactionId transactionId1 = new TransactionId(transactionAgentId, currentTime, 1);
    TransactionId transactionId2 = new TransactionId(transactionAgentId, currentTime, 2);
    long acceptedTime = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
    int executionTime = (int) Math.abs(ThreadLocalRandom.current().nextLong(60 * 1000));
    long acceptedTime2 = Math.max(Math.abs(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)), from);
    Dot dot1 = new Dot(transactionId1, acceptedTime2, executionTime, 0, agentId);
    Dot dot2 = new Dot(transactionId2, acceptedTime2, executionTime, 1, agentId);
    scatterData.addDot(dot1);
    scatterData.addDot(dot2);
    Map<Long, DotGroups> scatterDataMap = scatterData.getScatterDataMap();
    Collection<DotGroups> values = scatterDataMap.values();
    Assert.assertTrue(values.size() == 1);
    for (DotGroups dotGroups : values) {
        Map<Dot, DotGroup> dotGroupLeaders = dotGroups.getDotGroupLeaders();
        Assert.assertTrue(dotGroupLeaders.keySet().size() == 2);
    }
}
Also used : Dot(com.navercorp.pinpoint.web.vo.scatter.Dot) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) Test(org.junit.Test)

Aggregations

TransactionId (com.navercorp.pinpoint.common.util.TransactionId)44 ArrayList (java.util.ArrayList)11 Dot (com.navercorp.pinpoint.web.vo.scatter.Dot)9 Test (org.junit.Test)9 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)8 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)8 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)7 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)5 List (java.util.List)5 Put (org.apache.hadoop.hbase.client.Put)4 ByteBuffer (java.nio.ByteBuffer)3 Cell (org.apache.hadoop.hbase.Cell)3 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)2 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)2 ScatterData (com.navercorp.pinpoint.web.scatter.ScatterData)2 LimitedScanResult (com.navercorp.pinpoint.web.vo.LimitedScanResult)2 Get (org.apache.hadoop.hbase.client.Get)2 Scan (org.apache.hadoop.hbase.client.Scan)2 FilterList (org.apache.hadoop.hbase.filter.FilterList)2