Search in sources :

Example 26 with FixedBuffer

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));
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) Test(org.junit.Test)

Example 27 with FixedBuffer

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));
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) Test(org.junit.Test)

Example 28 with FixedBuffer

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));
    }
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) Test(org.junit.Test)

Example 29 with FixedBuffer

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);
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 30 with FixedBuffer

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;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) DeadlockBo(com.navercorp.pinpoint.common.server.bo.event.DeadlockBo) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ArrayList(java.util.ArrayList) ThreadDumpBo(com.navercorp.pinpoint.common.server.bo.event.ThreadDumpBo)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)39 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)39 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)23 Test (org.junit.Test)16 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)10 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)10 Date (java.util.Date)10 ByteBuffer (java.nio.ByteBuffer)5 Cell (org.apache.hadoop.hbase.Cell)4 ArrayList (java.util.ArrayList)3 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)2 AgentStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.AgentStatDecodingContext)2 AgentStatDataPoint (com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint)2 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)2 LinkDataMap (com.navercorp.pinpoint.web.applicationmap.rawdata.LinkDataMap)2 Application (com.navercorp.pinpoint.web.vo.Application)2 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)1 AgentLifeCycleBo (com.navercorp.pinpoint.common.server.bo.AgentLifeCycleBo)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1