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