Search in sources :

Example 16 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanFactoryTest method testNewSpanChunkBo.

@Test
public void testNewSpanChunkBo() throws Exception {
    TSpanChunk tSpanChunk = random.randomTSpanChunk();
    SpanChunkBo spanChunkBo = spanFactory.newSpanChunkBo(tSpanChunk);
    spanFactoryAssert.assertSpanChunk(tSpanChunk, spanChunkBo);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) Test(org.junit.Test)

Example 17 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanStreamSendDataSerializer method serializeSpanChunkStream.

public PartitionedByteBufferLocator serializeSpanChunkStream(HeaderTBaseSerializer serializer, TSpanChunk spanChunk) {
    PartitionedByteBufferLocator.Builder partitionedByteBufferLocatorBuilder = new PartitionedByteBufferLocator.Builder();
    List<TSpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (spanEventList != null) {
        for (TSpanEvent spanEvent : spanEventList) {
            int bufferStartIndex = serializer.getInterBufferSize();
            try {
                byte[] buffer = serializer.continueSerialize(spanEvent);
                int bufferEndIndex = serializer.getInterBufferSize();
                partitionedByteBufferLocatorBuilder.addIndex(bufferStartIndex, bufferEndIndex);
            } catch (TException e) {
                logger.warn("Serialize fail. value:{}.", spanEvent, e);
                serializer.reset(bufferStartIndex);
            }
        }
    }
    TSpanChunk copiedSpanChunk = copySpanChunkWithoutSpanEvent(spanChunk);
    try {
        int bufferStartIndex = serializer.getInterBufferSize();
        byte[] buffer = serializer.continueSerialize(copiedSpanChunk);
        int bufferEndIndex = serializer.getInterBufferSize();
        partitionedByteBufferLocatorBuilder.addIndex(bufferStartIndex, bufferEndIndex);
        partitionedByteBufferLocatorBuilder.setBuffer(buffer);
        return partitionedByteBufferLocatorBuilder.build();
    } catch (TException e) {
        logger.warn("Serialize fail. value:{}.", copiedSpanChunk, e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 18 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk 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)

Example 19 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanFactoryTest method testNewSpanChunkBo.

@Test
public void testNewSpanChunkBo() {
    TSpanChunk tSpanChunk = random.randomTSpanChunk();
    SpanChunkBo spanChunkBo = spanFactory.newSpanChunkBo(tSpanChunk);
    spanFactoryAssert.assertSpanChunk(tSpanChunk, spanChunkBo);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) Test(org.junit.Test)

Example 20 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanFactoryTest method testFullScanLocalAsyncIdBo.

@Test
public void testFullScanLocalAsyncIdBo() {
    int asyncId = 1;
    short asyncSequence = 0;
    TSpanEvent tSpanEvent = new TSpanEvent();
    tSpanEvent.setAsyncId(asyncId);
    tSpanEvent.setAsyncSequence(asyncSequence);
    TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setSpanEventList(Arrays.asList(tSpanEvent, tSpanEvent));
    LocalAsyncIdBo localAsyncIdBo = spanFactory.fullScanLocalAsyncIdBo(tSpanChunk);
    Assert.assertEquals(localAsyncIdBo.getAsyncId(), asyncId);
    Assert.assertEquals(localAsyncIdBo.getSequence(), asyncSequence);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Aggregations

TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)26 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)14 Test (org.junit.Test)13 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)5 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)4 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)4 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)2 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 ArrayList (java.util.ArrayList)2 TBase (org.apache.thrift.TBase)2 TypeLiteral (com.google.inject.TypeLiteral)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 Message (com.navercorp.pinpoint.io.request.Message)1 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)1