Search in sources :

Example 1 with ApplicationStatDecodingContext

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

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 FileDescriptorCodec fileDescriptorCodec = new FileDescriptorCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinStatBo> 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<JoinStatBo> 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) 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 2 with ApplicationStatDecodingContext

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

the class DataSourceCodecTest method encodeAndDecodeTest.

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

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

the class CpuLoadCodecTest method encodeAndDecodeTest.

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

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

the class DirectBufferCodecTest method encodeAndDecodeTest.

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

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

the class ApplicationStatMapper method mapRow.

@Override
public List<JoinStatBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    final byte[] distributedRowKey = result.getRow();
    final String applicationId = this.hbaseOperationFactory.getApplicationId(distributedRowKey);
    final long baseTimestamp = this.hbaseOperationFactory.getBaseTimestamp(distributedRowKey);
    List<JoinStatBo> dataPoints = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        if (CellUtil.matchingFamily(cell, HbaseColumnFamily.APPLICATION_STAT_STATISTICS.getName())) {
            Buffer qualifierBuffer = new OffsetFixedBuffer(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());
            Buffer valueBuffer = new OffsetFixedBuffer(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
            long timestampDelta = this.decoder.decodeQualifier(qualifierBuffer);
            ApplicationStatDecodingContext decodingContext = new ApplicationStatDecodingContext();
            decodingContext.setApplicationId(applicationId);
            decodingContext.setBaseTimestamp(baseTimestamp);
            decodingContext.setTimestampDelta(timestampDelta);
            List<JoinStatBo> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
            for (JoinStatBo candidate : candidates) {
                long timestamp = candidate.getTimestamp();
                if (this.filter.filter(timestamp)) {
                    continue;
                }
                dataPoints.add(candidate);
            }
        }
    }
    // Reverse sort as timestamp is stored in a reversed order.
    dataPoints.sort(REVERSE_TIMESTAMP_COMPARATOR);
    return dataPoints;
}
Also used : Buffer(com.navercorp.pinpoint.common.buffer.Buffer) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Cell(org.apache.hadoop.hbase.Cell)

Aggregations

Buffer (com.navercorp.pinpoint.common.buffer.Buffer)11 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)11 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)11 AutomaticBuffer (com.navercorp.pinpoint.common.buffer.AutomaticBuffer)10 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)10 AgentStatDataPointCodec (com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec)10 Date (java.util.Date)10 Test (org.junit.Test)10 OffsetFixedBuffer (com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer)1 ArrayList (java.util.ArrayList)1 Cell (org.apache.hadoop.hbase.Cell)1