Search in sources :

Example 46 with Buffer

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

the class ResponseTimeMapper method createResponseTime.

private ResponseTime createResponseTime(byte[] rowKey) {
    final Buffer row = new FixedBuffer(rowKey);
    String applicationName = row.read2PrefixedString();
    short serviceTypeCode = row.readShort();
    final long timestamp = TimeUtils.recoveryTimeMillis(row.readLong());
    ServiceType serviceType = registry.findServiceType(serviceTypeCode);
    return new ResponseTime(applicationName, serviceType, timestamp);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) ResponseTime(com.navercorp.pinpoint.web.vo.ResponseTime)

Example 47 with Buffer

use of com.navercorp.pinpoint.common.buffer.Buffer 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 48 with Buffer

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

Example 49 with Buffer

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

the class ApplicationStatMapper method mapRow.

@Override
public List<JoinStatBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    final byte[] distributedRowKey = result.getRow();
    final String applicationId = this.hbaseOperationFactory.getApplicationId(distributedRowKey);
    final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey);
    List<JoinStatBo> dataPoints = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        if (CellUtil.matchingFamily(cell, HbaseColumnFamily.APPLICATION_STAT_STATISTICS.getName())) {
            Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer);
            ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
            decodingContext.setApplicationId(applicationId);
            decodingContext.setBaseTimestamp(baseTimestamp);
            decodingContext.setTimestampDelta(timestampDelta);
            List<JoinStatBo> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
            for (JoinStatBo candidate : candidates) {
                long timestamp = candidate.getTimestamp();
                if (this.filter.filter(timestamp)) {
                    continue;
                }
                dataPoints.add(candidate);
            }
        }
    }
    // Reverse sort as timestamp is stored in a reversed order.
    dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR);
    return dataPoints;
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Cell(org.apache.hadoop.hbase.Cell)

Example 50 with Buffer

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

the class ApiMetaDataMapper method mapRow.

@Override
public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    final byte[] rowKey = getOriginalKey(result.getRow());
    final MetaDataRowKey key = decoder.decodeRowKey(rowKey);
    List<ApiMetaDataBo> apiMetaDataList = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        final byte[] value = getValue(cell);
        Buffer buffer = new FixedBuffer(value);
        final String apiInfo = buffer.readPrefixedString();
        final int lineNumber = buffer.readInt();
        MethodTypeEnum methodTypeEnum = MethodTypeEnum.DEFAULT;
        if (buffer.hasRemaining()) {
            methodTypeEnum = MethodTypeEnum.valueOf(buffer.readInt());
        }
        ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(key.getAgentId(), key.getAgentStartTime(), key.getId(), lineNumber, methodTypeEnum, apiInfo);
        apiMetaDataList.add(apiMetaDataBo);
        if (logger.isDebugEnabled()) {
            logger.debug("read apiAnnotation:{}", apiMetaDataBo);
        }
    }
    return apiMetaDataList;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) MetaDataRowKey(com.navercorp.pinpoint.common.server.bo.serializer.metadata.MetaDataRowKey) ArrayList(java.util.ArrayList) MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) Cell(org.apache.hadoop.hbase.Cell)

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