use of com.navercorp.pinpoint.thrift.dto.TSpanEvent 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.TSpanEvent in project pinpoint by naver.
the class SpanStreamSendDataSerializer method serializeSpanStream.
public PartitionedByteBufferLocator serializeSpanStream(HeaderTBaseSerializer serializer, TSpan span) {
PartitionedByteBufferLocator.Builder partitionedByteBufferLocatorBuilder = new PartitionedByteBufferLocator.Builder();
List<TSpanEvent> spanEventList = span.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);
}
}
}
TSpan copiedSpan = copySpanWithoutSpanEvent(span);
try {
int bufferStartIndex = serializer.getInterBufferSize();
byte[] buffer = serializer.continueSerialize(copiedSpan);
int bufferEndIndex = serializer.getInterBufferSize();
partitionedByteBufferLocatorBuilder.addIndex(bufferStartIndex, bufferEndIndex);
partitionedByteBufferLocatorBuilder.setBuffer(buffer);
return partitionedByteBufferLocatorBuilder.build();
} catch (TException e) {
logger.warn("Serialize fail. value:{}.", copiedSpan, e);
}
return null;
}
use of com.navercorp.pinpoint.thrift.dto.TSpanEvent 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.TSpanEvent in project pinpoint by naver.
the class SpanStreamSendDataSerializerTest method spanStreamSendDataSerializerTest2.
@Test
public void spanStreamSendDataSerializerTest2() throws InterruptedException, TException {
int spanEventSize = 10;
SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
HeaderTBaseSerializerFactory factory = new HeaderTBaseSerializerFactory();
Span span = createSpan(createSpanEventList(spanEventSize));
PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanStream(factory.createSerializer(), span);
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 TSpan);
}
}
}
use of com.navercorp.pinpoint.thrift.dto.TSpanEvent in project pinpoint by naver.
the class SpanChunkStreamSendDataPlanerTest method spanChunkStreamSendDataPlanerTest.
@Test
public void spanChunkStreamSendDataPlanerTest() throws Exception {
int spanEventSize = 10;
SpanStreamSendDataSerializer serializer = new SpanStreamSendDataSerializer();
HeaderTBaseSerializerFactory headerTBaseSerializerFactory = new HeaderTBaseSerializerFactory();
List<SpanEvent> originalSpanEventList = createSpanEventList(spanEventSize);
SpanChunk spanChunk = spanChunkFactory.create(originalSpanEventList);
PartitionedByteBufferLocator partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
SpanStreamSendDataFactory factory = new SpanStreamSendDataFactory(100, 50, objectPool);
List<TSpanEvent> spanEventList = getSpanEventList(partitionedByteBufferLocator, factory);
partitionedByteBufferLocator = serializer.serializeSpanChunkStream(headerTBaseSerializerFactory.createSerializer(), spanChunk);
factory = new SpanStreamSendDataFactory(objectPool);
List<TSpanEvent> spanEventList2 = getSpanEventList(partitionedByteBufferLocator, factory);
Assert.assertEquals(spanEventSize, spanEventList.size());
Assert.assertEquals(spanEventSize, spanEventList2.size());
}
Aggregations