Search in sources :

Example 1 with HeaderTBaseDeserializerFactory

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.

the class SpanChunkStreamSendDataPlanerTest method deserialize.

private List<TSpanEvent> deserialize(byte[] data) throws TException {
    ByteBuffer bb = ByteBuffer.wrap(data);
    bb.get();
    bb.get();
    int chunkSize = bb.get();
    List<TSpanEvent> eventList = new ArrayList<TSpanEvent>();
    for (int i = 0; i < chunkSize; i++) {
        short componentSize = bb.getShort();
        byte[] component = new byte[componentSize];
        bb.get(component);
        HeaderTBaseDeserializer deserialize = new HeaderTBaseDeserializerFactory().createDeserializer();
        List<TBase<?, ?>> value = deserialize.deserializeList(component);
        for (int j = 0; j < value.size(); j++) {
            TBase tbase = value.get(j);
            if (tbase instanceof TSpanEvent) {
                eventList.add((TSpanEvent) tbase);
            } else {
            }
        }
    }
    return eventList;
}
Also used : ArrayList(java.util.ArrayList) TBase(org.apache.thrift.TBase) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)

Example 2 with HeaderTBaseDeserializerFactory

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.

the class SpanStreamSendDataPlanerTest method deserialize.

private List<TSpanEvent> deserialize(byte[] data) throws TException {
    ByteBuffer bb = ByteBuffer.wrap(data);
    bb.get();
    bb.get();
    int chunkSize = bb.get();
    List<TSpanEvent> eventList = new ArrayList<TSpanEvent>();
    for (int i = 0; i < chunkSize; i++) {
        short componentSize = bb.getShort();
        byte[] component = new byte[componentSize];
        bb.get(component);
        HeaderTBaseDeserializer deserialize = new HeaderTBaseDeserializerFactory().createDeserializer();
        List<TBase<?, ?>> value = deserialize.deserializeList(component);
        for (int j = 0; j < value.size(); j++) {
            TBase tbase = value.get(j);
            if (tbase instanceof TSpanEvent) {
                eventList.add((TSpanEvent) tbase);
            } else {
            }
        }
    }
    return eventList;
}
Also used : ArrayList(java.util.ArrayList) TBase(org.apache.thrift.TBase) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)

Example 3 with HeaderTBaseDeserializerFactory

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.

the class HeaderTBaseSerializerTest method testSerialize2.

@Test
public void testSerialize2() throws Exception {
    HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory().createSerializer();
    HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
    test(serializer, deserializer);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory) Test(org.junit.Test)

Example 4 with HeaderTBaseDeserializerFactory

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.

the class HeaderTBaseSerializerTest method testSerialize1.

@Test
public void testSerialize1() throws Exception {
    HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false).createSerializer();
    HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
    test(serializer, deserializer);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory) Test(org.junit.Test)

Example 5 with HeaderTBaseDeserializerFactory

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.

the class SpanStreamSendDataSerializerTest method spanStreamSendDataSerializerTest1.

@Test
public void spanStreamSendDataSerializerTest1() throws InterruptedException, TException {
    int spanEventSize = 10;
    SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
    HeaderTBaseSerializerFactory factory = new HeaderTBaseSerializerFactory();
    SpanChunk spanChunk = spanChunkFactory.create(createSpanEventList(spanEventSize));
    PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanChunkStream(factory.createSerializer(), spanChunk);
    Assert.assertEquals(spanEventSize + 1, partitionedByteBufferLocator.getPartitionedCount());
    HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
    for (int i = 0; i < partitionedByteBufferLocator.getPartitionedCount(); i++) {
        ByteBuffer byteBuffer = partitionedByteBufferLocator.getByteBuffer(i);
        byte[] readBuffer = new byte[byteBuffer.remaining()];
        byteBuffer.get(readBuffer);
        Object o = deserializer.deserialize(readBuffer);
        if (o == null) {
            Assert.fail();
        }
        if (i < spanEventSize) {
            Assert.assertTrue(o instanceof TSpanEvent);
        } else {
            Assert.assertTrue(o instanceof TSpanChunk);
        }
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Aggregations

HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)6 HeaderTBaseDeserializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)6 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)4 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)4 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)4 HeaderTBaseSerializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer)2 ArrayList (java.util.ArrayList)2 TBase (org.apache.thrift.TBase)2 Span (com.navercorp.pinpoint.profiler.context.Span)1 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)1 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)1 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)1