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);
}
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());
}
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;
}
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);
}
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;
}
Aggregations