use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class ResponseTimeCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final ResponseTimeCodec responseTimeCodec = new ResponseTimeCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinResponseTimeBoList = createJoinResponseTimeBoList(currentTime);
encodedValueBuffer.putByte(responseTimeCodec.getVersion());
responseTimeCodec.encodeValues(encodedValueBuffer, joinResponseTimeBoList);
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(), responseTimeCodec.getVersion());
List<JoinStatBo> decodedJoinResponseTimeBoList = responseTimeCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinResponseTimeBoList.size(); i++) {
assertEquals(decodedJoinResponseTimeBoList.get(i), joinResponseTimeBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class MemoryCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final MemoryCodec memoryCodec = new MemoryCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinMemoryBoList = createJoinMemoryBoList(currentTime);
encodedValueBuffer.putByte(memoryCodec.getVersion());
memoryCodec.encodeValues(encodedValueBuffer, joinMemoryBoList);
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(), memoryCodec.getVersion());
List<JoinStatBo> decodedJoinMemoryBoList = memoryCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinMemoryBoList.size(); i++) {
assertEquals(decodedJoinMemoryBoList.get(i), joinMemoryBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class TotalThreadCountCodecTest method encodeAndDecodeTest.
@Test
public void encodeAndDecodeTest() {
final String id = "test_app";
final long currentTime = new Date().getTime();
final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
final TotalThreadCountCodec totalThreadCountCodec = new TotalThreadCountCodec(agentStatDataPointCodec);
final Buffer encodedValueBuffer = new AutomaticBuffer();
final List<JoinStatBo> joinTotalThreadCountBoList = createJoinTotalThreadCountBoList(currentTime);
encodedValueBuffer.putByte(totalThreadCountCodec.getVersion());
totalThreadCountCodec.encodeValues(encodedValueBuffer, joinTotalThreadCountBoList);
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(), totalThreadCountCodec.getVersion());
List<JoinStatBo> decodedJoinTotalThreadCountBoList = totalThreadCountCodec.decodeValues(valueBuffer, decodingContext);
for (int i = 0; i < decodedJoinTotalThreadCountBoList.size(); i++) {
assertEquals(decodedJoinTotalThreadCountBoList.get(i), joinTotalThreadCountBoList.get(i));
}
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class AgentStatDataPointCodecTest method test_single_timestamp.
@Test
public void test_single_timestamp() {
// Given
final long givenTimestamp = System.currentTimeMillis();
final List<Long> expectedTimestamp = Arrays.asList(givenTimestamp);
final Buffer timestampBuffer = new AutomaticBuffer();
// When
codec.encodeTimestamps(timestampBuffer, expectedTimestamp);
// Then
List<Long> decodedTimestamp = codec.decodeTimestamps(givenTimestamp, new FixedBuffer(timestampBuffer.getBuffer()), 1);
Assert.assertEquals(expectedTimestamp, decodedTimestamp);
}
use of com.navercorp.pinpoint.common.buffer.FixedBuffer in project pinpoint by naver.
the class AgentEventMessageDeserializerV1 method deserializeDeadlockBo.
private DeadlockBo deserializeDeadlockBo(final byte[] eventBody) {
final Buffer buffer = new FixedBuffer(eventBody);
final int deadlockedThreadCount = buffer.readInt();
final int threadDumpBoListSize = buffer.readVInt();
final List<ThreadDumpBo> threadDumpBoList = new ArrayList<>(threadDumpBoListSize);
if (threadDumpBoListSize > 0) {
threadDumpBoList.add(readThreadDumpBo(buffer));
}
final DeadlockBo deadlockBo = new DeadlockBo();
deadlockBo.setDeadlockedThreadCount(deadlockedThreadCount);
deadlockBo.setThreadDumpBoList(threadDumpBoList);
return deadlockBo;
}
Aggregations