Search in sources :

Example 1 with Buffer

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

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

the class SpanBoTest method serialize_V1.

@Test
public void serialize_V1() {
    final SpanBo spanBo = new SpanBo();
    spanBo.setAgentId("agentId");
    spanBo.setApplicationId("applicationId");
    spanBo.setEndPoint("end");
    spanBo.setRpc("rpc");
    spanBo.setParentSpanId(5);
    spanBo.setAgentStartTime(1);
    TransactionId transactionId = new TransactionId("agentId", 2, 3);
    spanBo.setTransactionId(transactionId);
    spanBo.setElapsed(4);
    spanBo.setStartTime(5);
    spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
    spanBo.setLoggingTransactionInfo(LoggingInfo.INFO.getCode());
    spanBo.setExceptionInfo(1000, "Exception");
    ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
    SpanBo newSpanBo = new SpanBo();
    Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
    int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
    logger.debug("length:{}", i);
    Assert.assertEquals(bytes.limit(), i);
    Assert.assertEquals(newSpanBo.getAgentId(), spanBo.getAgentId());
    Assert.assertEquals(newSpanBo.getApplicationId(), spanBo.getApplicationId());
    Assert.assertEquals(newSpanBo.getAgentStartTime(), spanBo.getAgentStartTime());
    Assert.assertEquals(newSpanBo.getElapsed(), spanBo.getElapsed());
    Assert.assertEquals(newSpanBo.getEndPoint(), spanBo.getEndPoint());
    Assert.assertEquals(newSpanBo.getErrCode(), spanBo.getErrCode());
    Assert.assertEquals(newSpanBo.getFlag(), spanBo.getFlag());
    //        not included for serialization
    //        Assert.assertEquals(newSpanBo.getTraceAgentStartTime(), spanBo.getTraceAgentStartTime());
    //        Assert.assertEquals(newSpanBo.getTraceTransactionSequence(), spanBo.getTraceTransactionSequence());
    Assert.assertEquals(newSpanBo.getParentSpanId(), spanBo.getParentSpanId());
    Assert.assertEquals(newSpanBo.getServiceType(), spanBo.getServiceType());
    Assert.assertEquals(newSpanBo.getApplicationServiceType(), spanBo.getServiceType());
    Assert.assertEquals(newSpanBo.getVersion(), spanBo.getVersion());
    Assert.assertEquals(newSpanBo.getLoggingTransactionInfo(), spanBo.getLoggingTransactionInfo());
    Assert.assertEquals(newSpanBo.getExceptionId(), spanBo.getExceptionId());
    Assert.assertEquals(newSpanBo.getExceptionMessage(), spanBo.getExceptionMessage());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ByteBuffer(java.nio.ByteBuffer) TransactionId(com.navercorp.pinpoint.common.util.TransactionId) Test(org.junit.Test)

Example 3 with Buffer

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

the class SpanBoTest method serialize2_V1.

@Test
public void serialize2_V1() {
    SpanBo spanBo = new SpanBo();
    spanBo.setAgentId("agent");
    String service = createString(5);
    spanBo.setApplicationId(service);
    String endPoint = createString(127);
    spanBo.setEndPoint(endPoint);
    String rpc = createString(255);
    spanBo.setRpc(rpc);
    spanBo.setServiceType(ServiceType.STAND_ALONE.getCode());
    spanBo.setApplicationServiceType(ServiceType.UNKNOWN.getCode());
    final ByteBuffer bytes = spanSerializer.writeColumnValue(spanBo);
    SpanBo newSpanBo = new SpanBo();
    Buffer valueBuffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
    int i = spanDecoder.readSpan(newSpanBo, valueBuffer);
    logger.debug("length:{}", i);
    Assert.assertEquals(bytes.limit(), i);
    Assert.assertEquals(spanBo.getServiceType(), spanBo.getServiceType());
    Assert.assertEquals(spanBo.getApplicationServiceType(), spanBo.getApplicationServiceType());
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ByteBuffer(java.nio.ByteBuffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) SpanBo(com.navercorp.pinpoint.common.server.bo.SpanBo) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 4 with Buffer

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

the class TransactionIdUtils method parseTransactionId.

public static TransactionId parseTransactionId(final byte[] transactionId) {
    if (transactionId == null) {
        throw new NullPointerException("transactionId must not be null");
    }
    final Buffer buffer = new FixedBuffer(transactionId);
    final byte version = buffer.readByte();
    if (version != VERSION) {
        throw new IllegalArgumentException("invalid Version");
    }
    final String agentId = buffer.readPrefixedString();
    final long agentStartTime = buffer.readVLong();
    final long transactionSequence = buffer.readVLong();
    if (agentId == null) {
        return new TransactionId(agentStartTime, transactionSequence);
    } else {
        return new TransactionId(agentId, agentStartTime, transactionSequence);
    }
}
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) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 5 with Buffer

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

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