Search in sources :

Example 11 with ApplicationStatDecodingContext

use of com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext in project pinpoint by pinpoint-apm.

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 ApplicationStatCodec<JoinFileDescriptorBo> fileDescriptorCodec = new FileDescriptorCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinFileDescriptorBo> 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<JoinFileDescriptorBo> decodedJoinFileDescriptorBoList = fileDescriptorCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedJoinFileDescriptorBoList.size(); i++) {
        assertEquals(decodedJoinFileDescriptorBoList.get(i), joinFileDescriptorBoList.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) JoinFileDescriptorBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinFileDescriptorBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 12 with ApplicationStatDecodingContext

use of com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext in project pinpoint by pinpoint-apm.

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 ApplicationStatCodec<JoinLoadedClassBo> loadedClassCodec = new LoadedClassCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinLoadedClassBo> 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<JoinLoadedClassBo> 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) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) JoinLoadedClassBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinLoadedClassBo) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 13 with ApplicationStatDecodingContext

use of com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext in project pinpoint by pinpoint-apm.

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

Example 14 with ApplicationStatDecodingContext

use of com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext in project pinpoint by pinpoint-apm.

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 ApplicationStatCodec<JoinTotalThreadCountBo> totalThreadCountCodec = new TotalThreadCountCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinTotalThreadCountBo> 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<JoinTotalThreadCountBo> 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) JoinTotalThreadCountBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinTotalThreadCountBo) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Example 15 with ApplicationStatDecodingContext

use of com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext in project pinpoint by pinpoint-apm.

the class ActiveTraceCodecTest method encodeValuesTest.

@Test
public void encodeValuesTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    ApplicationStatCodec<JoinActiveTraceBo> activeTraceCodec = new ActiveTraceCodec(new AgentStatDataPointCodec());
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinActiveTraceBo> 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<JoinActiveTraceBo> 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) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) JoinActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) Test(org.junit.Test)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)22 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)22 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)20 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)20 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)20 Date (java.util.Date)20 Test (org.junit.Test)20 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)2 JoinActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinActiveTraceBo)2 JoinCpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo)2 JoinDataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinDataSourceListBo)2 JoinDirectBufferBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinDirectBufferBo)2 JoinFileDescriptorBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinFileDescriptorBo)2 JoinLoadedClassBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinLoadedClassBo)2 JoinMemoryBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo)2 JoinResponseTimeBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinResponseTimeBo)2 JoinTotalThreadCountBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinTotalThreadCountBo)2 JoinTransactionBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinTransactionBo)2 ArrayList (java.util.ArrayList)2 Cell (org.apache.hadoop.hbase.Cell)2