Search in sources :

Example 61 with Buffer

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

the class SpanEventBoTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    SpanBo spanBo = new SpanBo();
    spanBo.setAgentId("testAgent");
    spanBo.setApplicationId("testApp");
    spanBo.setAgentStartTime(1);
    spanBo.setSpanId(12);
    SpanEventBo spanEventBo = new SpanEventBo();
    spanEventBo.setDepth(3);
    spanEventBo.setDestinationId("testdest");
    spanEventBo.setEndElapsed(2);
    spanEventBo.setEndPoint("endpoint");
    spanEventBo.setNextSpanId(4);
    spanEventBo.setRpc("rpc");
    spanEventBo.setServiceType(ServiceType.STAND_ALONE.getCode());
    spanEventBo.setStartElapsed(100);
    spanEventBo.setNextAsyncId(1000);
    SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(spanBo, spanEventBo);
    ByteBuffer bytes = serializer.writeValue(spanEventEncodingContext);
    SpanEventBo newSpanEventBo = new SpanEventBo();
    SpanDecodingContext spanDecodingContext = new SpanDecodingContext();
    Buffer buffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
    int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer, spanDecodingContext);
    Assert.assertEquals(bytes.limit(), i);
    Assert.assertEquals(spanBo.getAgentId(), spanDecodingContext.getAgentId());
    Assert.assertEquals(spanBo.getApplicationId(), spanDecodingContext.getApplicationId());
    Assert.assertEquals(spanBo.getAgentStartTime(), spanDecodingContext.getAgentStartTime());
    Assert.assertEquals(spanEventBo.getDepth(), newSpanEventBo.getDepth());
    Assert.assertEquals(spanEventBo.getDestinationId(), newSpanEventBo.getDestinationId());
    Assert.assertEquals(spanEventBo.getEndElapsed(), newSpanEventBo.getEndElapsed());
    Assert.assertEquals(spanEventBo.getEndPoint(), newSpanEventBo.getEndPoint());
    Assert.assertEquals(spanEventBo.getNextSpanId(), newSpanEventBo.getNextSpanId());
    Assert.assertEquals(spanEventBo.getRpc(), newSpanEventBo.getRpc());
    Assert.assertEquals(spanEventBo.getServiceType(), newSpanEventBo.getServiceType());
    Assert.assertEquals(spanEventBo.getStartElapsed(), newSpanEventBo.getStartElapsed());
    Assert.assertEquals(spanEventBo.getNextAsyncId(), newSpanEventBo.getNextAsyncId());
    spanEventBo.setSequence((short) 3);
    newSpanEventBo.setSequence((short) 3);
    Assert.assertEquals(spanEventBo.getSequence(), newSpanEventBo.getSequence());
}
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) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 62 with Buffer

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

the class AnnotationTranscoder method decodeIntStringValue.

private Object decodeIntStringValue(byte[] data) {
    final Buffer buffer = new FixedBuffer(data);
    final int intValue = buffer.readSVInt();
    final String stringValue = BytesUtils.toString(buffer.readPrefixedBytes());
    return new IntStringValue(intValue, stringValue);
}
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) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue)

Example 63 with Buffer

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

the class AnnotationTranscoder method decodeIntStringStringValue.

private Object decodeIntStringStringValue(byte[] data) {
    final Buffer buffer = new FixedBuffer(data);
    final int intValue = buffer.readSVInt();
    final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
    final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
    return new IntStringStringValue(intValue, stringValue1, stringValue2);
}
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) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer)

Example 64 with Buffer

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

the class ApplicationMapStatisticsUtils method makeRowKey.

/**
     * <pre>
     * rowkey format = "APPLICATIONNAME(max 24bytes)" + apptype(2byte) + "TIMESTAMP(8byte)"
     * </pre>
     *
     * @param applicationName
     * @param timestamp
     * @return
     */
public static byte[] makeRowKey(String applicationName, short applicationType, long timestamp) {
    if (applicationName == null) {
        throw new NullPointerException("applicationName must not be null");
    }
    final byte[] applicationNameBytes = BytesUtils.toBytes(applicationName);
    final Buffer buffer = new AutomaticBuffer(2 + applicationNameBytes.length + 2 + 8);
    //        buffer.put2PrefixedString(applicationName);
    buffer.putShort((short) applicationNameBytes.length);
    buffer.putBytes(applicationNameBytes);
    buffer.putShort(applicationType);
    long reverseTimeMillis = TimeUtils.reverseTimeMillis(timestamp);
    buffer.putLong(reverseTimeMillis);
    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 65 with Buffer

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

the class ApplicationMapStatisticsUtilsTest method testMakeColumnName2.

@Test
public void testMakeColumnName2() {
    //        short serviceType, String applicationName, String destHost, short slotNumber
    final short slotNumber = 10;
    final byte[] columnNameBytes = ApplicationMapStatisticsUtils.makeColumnName(ServiceType.STAND_ALONE.getCode(), "applicationName", "dest", slotNumber);
    Buffer buffer = new FixedBuffer(columnNameBytes);
    Assert.assertEquals(ServiceType.STAND_ALONE.getCode(), buffer.readShort());
    Assert.assertEquals(10, buffer.readShort());
    Assert.assertEquals("applicationName", buffer.read2PrefixedString());
    int offset = buffer.getOffset();
    byte[] interBuffer = buffer.getInternalBuffer();
    Assert.assertEquals(BytesUtils.toString(interBuffer, offset, interBuffer.length - offset), "dest");
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Test(org.junit.Test)

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