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