use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec in project pinpoint by naver.
the class TransactionCodecTest method encodeValuesTest.
@Test
public void encodeValuesTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
TransactionCodec transactionCodec = new TransactionCodec(new AgentStatDataPointCodec());
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinTransactionBoList = createJoinTransactionBoList(currentTime);
encodedValueBuffer.putByte(transactionCodec.getVersion());
transactionCodec.encodeValues(encodedValueBuffer, joinTransactionBoList);
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(), transactionCodec.getVersion());
List<JoinStatBo> decodedJoinTransactionBoList = transactionCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinTransactionBoList.size(); i++) {
assertEquals(decodedJoinTransactionBoList.get(i), joinTransactionBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec in project pinpoint by naver.
the class AgentStatCodecV2 method decodeValues.
@Override
public List<T> decodeValues(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
final String agentId = decodingContext.getAgentId();
final long baseTimestamp = decodingContext.getBaseTimestamp();
final long timestampDelta = decodingContext.getTimestampDelta();
final long initialTimestamp = baseTimestamp + timestampDelta;
int numValues = valueBuffer.readVInt();
final AgentStatDataPointCodec codec = codecFactory.getCodec();
List<Long> startTimestamps = codec.decodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, numValues);
List<Long> timestamps = codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
CodecDecoder<T> codecDecoder = codecFactory.createCodecDecoder();
// decode headers
final byte[] header = valueBuffer.readPrefixedBytes();
AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
codecDecoder.decode(valueBuffer, headerDecoder, numValues);
List<T> result = new ArrayList<T>(numValues);
for (int i = 0; i < numValues; i++) {
T newObject = codecDecoder.getValue(i);
newObject.setAgentId(agentId);
newObject.setStartTimestamp(startTimestamps.get(i));
newObject.setTimestamp(timestamps.get(i));
result.add(newObject);
}
return result;
}
Aggregations