use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentStatCodecTestBase method runTest.
private void runTest() {
// Given
final long initialTimestamp = System.currentTimeMillis();
final long baseTimestamp = AgentStatUtils.getBaseTimestamp(initialTimestamp);
final long timestampDelta = initialTimestamp - baseTimestamp;
final List<T> expectedAgentStats = createAgentStats(AGENT_ID, AGENT_START_TIMESTAMP, initialTimestamp);
// When
Buffer encodedValueBuffer = new AutomaticBuffer();
getCodec().encodeValues(encodedValueBuffer, expectedAgentStats);
// Then
AgentStatDecodingContext decodingContext = new AgentStatDecodingContext();
decodingContext.setAgentId(AGENT_ID);
decodingContext.setBaseTimestamp(baseTimestamp);
decodingContext.setTimestampDelta(timestampDelta);
Buffer valueBuffer = new FixedBuffer(encodedValueBuffer.getBuffer());
List<T> actualAgentStats = getCodec().decodeValues(valueBuffer, decodingContext);
Assert.assertEquals(expectedAgentStats.size(), actualAgentStats.size());
for (int i = 0; i < expectedAgentStats.size(); i++) {
T expectedAgentStat = expectedAgentStats.get(i);
T actualAgentStat = actualAgentStats.get(i);
verify(expectedAgentStat, actualAgentStat);
}
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentStatEncoderTest method stats_should_be_encoded_and_decoded_into_same_value.
@Test
public void stats_should_be_encoded_and_decoded_into_same_value() {
long initialTimestamp = System.currentTimeMillis();
int numStats = RandomUtils.nextInt(1, 21);
List<TestAgentStat> expectedAgentStats = this.createTestAgentStats(initialTimestamp, numStats);
long baseTimestamp = AgentStatUtils.getBaseTimestamp(initialTimestamp);
long timestampDelta = initialTimestamp - baseTimestamp;
ByteBuffer qualifierBuffer = encoder.encodeQualifier(timestampDelta);
ByteBuffer valueBuffer = encoder.encodeValue(expectedAgentStats);
Buffer encodedQualifierBuffer = new FixedBuffer(qualifierBuffer.array());
Buffer encodedValueBuffer = new FixedBuffer(valueBuffer.array());
AgentStatDecodingContext context = new AgentStatDecodingContext();
context.setAgentId(AGENT_ID);
context.setBaseTimestamp(baseTimestamp);
List<TestAgentStat> decodedAgentStats = decode(encodedQualifierBuffer, encodedValueBuffer, context);
verify(expectedAgentStats, decodedAgentStats);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentStatDataPointCodecTest method test_timestamps.
@Test
public void test_timestamps() {
// Given
final long initialTimestamp = System.currentTimeMillis();
final long intervalMs = 5000L;
final long randomDelta = 10L;
final int numValues = (int) (Math.random() * 100) + 1;
final List<Long> expectedTimestamps = createTimestamps(initialTimestamp, intervalMs, randomDelta, numValues);
final Buffer timestampBuffer = new AutomaticBuffer();
// When
codec.encodeTimestamps(timestampBuffer, expectedTimestamps);
// Then
List<Long> decodedTimestamps = codec.decodeTimestamps(initialTimestamp, new FixedBuffer(timestampBuffer.getBuffer()), numValues);
Assert.assertEquals(expectedTimestamps, decodedTimestamps);
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class AgentEventMessageSerializerV1 method serializeDeadlockBo.
private byte[] serializeDeadlockBo(final DeadlockBo deadlockBo) {
final Buffer buffer = new AutomaticBuffer();
buffer.putInt(deadlockBo.getDeadlockedThreadCount());
// Put ThreadDumpBoList
final int threadDumpBoListSize = deadlockBo.getThreadDumpBoList() == null ? 0 : deadlockBo.getThreadDumpBoList().size();
buffer.putVInt(threadDumpBoListSize);
if (threadDumpBoListSize > 0) {
for (ThreadDumpBo threadDumpBo : deadlockBo.getThreadDumpBoList()) {
putThreadDumpBo(buffer, threadDumpBo);
}
}
return buffer.getBuffer();
}
use of com.navercorp.pinpoint.common.buffer.Buffer in project pinpoint by naver.
the class SpanEncoderV0 method encodeSpanChunkColumnValue.
@Override
public ByteBuffer encodeSpanChunkColumnValue(SpanEncodingContext<SpanChunkBo> encodingContext) {
final SpanChunkBo spanChunkBo = encodingContext.getValue();
final Buffer buffer = new AutomaticBuffer(256);
final byte version = (byte) spanChunkBo.getVersion();
buffer.putByte(version);
if (version == SpanVersion.TRACE_V2) {
long keyTime = spanChunkBo.getKeyTime();
buffer.putVLong(keyTime);
}
final List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
writeSpanEventList(buffer, spanEventBoList, encodingContext);
return buffer.wrapByteBuffer();
}
Aggregations