use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentLifeCycleValueMapper method mapValue.
@Override
public byte[] mapValue(AgentLifeCycleBo value) {
final Buffer buffer = new AutomaticBuffer();
buffer.putInt(value.getVersion());
buffer.putPrefixedString(value.getAgentId());
buffer.putLong(value.getStartTimestamp());
buffer.putLong(value.getEventTimestamp());
buffer.putLong(value.getEventIdentifier());
buffer.putShort(value.getAgentLifeCycleState().getCode());
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class BytesUtilsTest method assertVar32.
private void assertVar32(int value) {
final int computeBufferSize = BytesUtils.computeVar32Size(value);
final byte[] bytes = new byte[computeBufferSize];
BytesUtils.writeVar32(value, bytes, 0);
final Buffer buffer = new FixedBuffer(bytes);
final int varInt = buffer.readVInt();
Assert.assertEquals("check value", value, varInt);
assertEquals("check buffer size", buffer.getOffset(), computeBufferSize);
final int varInt_ByteUtils1 = BytesUtils.bytesToVar32(buffer.getBuffer(), 0);
Assert.assertEquals("check value", value, varInt_ByteUtils1);
final byte[] max_buffer = new byte[BytesUtils.VLONG_MAX_SIZE];
BytesUtils.writeVar32(value, max_buffer, 0);
final int varInt_ByteUtils2 = BytesUtils.bytesToVar32(max_buffer, 0);
Assert.assertEquals("check value", value, varInt_ByteUtils2);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class BytesUtilsTest method assertVar64.
private void assertVar64(long value) {
final int computeBufferSize = BytesUtils.computeVar64Size(value);
final byte[] bytes = new byte[computeBufferSize];
BytesUtils.writeVar64(value, bytes, 0);
final Buffer buffer = new FixedBuffer(bytes);
final long varLong = buffer.readVLong();
Assert.assertEquals("check value", value, varLong);
assertEquals("check buffer size", buffer.getOffset(), computeBufferSize);
final long varLong_ByteUtils1 = BytesUtils.bytesToVar64(buffer.getBuffer(), 0);
Assert.assertEquals("check value", value, varLong_ByteUtils1);
final byte[] max_buffer = new byte[BytesUtils.VLONG_MAX_SIZE];
BytesUtils.writeVar64(value, max_buffer, 0);
final long varLong_ByteUtils2 = BytesUtils.bytesToVar64(max_buffer, 0);
Assert.assertEquals("check value", value, varLong_ByteUtils2);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanEncoderV0 method encodeQualifier.
private ByteBuffer encodeQualifier(byte type, BasicSpan basicSpan, SpanEventBo firstEvent, LocalAsyncIdBo localAsyncId) {
final Buffer buffer = new AutomaticBuffer(128);
buffer.putByte(type);
buffer.putPrefixedString(basicSpan.getApplicationId());
buffer.putPrefixedString(basicSpan.getAgentId());
buffer.putVLong(basicSpan.getAgentStartTime());
buffer.putLong(basicSpan.getSpanId());
if (firstEvent != null) {
buffer.putSVInt(firstEvent.getSequence());
final byte bitField = SpanEventQualifierBitField.buildBitField(localAsyncId);
buffer.putByte(bitField);
// case : async span
if (SpanEventQualifierBitField.isSetAsync(bitField)) {
buffer.putInt(localAsyncId.getAsyncId());
buffer.putVInt(localAsyncId.getSequence());
}
} else {
// simple trace case
// buffer.putSVInt((short) -1);
// byte cfBitField = SpanEventQualifierBitField.setAsync((byte) 0, false);
// buffer.putByte(cfBitField);
}
return buffer.wrapByteBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanEncoderV0 method encodeSpanColumnValue.
@Override
public ByteBuffer encodeSpanColumnValue(SpanEncodingContext<SpanBo> encodingContext) {
final SpanBo span = encodingContext.getValue();
final SpanBitFiled bitField = SpanBitFiled.build(span);
final Buffer buffer = new AutomaticBuffer(256);
final byte version = span.getRawVersion();
buffer.putByte(version);
// bit field
buffer.putByte(bitField.getBitField());
final short serviceType = span.getServiceType();
buffer.putShort(serviceType);
switch(bitField.getApplicationServiceTypeEncodingStrategy()) {
case PREV_EQUALS:
break;
case RAW:
buffer.putShort(span.getApplicationServiceType());
break;
default:
throw new IllegalStateException("applicationServiceType");
}
// buffer.put(spanID);
if (!bitField.isRoot()) {
buffer.putLong(span.getParentSpanId());
}
// prevSpanEvent coding
final long startTime = span.getStartTime();
final long startTimeDelta = span.getCollectorAcceptTime() - startTime;
buffer.putVLong(startTimeDelta);
buffer.putVInt(span.getElapsed());
buffer.putPrefixedString(span.getRpc());
buffer.putPrefixedString(span.getEndPoint());
buffer.putPrefixedString(span.getRemoteAddr());
buffer.putSVInt(span.getApiId());
// BIT flag
if (bitField.isSetErrorCode()) {
buffer.putInt(span.getErrCode());
}
if (bitField.isSetHasException()) {
buffer.putSVInt(span.getExceptionId());
buffer.putPrefixedString(span.getExceptionMessage());
}
if (bitField.isSetFlag()) {
buffer.putShort(span.getFlag());
}
if (bitField.isSetLoggingTransactionInfo()) {
buffer.putByte(span.getLoggingTransactionInfo());
}
buffer.putPrefixedString(span.getAcceptorHost());
if (bitField.isSetAnnotation()) {
List<AnnotationBo> annotationBoList = span.getAnnotationBoList();
writeAnnotationList(buffer, annotationBoList, encodingContext);
}
final List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
writeSpanEventList(buffer, spanEventBoList, encodingContext);
return buffer.wrapByteBuffer();
}
Aggregations