use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.
the class SpanChunkStreamSendDataPlanerTest method deserialize.
private List<TSpanEvent> deserialize(byte[] data) throws TException {
ByteBuffer bb = ByteBuffer.wrap(data);
bb.get();
bb.get();
int chunkSize = bb.get();
List<TSpanEvent> eventList = new ArrayList<TSpanEvent>();
for (int i = 0; i < chunkSize; i++) {
short componentSize = bb.getShort();
byte[] component = new byte[componentSize];
bb.get(component);
HeaderTBaseDeserializer deserialize = new HeaderTBaseDeserializerFactory().createDeserializer();
List<TBase<?, ?>> value = deserialize.deserializeList(component);
for (int j = 0; j < value.size(); j++) {
TBase tbase = value.get(j);
if (tbase instanceof TSpanEvent) {
eventList.add((TSpanEvent) tbase);
} else {
}
}
}
return eventList;
}
use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.
the class SpanStreamSendDataPlanerTest method deserialize.
private List<TSpanEvent> deserialize(byte[] data) throws TException {
ByteBuffer bb = ByteBuffer.wrap(data);
bb.get();
bb.get();
int chunkSize = bb.get();
List<TSpanEvent> eventList = new ArrayList<TSpanEvent>();
for (int i = 0; i < chunkSize; i++) {
short componentSize = bb.getShort();
byte[] component = new byte[componentSize];
bb.get(component);
HeaderTBaseDeserializer deserialize = new HeaderTBaseDeserializerFactory().createDeserializer();
List<TBase<?, ?>> value = deserialize.deserializeList(component);
for (int j = 0; j < value.size(); j++) {
TBase tbase = value.get(j);
if (tbase instanceof TSpanEvent) {
eventList.add((TSpanEvent) tbase);
} else {
}
}
}
return eventList;
}
use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory in project pinpoint by naver.
the class HeaderTBaseSerializerTest method testSerialize2.
@Test
public void testSerialize2() throws Exception {
HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory().createSerializer();
HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
test(serializer, deserializer);
}
use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory 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.HeaderTBaseDeserializerFactory 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);
}
}
}
Aggregations