Search in sources :

Example 6 with HeaderTBaseDeserializerFactory

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

the class SpanStreamSendDataSerializerTest method spanStreamSendDataSerializerTest2.

@Test
public void spanStreamSendDataSerializerTest2() throws InterruptedException, TException {
    int spanEventSize = 10;
    SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
    HeaderTBaseSerializerFactory factory = new HeaderTBaseSerializerFactory();
    Span span = createSpan(createSpanEventList(spanEventSize));
    PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanStream(factory.createSerializer(), span);
    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 TSpan);
        }
    }
}
Also used : HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) Span(com.navercorp.pinpoint.profiler.context.Span) 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