Search in sources :

Example 91 with Buffer

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

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

the class BytesUtilsTest method assertVar32.

private void assertVar32(int value) {
    final int computeBufferSize = BytesUtils.computeVar32Size(value);
    final byte[] bytes = new byte[computeBufferSize];
    BytesUtils.writeVar32(value, bytes, 0);
    final Buffer buffer = new FixedBuffer(bytes);
    final int varInt = buffer.readVInt();
    Assert.assertEquals("check value", value, varInt);
    assertEquals("check buffer size", buffer.getOffset(), computeBufferSize);
    final int varInt_ByteUtils1 = BytesUtils.bytesToVar32(buffer.getBuffer(), 0);
    Assert.assertEquals("check value", value, varInt_ByteUtils1);
    final byte[] max_buffer = new byte[BytesUtils.VLONG_MAX_SIZE];
    BytesUtils.writeVar32(value, max_buffer, 0);
    final int varInt_ByteUtils2 = BytesUtils.bytesToVar32(max_buffer, 0);
    Assert.assertEquals("check value", value, varInt_ByteUtils2);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) ByteBuffer(java.nio.ByteBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 93 with Buffer

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

the class BytesUtilsTest method assertVar64.

private void assertVar64(long value) {
    final int computeBufferSize = BytesUtils.computeVar64Size(value);
    final byte[] bytes = new byte[computeBufferSize];
    BytesUtils.writeVar64(value, bytes, 0);
    final Buffer buffer = new FixedBuffer(bytes);
    final long varLong = buffer.readVLong();
    Assert.assertEquals("check value", value, varLong);
    assertEquals("check buffer size", buffer.getOffset(), computeBufferSize);
    final long varLong_ByteUtils1 = BytesUtils.bytesToVar64(buffer.getBuffer(), 0);
    Assert.assertEquals("check value", value, varLong_ByteUtils1);
    final byte[] max_buffer = new byte[BytesUtils.VLONG_MAX_SIZE];
    BytesUtils.writeVar64(value, max_buffer, 0);
    final long varLong_ByteUtils2 = BytesUtils.bytesToVar64(max_buffer, 0);
    Assert.assertEquals("check value", value, varLong_ByteUtils2);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) ByteBuffer(java.nio.ByteBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 94 with Buffer

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

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

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