use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec in project pinpoint by naver.
the class FileDescriptorCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final FileDescriptorCodec fileDescriptorCodec = new FileDescriptorCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinFileDescriptorBoList = createJoinFileDescriptorBoList(currentTime);
encodedValueBuffer.putByte(fileDescriptorCodec.getVersion());
fileDescriptorCodec.encodeValues(encodedValueBuffer, joinFileDescriptorBoList);
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(), fileDescriptorCodec.getVersion());
List<JoinStatBo> decodedJoinFileDescriptorBoList = fileDescriptorCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinFileDescriptorBoList.size(); i++) {
assertEquals(decodedJoinFileDescriptorBoList.get(i), joinFileDescriptorBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec 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.server.bo.codec.stat.AgentStatDataPointCodec 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));
}
}
use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec in project pinpoint by naver.
the class DirectBufferCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final DirectBufferCodec directBufferCodec = new DirectBufferCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinDirectBufferBoList = createJoinDirectBufferBoList(currentTime);
encodedValueBuffer.putByte(directBufferCodec.getVersion());
directBufferCodec.encodeValues(encodedValueBuffer, joinDirectBufferBoList);
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(), directBufferCodec.getVersion());
List<JoinStatBo> decodedJoinDirectBufferBoList = directBufferCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinDirectBufferBoList.size(); i++) {
assertEquals(decodedJoinDirectBufferBoList.get(i), joinDirectBufferBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec in project pinpoint by naver.
the class AgentStatCodecV2 method encodeValues.
@Override
public void encodeValues(Buffer valueBuffer, List<T> statDataPointList) {
Assert.isTrue(CollectionUtils.hasLength(statDataPointList), "statDataPointList must not be empty");
final int numValues = statDataPointList.size();
valueBuffer.putVInt(numValues);
List<Long> startTimestamps = new ArrayList<>(numValues);
List<Long> timestamps = new ArrayList<>(numValues);
CodecEncoder<T> encoder = codecFactory.createCodecEncoder();
for (T statDataPoint : statDataPointList) {
startTimestamps.add(statDataPoint.getStartTimestamp());
timestamps.add(statDataPoint.getTimestamp());
encoder.addValue(statDataPoint);
}
final AgentStatDataPointCodec codec = codecFactory.getCodec();
codec.encodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, startTimestamps);
codec.encodeTimestamps(valueBuffer, timestamps);
encoder.encode(valueBuffer);
}
Aggregations