Search in sources :

Example 66 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class HbaseApplicationTraceIndexDao method makeResponseTimeFilter.

/**
     * make the hbase filter for selecting values of y-axis(response time) in order to select transactions in scatter chart.
     * 4 bytes for elapsed time should be attached for the prefix of column qualifier for to use this filter.
     *
     * @param area
     * @param offsetTransactionId
     * @param offsetTransactionElapsed
     * @return
     */
private Filter makeResponseTimeFilter(final SelectedScatterArea area, final TransactionId offsetTransactionId, int offsetTransactionElapsed) {
    // filter by response time
    ResponseTimeRange responseTimeRange = area.getResponseTimeRange();
    byte[] responseFrom = Bytes.toBytes(responseTimeRange.getFrom());
    byte[] responseTo = Bytes.toBytes(responseTimeRange.getTo());
    FilterList filterList = new FilterList(Operator.MUST_PASS_ALL);
    filterList.addFilter(new QualifierFilter(CompareOp.GREATER_OR_EQUAL, new BinaryPrefixComparator(responseFrom)));
    filterList.addFilter(new QualifierFilter(CompareOp.LESS_OR_EQUAL, new BinaryPrefixComparator(responseTo)));
    // add offset
    if (offsetTransactionId != null) {
        final Buffer buffer = new AutomaticBuffer(32);
        buffer.putInt(offsetTransactionElapsed);
        buffer.putPrefixedString(offsetTransactionId.getAgentId());
        buffer.putSVLong(offsetTransactionId.getAgentStartTime());
        buffer.putVLong(offsetTransactionId.getTransactionSequence());
        byte[] qualifierOffset = buffer.getBuffer();
        filterList.addFilter(new QualifierFilter(CompareOp.GREATER, new BinaryPrefixComparator(qualifierOffset)));
    }
    return filterList;
}
Also used : AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) BinaryPrefixComparator(org.apache.hadoop.hbase.filter.BinaryPrefixComparator) ResponseTimeRange(com.navercorp.pinpoint.web.vo.ResponseTimeRange) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FilterList(org.apache.hadoop.hbase.filter.FilterList) QualifierFilter(org.apache.hadoop.hbase.filter.QualifierFilter)

Example 67 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class TraceIndexScatterMapper2 method createDot.

private Dot createDot(Cell cell) {
    final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
    int elapsed = valueBuffer.readVInt();
    if (elapsed < responseOffsetFrom || elapsed > responseOffsetTo) {
        return null;
    }
    int exceptionCode = valueBuffer.readSVInt();
    String agentId = valueBuffer.readPrefixedString();
    long reverseAcceptedTime = BytesUtils.bytesToLong(cell.getRowArray(), cell.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
    long acceptedTime = TimeUtils.recoveryTimeMillis(reverseAcceptedTime);
    final int qualifierOffset = cell.getQualifierOffset();
    // TransactionId transactionId = new TransactionId(buffer,
    // qualifierOffset);
    // for temporary, used TransactionIdMapper
    TransactionId transactionId = TransactionIdMapper.parseVarTransactionId(cell.getQualifierArray(), qualifierOffset, cell.getQualifierLength());
    return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Dot(com.navercorp.pinpoint.web.vo.scatter.Dot) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 68 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class TraceIndexScatterMapper3 method createDot.

private Dot createDot(Cell cell) {
    final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
    int elapsed = valueBuffer.readVInt();
    int exceptionCode = valueBuffer.readSVInt();
    String agentId = valueBuffer.readPrefixedString();
    long reverseAcceptedTime = BytesUtils.bytesToLong(cell.getRowArray(), cell.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
    long acceptedTime = TimeUtils.recoveryTimeMillis(reverseAcceptedTime);
    // TransactionId transactionId = new TransactionId(buffer,
    // qualifierOffset);
    // for temporary, used TransactionIdMapper
    TransactionId transactionId = TransactionIdMapper.parseVarTransactionId(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
    return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Dot(com.navercorp.pinpoint.web.vo.scatter.Dot) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) TransactionId(com.navercorp.pinpoint.common.util.TransactionId)

Example 69 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class SpanMapper 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();
    Map<AgentKey, SpanBo> spanMap = new LinkedHashMap<>();
    ListMultimap<AgentKey, SpanEventBo> spanEventBoListMap = ArrayListMultimap.create();
    ListMultimap<Long, AnnotationBo> annotationBoListMap = ArrayListMultimap.create();
    final SpanDecodingContext decodingContext = new SpanDecodingContext();
    decodingContext.setTransactionId(transactionId);
    for (Cell cell : rawCells) {
        decodingContext.setCollectorAcceptedTime(cell.getTimestamp());
        // only if family name is "span"
        if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_SPAN)) {
            Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            final SpanBo spanBo = spanDecoder.decodeSpanBo(qualifierBuffer, valueBuffer, decodingContext);
            AgentKey agentKey = newAgentKey(spanBo);
            spanMap.put(agentKey, spanBo);
        } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_TERMINALSPAN)) {
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            SpanEventBo spanEventBo = spanDecoder.decodeSpanEventBo(qualifier, valueBuffer, decodingContext);
            AgentKey agentKey = newAgentKey(decodingContext);
            spanEventBoListMap.put(agentKey, spanEventBo);
        } else if (CellUtil.matchingFamily(cell, HBaseTables.TRACES_CF_ANNOTATION)) {
            final Buffer qualifier = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            final Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            List<AnnotationBo> annotationBoList = annotationBoDecoder.decode(qualifier, valueBuffer, decodingContext);
            if (CollectionUtils.isNotEmpty(annotationBoList)) {
                long spanId = decodingContext.getSpanId();
                annotationBoListMap.putAll(spanId, annotationBoList);
            }
        }
        spanDecoder.next(decodingContext);
    }
    decodingContext.finish();
    for (Map.Entry<AgentKey, SpanEventBo> spanBoEntry : spanEventBoListMap.entries()) {
        final AgentKey agentKey = spanBoEntry.getKey();
        SpanBo spanBo = spanMap.get(agentKey);
        if (spanBo != null) {
            SpanEventBo value = spanBoEntry.getValue();
            spanBo.addSpanEvent(value);
        } else {
            if (logger.isInfoEnabled()) {
                logger.info("Span not exist spanId:{} spanEvent:{}", spanBoEntry.getKey(), spanBoEntry.getValue());
            }
        }
    }
    List<SpanBo> spanList = Lists.newArrayList(spanMap.values());
    if (!annotationBoListMap.isEmpty()) {
        addAnnotation(spanList, annotationBoListMap);
    }
    return spanList;
}
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.v1.SpanDecodingContext) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) Cell(org.apache.hadoop.hbase.Cell) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 70 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.

the class ApplicationMapStatisticsUtils method makeColumnName.

public static byte[] makeColumnName(short serviceType, String applicationName, String destHost, short slotNumber) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    if (destHost == null) {
        // throw new NullPointerException("destHost must not be null");
        destHost = "";
    }
    // approximate size of destHost
    final Buffer buffer = new AutomaticBuffer(BytesUtils.SHORT_BYTE_LENGTH + PinpointConstants.APPLICATION_NAME_MAX_LEN + destHost.length() + BytesUtils.SHORT_BYTE_LENGTH);
    buffer.putShort(serviceType);
    buffer.putShort(slotNumber);
    buffer.put2PrefixedString(applicationName);
    buffer.putBytes(BytesUtils.toBytes(destHost));
    return buffer.getBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)107 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)76 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)57 ByteBuffer (java.nio.ByteBuffer)27 Test (org.junit.Test)24 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)15 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)11 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)11 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)9 Cell (org.apache.hadoop.hbase.Cell)9 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)8 ArrayList (java.util.ArrayList)6 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)5 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)4 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)4 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)4 Put (org.apache.hadoop.hbase.client.Put)4 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)3