Search in sources :

Example 6 with AutomaticBuffer

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

the class ServiceInfoBo method writeValue.

public byte[] writeValue() {
    final Buffer buffer = new AutomaticBuffer();
    buffer.put2PrefixedString(this.serviceName);
    int numServiceLibs = this.serviceLibs == null ? 0 : this.serviceLibs.size();
    buffer.putVInt(numServiceLibs);
    for (int i = 0; i < numServiceLibs; ++i) {
        buffer.put2PrefixedString(this.serviceLibs.get(i));
    }
    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) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer)

Example 7 with AutomaticBuffer

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

the class AgentEventValueMapper method mapValue.

@Override
public byte[] mapValue(AgentEventBo value) {
    final Buffer buffer = new AutomaticBuffer();
    buffer.putInt(value.getVersion());
    buffer.putPrefixedString(value.getAgentId());
    buffer.putLong(value.getStartTimestamp());
    buffer.putLong(value.getEventTimestamp());
    buffer.putPrefixedBytes(value.getEventBody());
    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 8 with AutomaticBuffer

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

the class CalleeColumnName method getColumnName.

public byte[] getColumnName() {
    final Buffer buffer = new AutomaticBuffer(64);
    buffer.putShort(calleeServiceType);
    buffer.putPrefixedString(calleeApplicationName);
    buffer.putPrefixedString(callHost);
    buffer.putShort(columnSlotNumber);
    buffer.putPrefixedString(callerAgentId);
    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 9 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 10 with AutomaticBuffer

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

the class AgentStatCodecTestBase method runTest.

private void runTest() {
    // Given
    final long initialTimestamp = System.currentTimeMillis();
    final long baseTimestamp = AgentStatUtils.getBaseTimestamp(initialTimestamp);
    final long timestampDelta = initialTimestamp - baseTimestamp;
    final List<T> expectedAgentStats = createAgentStats(AGENT_ID, AGENT_START_TIMESTAMP, initialTimestamp);
    // When
    Buffer encodedValueBuffer = new AutomaticBuffer();
    getCodec().encodeValues(encodedValueBuffer, expectedAgentStats);
    // Then
    AgentStatDecodingContext decodingContext = new AgentStatDecodingContext();
    decodingContext.setAgentId(AGENT_ID);
    decodingContext.setBaseTimestamp(baseTimestamp);
    decodingContext.setTimestampDelta(timestampDelta);
    Buffer valueBuffer = new FixedBuffer(encodedValueBuffer.getBuffer());
    List<T> actualAgentStats = getCodec().decodeValues(valueBuffer, decodingContext);
    Assert.assertEquals(expectedAgentStats.size(), actualAgentStats.size());
    for (int i = 0; i < expectedAgentStats.size(); ++i) {
        T expectedAgentStat = expectedAgentStats.get(i);
        T actualAgentStat = actualAgentStats.get(i);
        verify(expectedAgentStat, actualAgentStat);
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AgentStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) AgentStatDataPoint(com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)

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