use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanEventBoTest method testSerialize.
@Test
public void testSerialize() throws Exception {
SpanBo spanBo = new SpanBo();
spanBo.setAgentId("testAgent");
spanBo.setApplicationId("testApp");
spanBo.setAgentStartTime(1);
spanBo.setSpanId(12);
SpanEventBo spanEventBo = new SpanEventBo();
spanEventBo.setDepth(3);
spanEventBo.setDestinationId("testdest");
spanEventBo.setEndElapsed(2);
spanEventBo.setEndPoint("endpoint");
spanEventBo.setNextSpanId(4);
spanEventBo.setRpc("rpc");
spanEventBo.setServiceType(ServiceType.STAND_ALONE.getCode());
spanEventBo.setStartElapsed(100);
spanEventBo.setNextAsyncId(1000);
SpanEventEncodingContext spanEventEncodingContext = new SpanEventEncodingContext(spanBo, spanEventBo);
ByteBuffer bytes = serializer.writeValue(spanEventEncodingContext);
SpanEventBo newSpanEventBo = new SpanEventBo();
SpanDecodingContext spanDecodingContext = new SpanDecodingContext();
Buffer buffer = new OffsetFixedBuffer(bytes.array(), bytes.arrayOffset(), bytes.remaining());
int i = spanDecoder.readSpanEvent(newSpanEventBo, buffer, spanDecodingContext);
Assert.assertEquals(bytes.limit(), i);
Assert.assertEquals(spanBo.getAgentId(), spanDecodingContext.getAgentId());
Assert.assertEquals(spanBo.getApplicationId(), spanDecodingContext.getApplicationId());
Assert.assertEquals(spanBo.getAgentStartTime(), spanDecodingContext.getAgentStartTime());
Assert.assertEquals(spanEventBo.getDepth(), newSpanEventBo.getDepth());
Assert.assertEquals(spanEventBo.getDestinationId(), newSpanEventBo.getDestinationId());
Assert.assertEquals(spanEventBo.getEndElapsed(), newSpanEventBo.getEndElapsed());
Assert.assertEquals(spanEventBo.getEndPoint(), newSpanEventBo.getEndPoint());
Assert.assertEquals(spanEventBo.getNextSpanId(), newSpanEventBo.getNextSpanId());
Assert.assertEquals(spanEventBo.getRpc(), newSpanEventBo.getRpc());
Assert.assertEquals(spanEventBo.getServiceType(), newSpanEventBo.getServiceType());
Assert.assertEquals(spanEventBo.getStartElapsed(), newSpanEventBo.getStartElapsed());
Assert.assertEquals(spanEventBo.getNextAsyncId(), newSpanEventBo.getNextAsyncId());
spanEventBo.setSequence((short) 3);
newSpanEventBo.setSequence((short) 3);
Assert.assertEquals(spanEventBo.getSequence(), newSpanEventBo.getSequence());
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeIntStringValue.
private Object decodeIntStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final int intValue = buffer.readSVInt();
final String stringValue = BytesUtils.toString(buffer.readPrefixedBytes());
return new IntStringValue(intValue, stringValue);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeIntStringStringValue.
private Object decodeIntStringStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final int intValue = buffer.readSVInt();
final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
return new IntStringStringValue(intValue, stringValue1, stringValue2);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class ApplicationMapStatisticsUtils method makeRowKey.
/**
* <pre>
* rowkey format = "APPLICATIONNAME(max 24bytes)" + apptype(2byte) + "TIMESTAMP(8byte)"
* </pre>
*
* @param applicationName
* @param timestamp
* @return
*/
public static byte[] makeRowKey(String applicationName, short applicationType, long timestamp) {
if (applicationName == null) {
throw new NullPointerException("applicationName must not be null");
}
final byte[] applicationNameBytes = BytesUtils.toBytes(applicationName);
final Buffer buffer = new AutomaticBuffer(2 + applicationNameBytes.length + 2 + 8);
// buffer.put2PrefixedString(applicationName);
buffer.putShort((short) applicationNameBytes.length);
buffer.putBytes(applicationNameBytes);
buffer.putShort(applicationType);
long reverseTimeMillis = TimeUtils.reverseTimeMillis(timestamp);
buffer.putLong(reverseTimeMillis);
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class ApplicationMapStatisticsUtilsTest method testMakeColumnName2.
@Test
public void testMakeColumnName2() {
// short serviceType, String applicationName, String destHost, short slotNumber
final short slotNumber = 10;
final byte[] columnNameBytes = ApplicationMapStatisticsUtils.makeColumnName(ServiceType.STAND_ALONE.getCode(), "applicationName", "dest", slotNumber);
Buffer buffer = new FixedBuffer(columnNameBytes);
Assert.assertEquals(ServiceType.STAND_ALONE.getCode(), buffer.readShort());
Assert.assertEquals(10, buffer.readShort());
Assert.assertEquals("applicationName", buffer.read2PrefixedString());
int offset = buffer.getOffset();
byte[] interBuffer = buffer.getInternalBuffer();
Assert.assertEquals(BytesUtils.toString(interBuffer, offset, interBuffer.length - offset), "dest");
}
Aggregations