Search in sources :

Example 51 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class ActiveTraceCodecTest method encodeValuesTest.

@Test
public void encodeValuesTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    ActiveTraceCodec activeTraceCodec = new ActiveTraceCodec(new AgentStatDataPointCodec());
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinStatBo> joinActiveTraceBoList = createJoinActiveTRaceBoList(currentTime);
    encodedValueBuffer.putByte(activeTraceCodec.getVersion());
    activeTraceCodec.encodeValues(encodedValueBuffer, joinActiveTraceBoList);
    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(), activeTraceCodec.getVersion());
    List<JoinStatBo> decodedJoinActiveTraceBoList = activeTraceCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedJoinActiveTraceBoList.size(); i++) {
        assertEquals(decodedJoinActiveTraceBoList.get(i), joinActiveTraceBoList.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 52 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer in project pinpoint by naver.

the class LoadedClassCountCodecTest method encodeAndDecodeTest.

@Test
public void encodeAndDecodeTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    final AgentStatDataPointCodec agentStatDataPointCodec = new AgentStatDataPointCodec();
    final LoadedClassCodec loadedClassCodec = new LoadedClassCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinStatBo> joinLoadedClassBoList = createJoinLoadedClassCountBoList(currentTime);
    encodedValueBuffer.putByte(loadedClassCodec.getVersion());
    loadedClassCodec.encodeValues(encodedValueBuffer, joinLoadedClassBoList);
    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(), loadedClassCodec.getVersion());
    List<JoinStatBo> decodedJoinLoadedClassBoList = loadedClassCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedJoinLoadedClassBoList.size(); i++) {
        assertEquals(decodedJoinLoadedClassBoList.get(i), joinLoadedClassBoList.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 53 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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 54 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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 55 with AutomaticBuffer

use of com.navercorp.pinpoint.common.buffer.AutomaticBuffer 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)

Aggregations

AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)68 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)68 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)30 Test (org.junit.Test)16 ByteBuffer (java.nio.ByteBuffer)15 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 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Put (org.apache.hadoop.hbase.client.Put)4 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)3 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)3 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 BasicSpan (com.navercorp.pinpoint.common.server.bo.BasicSpan)2 StringStringValue (com.navercorp.pinpoint.common.util.StringStringValue)2 TableName (org.apache.hadoop.hbase.TableName)2 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 TransactionId (com.navercorp.pinpoint.common.profiler.util.TransactionId)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1