Search in sources :

Example 61 with AutomaticBuffer

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

the class AgentLifeCycleValueMapper method mapValue.

@Override
public byte[] mapValue(AgentLifeCycleBo value) {
    final Buffer buffer = new AutomaticBuffer();
    buffer.putInt(value.getVersion());
    buffer.putPrefixedString(value.getAgentId());
    buffer.putLong(value.getStartTimestamp());
    buffer.putLong(value.getEventTimestamp());
    buffer.putLong(value.getEventIdentifier());
    buffer.putShort(value.getAgentLifeCycleState().getCode());
    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)

Example 62 with AutomaticBuffer

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

the class SpanEncoderV0 method encodeQualifier.

private ByteBuffer encodeQualifier(byte type, BasicSpan basicSpan, SpanEventBo firstEvent, LocalAsyncIdBo localAsyncId) {
    final Buffer buffer = new AutomaticBuffer(128);
    buffer.putByte(type);
    buffer.putPrefixedString(basicSpan.getApplicationId());
    buffer.putPrefixedString(basicSpan.getAgentId());
    buffer.putVLong(basicSpan.getAgentStartTime());
    buffer.putLong(basicSpan.getSpanId());
    if (firstEvent != null) {
        buffer.putSVInt(firstEvent.getSequence());
        final byte bitField = SpanEventQualifierBitField.buildBitField(localAsyncId);
        buffer.putByte(bitField);
        // case : async span
        if (SpanEventQualifierBitField.isSetAsync(bitField)) {
            buffer.putInt(localAsyncId.getAsyncId());
            buffer.putVInt(localAsyncId.getSequence());
        }
    } else {
    // simple trace case
    // buffer.putSVInt((short) -1);
    // byte cfBitField = SpanEventQualifierBitField.setAsync((byte) 0, false);
    // buffer.putByte(cfBitField);
    }
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 63 with AutomaticBuffer

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

the class SpanEncoderV0 method encodeSpanColumnValue.

@Override
public ByteBuffer encodeSpanColumnValue(SpanEncodingContext<SpanBo> encodingContext) {
    final SpanBo span = encodingContext.getValue();
    final SpanBitFiled bitField = SpanBitFiled.build(span);
    final Buffer buffer = new AutomaticBuffer(256);
    final byte version = span.getRawVersion();
    buffer.putByte(version);
    // bit field
    buffer.putByte(bitField.getBitField());
    final short serviceType = span.getServiceType();
    buffer.putShort(serviceType);
    switch(bitField.getApplicationServiceTypeEncodingStrategy()) {
        case PREV_EQUALS:
            break;
        case RAW:
            buffer.putShort(span.getApplicationServiceType());
            break;
        default:
            throw new IllegalStateException("applicationServiceType");
    }
    // buffer.put(spanID);
    if (!bitField.isRoot()) {
        buffer.putLong(span.getParentSpanId());
    }
    // prevSpanEvent coding
    final long startTime = span.getStartTime();
    final long startTimeDelta = span.getCollectorAcceptTime() - startTime;
    buffer.putVLong(startTimeDelta);
    buffer.putVInt(span.getElapsed());
    buffer.putPrefixedString(span.getRpc());
    buffer.putPrefixedString(span.getEndPoint());
    buffer.putPrefixedString(span.getRemoteAddr());
    buffer.putSVInt(span.getApiId());
    // BIT flag
    if (bitField.isSetErrorCode()) {
        buffer.putInt(span.getErrCode());
    }
    if (bitField.isSetHasException()) {
        buffer.putSVInt(span.getExceptionId());
        buffer.putPrefixedString(span.getExceptionMessage());
    }
    if (bitField.isSetFlag()) {
        buffer.putShort(span.getFlag());
    }
    if (bitField.isSetLoggingTransactionInfo()) {
        buffer.putByte(span.getLoggingTransactionInfo());
    }
    buffer.putPrefixedString(span.getAcceptorHost());
    if (bitField.isSetAnnotation()) {
        List<AnnotationBo> annotationBoList = span.getAnnotationBoList();
        writeAnnotationList(buffer, annotationBoList, encodingContext);
    }
    final List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
    writeSpanEventList(buffer, spanEventBoList, encodingContext);
    return buffer.wrapByteBuffer();
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) ByteBuffer(java.nio.ByteBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) SpanBitFiled(com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo)

Example 64 with AutomaticBuffer

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

the class HbaseApplicationTraceIndexDao method insert.

@Override
public void insert(final SpanBo span) {
    Objects.requireNonNull(span, "span");
    if (logger.isDebugEnabled()) {
        logger.debug("insert ApplicationTraceIndex: {}", span);
    }
    // Assert agentId
    CollectorUtils.checkAgentId(span.getAgentId());
    // Assert applicationName
    CollectorUtils.checkApplicationName(span.getApplicationId());
    final Buffer buffer = new AutomaticBuffer(10 + HbaseTableConstants.AGENT_ID_MAX_LEN);
    buffer.putVInt(span.getElapsed());
    buffer.putSVInt(span.getErrCode());
    buffer.putPrefixedString(span.getAgentId());
    final byte[] value = buffer.getBuffer();
    final long acceptedTime = acceptedTimeService.getAcceptedTime();
    final byte[] distributedKey = createRowKey(span, acceptedTime);
    final Put put = new Put(distributedKey);
    put.addColumn(DESCRIPTOR.getName(), makeQualifier(span), acceptedTime, value);
    final TableName applicationTraceIndexTableName = tableNameProvider.getTableName(DESCRIPTOR.getTable());
    hbaseTemplate.asyncPut(applicationTraceIndexTableName, put);
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) TableName(org.apache.hadoop.hbase.TableName) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Put(org.apache.hadoop.hbase.client.Put)

Example 65 with AutomaticBuffer

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

the class EncodingStrategyTestBase method testStrategy.

public <T> void testStrategy(List<T> expectedValues, EncodingStrategy<T> strategy) {
    Buffer encodeBuffer = new AutomaticBuffer();
    strategy.encodeValues(encodeBuffer, expectedValues);
    Buffer decodeBuffer = new FixedBuffer(encodeBuffer.getBuffer());
    List<T> actualValues = strategy.decodeValues(decodeBuffer, expectedValues.size());
    Assert.assertEquals(expectedValues, actualValues);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Aggregations

AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)68 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)68 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)30 Test (org.junit.Test)16 ByteBuffer (java.nio.ByteBuffer)15 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)10 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)10 Date (java.util.Date)10 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Put (org.apache.hadoop.hbase.client.Put)4 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)2 TableName (org.apache.hadoop.hbase.TableName)2 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1