Search in sources :

Example 6 with TSpanEvent

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

the class TBaseStreamTest method clear.

@Test
public void clear() throws Exception {
    TBaseStream stream = new TBaseStream(DEFAULT_PROTOCOL_FACTORY);
    TSpanEvent spanEvent = newSpanEvent();
    stream.write(spanEvent);
    assertTrue(stream.size() > 0);
    stream.clear();
    assertTrue(stream.size() == 0);
}
Also used : TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 7 with TSpanEvent

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

the class TBaseStreamTest method splite.

@Test
public void splite() throws Exception {
    TBaseStream stream = new TBaseStream(DEFAULT_PROTOCOL_FACTORY);
    TSpanEvent spanEvent = newSpanEvent();
    stream.write(spanEvent);
    int size = stream.size();
    // append 3
    stream.write(spanEvent);
    stream.write(spanEvent);
    stream.write(spanEvent);
    // split 1
    List<ByteArrayOutput> nodes = stream.split(size);
    assertEquals(1, nodes.size());
    // split 2
    nodes = stream.split(size * 2);
    assertEquals(2, nodes.size());
    // split 1
    nodes = stream.split(1);
    assertEquals(1, nodes.size());
    nodes = stream.split(1);
    assertEquals(0, nodes.size());
}
Also used : TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) Test(org.junit.Test)

Example 8 with TSpanEvent

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

the class TBaseStreamTest method newSpanEvent.

private TSpanEvent newSpanEvent() {
    TSpanEvent spanEvent = new TSpanEvent();
    spanEvent.setApiId(1);
    spanEvent.setApiIdIsSet(true);
    spanEvent.setDepth(1);
    spanEvent.setDepthIsSet(true);
    spanEvent.setEndElapsed(1);
    spanEvent.setEndElapsedIsSet(true);
    spanEvent.setDestinationId("db");
    spanEvent.setDestinationIdIsSet(true);
    spanEvent.setEndPoint("10.10.10.10");
    spanEvent.setEndPointIsSet(true);
    return spanEvent;
}
Also used : TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 9 with TSpanEvent

use of com.navercorp.pinpoint.thrift.dto.TSpanEvent 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 10 with TSpanEvent

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

the class SpanChunkStreamSendDataPlanerTest method getSpanEventList.

private List<TSpanEvent> getSpanEventList(PartitionedByteBufferLocator spanData, SpanStreamSendDataFactory factory) throws Exception {
    List<TSpanEvent> spanEventList = new ArrayList<TSpanEvent>();
    SpanChunkStreamSendDataPlaner planer = new SpanChunkStreamSendDataPlaner(spanData, factory);
    Iterator<SpanStreamSendData> iterator = planer.getSendDataIterator();
    while (iterator.hasNext()) {
        SpanStreamSendData data = iterator.next();
        ByteBuffer[] sendBuffers = data.getSendBuffers();
        byte[] relatedBuffer = getSpanRelatedBuffer(sendBuffers);
        List<TSpanEvent> result = deserialize(relatedBuffer);
        for (TSpanEvent spanEvent : result) {
            spanEventList.add(spanEvent);
        }
    }
    return spanEventList;
}
Also used : SpanStreamSendData(com.navercorp.pinpoint.profiler.sender.SpanStreamSendData) ArrayList(java.util.ArrayList) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) ByteBuffer(java.nio.ByteBuffer)

Aggregations

TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)30 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 ByteBuffer (java.nio.ByteBuffer)8 TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)7 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)6 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)4 HeaderTBaseDeserializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)4 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)4 Span (com.navercorp.pinpoint.profiler.context.Span)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 TransactionId (com.navercorp.pinpoint.common.util.TransactionId)2 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)2 PartitionedByteBufferLocator (com.navercorp.pinpoint.profiler.sender.PartitionedByteBufferLocator)2 SpanStreamSendData (com.navercorp.pinpoint.profiler.sender.SpanStreamSendData)2 SpanStreamSendDataFactory (com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataFactory)2 SpanStreamSendDataSerializer (com.navercorp.pinpoint.profiler.sender.SpanStreamSendDataSerializer)2 TBase (org.apache.thrift.TBase)2 TException (org.apache.thrift.TException)2 RandomTSpan (com.navercorp.pinpoint.common.server.bo.RandomTSpan)1