Search in sources :

Example 6 with TSpanChunk

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

the class SpanFactoryTest method testFullScanLocalAsyncIdBo_empty.

@Test
public void testFullScanLocalAsyncIdBo_empty() {
    TSpanEvent tSpanEvent = new TSpanEvent();
    TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setSpanEventList(Arrays.asList(tSpanEvent, tSpanEvent));
    LocalAsyncIdBo localAsyncIdBo = spanFactory.fullScanLocalAsyncIdBo(tSpanChunk);
    Assert.assertNull(localAsyncIdBo);
}
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)

Example 7 with TSpanChunk

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

the class TBaseStreamTest method chunk.

@Test
public void chunk() throws Exception {
    TBaseStream stream = new TBaseStream(DEFAULT_PROTOCOL_FACTORY);
    final String str1k = RandomStringUtils.randomAlphabetic(1024);
    // chunk
    TSpanChunk spanChunk = newSpanChunk();
    List<TSpanEvent> spanEventList = new ArrayList<TSpanEvent>();
    spanChunk.setSpanEventList(spanEventList);
    spanChunk.setSpanEventListIsSet(true);
    TSpanEvent event1k = new TSpanEvent();
    event1k.setDestinationId(str1k);
    event1k.setDestinationIdIsSet(true);
    // add 2 event
    spanEventList.add(event1k);
    spanEventList.add(event1k);
    // write event
    for (TSpanEvent e : spanChunk.getSpanEventList()) {
        stream.write(e);
    }
    logger.debug("event {}", stream);
    // split 1k
    TBaseStream chunkStream = new TBaseStream(DEFAULT_PROTOCOL_FACTORY);
    List<ByteArrayOutput> nodes = stream.split(1024);
    logger.debug("nodes {}", nodes);
// chunkStream.write(spanChunk, "spanEventList", nodes);
// while (!stream.isEmpty()) {
// nodes = stream.split(1024);
// System.out.println("nodes " + nodes);
// chunkStream.write(spanChunk, "spanEventList", nodes);
// }
// 
// System.out.println("chunk " + chunkStream);
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) ArrayList(java.util.ArrayList) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 8 with TSpanChunk

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

the class ChunkHeaderTBaseDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    final ChunkHeaderTBaseDeserializer deserializer = new ChunkHeaderTBaseDeserializer(DEFAULT_PROTOCOL_FACTORY, DEFAULT_TBASE_LOCATOR);
    UnsafeByteArrayOutputStream out = new UnsafeByteArrayOutputStream();
    ChunkHeaderBufferedTBaseSerializer serializer = new ChunkHeaderBufferedTBaseSerializer(out, DEFAULT_PROTOCOL_FACTORY, DEFAULT_TBASE_LOCATOR);
    TSpanChunk chunk = new TSpanMockBuilder().buildChunk(3, 10);
    serializer.add(chunk);
    List<Message<TBase<?, ?>>> list = deserializer.deserialize(serializer.getTransport().getBuffer(), 0, serializer.getTransport().getBufferPosition());
    assertEquals(1, list.size());
    TSpanChunk result = (TSpanChunk) list.get(0).getData();
    assertEquals(3, result.getSpanEventList().size());
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) Message(com.navercorp.pinpoint.io.request.Message) Test(org.junit.Test)

Example 9 with TSpanChunk

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

the class ChunkHeaderBufferedTBaseSerializerTest method add.

@Test
public void add() throws TException {
    final int chunkSize = 1024;
    UnsafeByteArrayOutputStream out = new UnsafeByteArrayOutputStream();
    ChunkHeaderBufferedTBaseSerializer serializer = new ChunkHeaderBufferedTBaseSerializer(out, DEFAULT_PROTOCOL_FACTORY, DEFAULT_TBASE_LOCATOR);
    serializer.setChunkSize(1024);
    serializer.setFlushHandler(new ChunkHeaderBufferedTBaseSerializerFlushHandler() {

        @Override
        public void handle(byte[] buffer, int offset, int length) {
            flushCounter.incrementAndGet();
        }
    });
    // add and flush
    flushCounter.set(0);
    TSpanChunk chunk = new TSpanMockBuilder().buildChunk(1, 1024);
    serializer.add(chunk);
    assertEquals(1, flushCounter.get());
    // add and flush * 3
    flushCounter.set(0);
    chunk = new TSpanMockBuilder().buildChunk(3, 1024);
    serializer.add(chunk);
    assertEquals(3, flushCounter.get());
    // add
    flushCounter.set(0);
    chunk = new TSpanMockBuilder().buildChunk(3, 10);
    serializer.add(chunk);
    assertEquals(0, flushCounter.get());
    // flush
    flushCounter.set(0);
    serializer.flush();
    assertEquals(1, flushCounter.get());
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) Test(org.junit.Test)

Example 10 with TSpanChunk

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

the class DefaultTBaseLocator method addBodyFactory.

public static void addBodyFactory(TypeLocatorBuilder<TBase<?, ?>> builder) {
    builder.addBodyFactory(SPAN, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TSpan();
        }
    });
    builder.addBodyFactory(AGENT_INFO, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TAgentInfo();
        }
    });
    builder.addBodyFactory(AGENT_STAT, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TAgentStat();
        }
    });
    builder.addBodyFactory(AGENT_STAT_BATCH, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TAgentStatBatch();
        }
    });
    builder.addBodyFactory(SPANCHUNK, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TSpanChunk();
        }
    });
    builder.addBodyFactory(SPANEVENT, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TSpanEvent();
        }
    });
    builder.addBodyFactory(SQLMETADATA, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TSqlMetaData();
        }
    });
    builder.addBodyFactory(APIMETADATA, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TApiMetaData();
        }
    });
    builder.addBodyFactory(RESULT, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TResult();
        }
    });
    builder.addBodyFactory(STRINGMETADATA, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new TStringMetaData();
        }
    });
    builder.addBodyFactory(NETWORK_CHECK, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return new NetworkAvailabilityCheckPacket();
        }
    });
    builder.addBodyFactory(CHUNK, new BodyFactory<TBase<?, ?>>() {

        @Override
        public TBase<?, ?> getObject() {
            return null;
        }
    });
}
Also used : TAgentStat(com.navercorp.pinpoint.thrift.dto.TAgentStat) TAgentStatBatch(com.navercorp.pinpoint.thrift.dto.TAgentStatBatch) TStringMetaData(com.navercorp.pinpoint.thrift.dto.TStringMetaData) TResult(com.navercorp.pinpoint.thrift.dto.TResult) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TApiMetaData(com.navercorp.pinpoint.thrift.dto.TApiMetaData) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TBase(org.apache.thrift.TBase) TSqlMetaData(com.navercorp.pinpoint.thrift.dto.TSqlMetaData) TAgentInfo(com.navercorp.pinpoint.thrift.dto.TAgentInfo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

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