use of com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory in project pinpoint by naver.
the class HeaderTBaseSerializerTest method testSerialize1.
@Test
public void testSerialize1() throws Exception {
HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false).createSerializer();
HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
test(serializer, deserializer);
}
use of com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory 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.io.HeaderTBaseSerializerFactory 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.io.HeaderTBaseSerializerFactory 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());
}
use of com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory in project pinpoint by naver.
the class NetworkAvailabilityChecker method getNetworkCheckPayload.
private static byte[] getNetworkCheckPayload() throws TException {
HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false, 65535, false).createSerializer();
byte[] payload = serializer.serialize(new NetworkAvailabilityCheckPacket());
int size = serializer.getInterBufferSize();
return Arrays.copyOf(payload, size);
}
Aggregations