Search in sources :

Example 1 with AutomaticBuffer

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

the class AnnotationBoDecoderTest method testWriteValue.

@Test
public void testWriteValue() throws Exception {
    final AnnotationBo annotation = new AnnotationBo();
    annotation.setKey(AnnotationKey.API.getCode());
    final String value = RandomStringUtils.random(RandomUtils.nextInt(0, 20));
    annotation.setValue(value);
    final Buffer buffer = new AutomaticBuffer(128);
    this.serializer.writeAnnotationList(Lists.newArrayList(annotation), buffer);
    buffer.setOffset(0);
    List<AnnotationBo> decode = annotationBoDecoder.decode(buffer);
    Assert.assertEquals(decode.size(), 1);
    AnnotationBo decodedAnnotation = decode.get(0);
    Assert.assertEquals(annotation.getKey(), decodedAnnotation.getKey());
    Assert.assertEquals(annotation.getValue(), decodedAnnotation.getValue());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AnnotationBo(com.navercorp.pinpoint.common.server.bo.AnnotationBo) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 2 with AutomaticBuffer

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

the class TransactionIdUtils method writeTransactionId.

private static Buffer writeTransactionId(String agentId, long agentStartTime, long transactionSequence) {
    // agentId may be null
    // version + prefixed size + string + long + long
    final Buffer buffer = new AutomaticBuffer(1 + 5 + 24 + 10 + 10);
    buffer.putByte(VERSION);
    buffer.putPrefixedString(agentId);
    buffer.putVLong(agentStartTime);
    buffer.putVLong(transactionSequence);
    return buffer;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) 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 3 with AutomaticBuffer

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

the class AnnotationTranscoder method encodeIntStringValue.

private byte[] encodeIntStringValue(Object value) {
    final TIntStringValue tIntStringValue = (TIntStringValue) value;
    final int intValue = tIntStringValue.getIntValue();
    final byte[] stringValue = BytesUtils.toBytes(tIntStringValue.getStringValue());
    // TODO increase by a more precise value
    final int bufferSize = getBufferSize(stringValue, 4 + 8);
    final Buffer buffer = new AutomaticBuffer(bufferSize);
    buffer.putSVInt(intValue);
    buffer.putPrefixedBytes(stringValue);
    return buffer.getBuffer();
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 4 with AutomaticBuffer

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

the class AnnotationTranscoder method encodeIntStringStringValue.

private byte[] encodeIntStringStringValue(Object o) {
    final TIntStringStringValue tIntStringStringValue = (TIntStringStringValue) o;
    final int intValue = tIntStringStringValue.getIntValue();
    final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
    final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
    // TODO increase by a more precise value
    final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
    final Buffer buffer = new AutomaticBuffer(bufferSize);
    buffer.putSVInt(intValue);
    buffer.putPrefixedBytes(stringValue1);
    buffer.putPrefixedBytes(stringValue2);
    return buffer.getBuffer();
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) TIntStringStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringStringValue) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 5 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 TSpan span) {
    if (span == null) {
        throw new NullPointerException("span must not be null");
    }
    final Buffer buffer = new AutomaticBuffer(10 + AGENT_NAME_MAX_LEN);
    buffer.putVInt(span.getElapsed());
    buffer.putSVInt(span.getErr());
    buffer.putPrefixedString(span.getAgentId());
    final byte[] value = buffer.getBuffer();
    long acceptedTime = acceptedTimeService.getAcceptedTime();
    final byte[] distributedKey = createRowKey(span, acceptedTime);
    Put put = new Put(distributedKey);
    put.addColumn(APPLICATION_TRACE_INDEX_CF_TRACE, makeQualifier(span), acceptedTime, value);
    boolean success = hbaseTemplate.asyncPut(APPLICATION_TRACE_INDEX, put);
    if (!success) {
        hbaseTemplate.put(APPLICATION_TRACE_INDEX, put);
    }
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Put(org.apache.hadoop.hbase.client.Put)

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