use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeLongIntIntByteByteStringValue.
private Object decodeLongIntIntByteByteStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final byte bitField = buffer.readByte();
final long longValue = buffer.readVLong();
final int intValue1 = buffer.readVInt();
int intValue2 = -1;
if (BitFieldUtils.testBit(bitField, 0)) {
intValue2 = buffer.readVInt();
}
byte byteValue1 = -1;
if (BitFieldUtils.testBit(bitField, 1)) {
byteValue1 = buffer.readByte();
}
byte byteValue2 = -1;
if (BitFieldUtils.testBit(bitField, 2)) {
byteValue2 = buffer.readByte();
}
String stringValue = null;
if (BitFieldUtils.testBit(bitField, 3)) {
stringValue = BytesUtils.toString(buffer.readPrefixedBytes());
}
return new LongIntIntByteByteStringValue(longValue, intValue1, intValue2, byteValue1, byteValue2, stringValue);
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeStringStringValue.
// 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);
// }
//
// private byte[] encodeIntStringStringValue(Object o) {
// final TIntStringStringValue tIntStringStringValue = (TIntStringStringValue) o;
// final int intValue = tIntStringStringValue.getIntValue();
// final byte[] stringValue1 = BytesUtils.toBytes(tIntStringStringValue.getStringValue1());
// final byte[] stringValue2 = BytesUtils.toBytes(tIntStringStringValue.getStringValue2());
// // TODO increase by a more precise value
// final int bufferSize = getBufferSize(stringValue1, stringValue2, 4 + 8);
// final Buffer buffer = new AutomaticBuffer(bufferSize);
// buffer.putSVInt(intValue);
// buffer.putPrefixedBytes(stringValue1);
// buffer.putPrefixedBytes(stringValue2);
// return buffer.getBuffer();
// }
//
// private int getBufferSize(byte[] stringValue1, byte[] stringValue2, int reserve) {
// int length = 0;
// if (stringValue1 != null) {
// length += stringValue1.length;
// }
// if (stringValue2 != null) {
// length += stringValue2.length;
//
// }
// return length + reserve;
// }
//
private Object decodeStringStringValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final String stringValue1 = BytesUtils.toString(buffer.readPrefixedBytes());
final String stringValue2 = BytesUtils.toString(buffer.readPrefixedBytes());
return new StringStringValue(stringValue1, stringValue2);
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class AnnotationTranscoder method decodeIntBooleanIntBooleanValue.
private Object decodeIntBooleanIntBooleanValue(byte[] data) {
final Buffer buffer = new FixedBuffer(data);
final int intValue1 = buffer.readVInt();
final boolean booleanValue1 = buffer.readBoolean();
final int intValue2 = buffer.readVInt();
final boolean booleanValue2 = buffer.readBoolean();
return new IntBooleanIntBooleanValue(intValue1, booleanValue1, intValue2, booleanValue2);
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class DataSourceCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final DataSourceCodec dataSourceCodec = new DataSourceCodec(agentStatDataPointCodec);
final List<JoinStatBo> joinDataSourceListBoList = createJoinDataSourceListBoList(currentTime);
final Buffer encodedValueBuffer = new AutomaticBuffer();
encodedValueBuffer.putByte(dataSourceCodec.getVersion());
dataSourceCodec.encodeValues(encodedValueBuffer, joinDataSourceListBoList);
final Buffer valueBuffer = new FixedBuffer(encodedValueBuffer.getBuffer());
;
final long baseTimestamp = AgentStatUtils.getBaseTimestamp(currentTime);
final long timestampDelta = currentTime - baseTimestamp;
final ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
decodingContext.setApplicationId(id);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
assertEquals(valueBuffer.readByte(), dataSourceCodec.getVersion());
List<JoinStatBo> decodedJoinDataSourceListBoList = dataSourceCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinDataSourceListBoList.size(); ++i) {
assertEquals(decodedJoinDataSourceListBoList.get(i), joinDataSourceListBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class CpuLoadCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final CpuLoadCodec cpuLoadCodec = new CpuLoadCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinCpuLoadBoList = createJoinCpuLoadBoList(currentTime);
encodedValueBuffer.putByte(cpuLoadCodec.getVersion());
cpuLoadCodec.encodeValues(encodedValueBuffer, joinCpuLoadBoList);
final Buffer valueBuffer = new FixedBuffer(encodedValueBuffer.getBuffer());
final long baseTimestamp = AgentStatUtils.getBaseTimestamp(currentTime);
final long timestampDelta = currentTime - baseTimestamp;
final ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
decodingContext.setApplicationId(id);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
assertEquals(valueBuffer.readByte(), cpuLoadCodec.getVersion());
List<JoinStatBo> decodedjoinCpuLoadBoList = cpuLoadCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedjoinCpuLoadBoList.size(); i++) {
assertEquals(decodedjoinCpuLoadBoList.get(i), joinCpuLoadBoList.get(i));
}
}
Aggregations