Search in sources :

Example 11 with AutomaticBuffer

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

the class AgentStatDataPointCodecTest method test_timestamps.

@Test
public void test_timestamps() {
    // Given
    final long initialTimestamp = System.currentTimeMillis();
    final long intervalMs = 5000L;
    final long randomDelta = 10L;
    final int numValues = (int) (Math.random() * 100) + 1;
    final List<Long> expectedTimestamps = createTimestamps(initialTimestamp, intervalMs, randomDelta, numValues);
    final Buffer timestampBuffer = new AutomaticBuffer();
    // When
    codec.encodeTimestamps(timestampBuffer, expectedTimestamps);
    // Then
    List<Long> decodedTimestamps = codec.decodeTimestamps(initialTimestamp, new FixedBuffer(timestampBuffer.getBuffer()), numValues);
    Assert.assertEquals(expectedTimestamps, decodedTimestamps);
}
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) Test(org.junit.Test)

Example 12 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 13 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 14 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 15 with AutomaticBuffer

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

the class HbaseHostApplicationMapDao method createKey.

private byte[] createKey(Application parentApplication, long time) {
    Buffer buffer = new AutomaticBuffer();
    buffer.putPadString(parentApplication.getName(), HBaseTables.APPLICATION_NAME_MAX_LEN);
    buffer.putShort(parentApplication.getServiceTypeCode());
    buffer.putLong(time);
    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

AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)39 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)39 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)13 ByteBuffer (java.nio.ByteBuffer)9 Test (org.junit.Test)6 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 Put (org.apache.hadoop.hbase.client.Put)2 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 EncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.strategy.EncodingStrategy)1 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)1 SpanBitFiled (com.navercorp.pinpoint.common.server.bo.serializer.trace.v2.bitfield.SpanBitFiled)1 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)1 HistogramSlot (com.navercorp.pinpoint.common.trace.HistogramSlot)1 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)1 TIntStringStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringStringValue)1