Search in sources :

Example 6 with ApplicationStatDecodingContext

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

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<JoinCpuLoadBo> 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<JoinCpuLoadBo> 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) JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo) 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 7 with ApplicationStatDecodingContext

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

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 ApplicationStatCodec<JoinDirectBufferBo> directBufferCodec = new DirectBufferCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinDirectBufferBo> 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<JoinDirectBufferBo> 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) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) JoinDirectBufferBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDirectBufferBo) 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 8 with ApplicationStatDecodingContext

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

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 ApplicationStatCodec<JoinMemoryBo> memoryCodec = new MemoryCodec(agentStatDataPointCodec);
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinMemoryBo> 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<JoinMemoryBo> 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) Date(java.util.Date) AgentStatDataPointCodec(com.navercorp.pinpoint.common.server.bo.codec.stat.AgentStatDataPointCodec) JoinMemoryBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinMemoryBo) 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 9 with ApplicationStatDecodingContext

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

the class TransactionCodecTest method encodeValuesTest.

@Test
public void encodeValuesTest() {
    final String id = "test_app";
    final long currentTime = new Date().getTime();
    ApplicationStatCodec<JoinTransactionBo> transactionCodec = new TransactionCodec(new AgentStatDataPointCodec());
    final Buffer encodedValueBuffer = new AutomaticBuffer();
    final List<JoinTransactionBo> joinTransactionBoList = createJoinTransactionBoList(currentTime);
    encodedValueBuffer.putByte(transactionCodec.getVersion());
    transactionCodec.encodeValues(encodedValueBuffer, joinTransactionBoList);
    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(), transactionCodec.getVersion());
    List<JoinTransactionBo> decodedJoinTransactionBoList = transactionCodec.decodeValues(valueBuffer, decodingContext);
    for (int i = 0; i < decodedJoinTransactionBoList.size(); i++) {
        assertEquals(decodedJoinTransactionBoList.get(i), joinTransactionBoList.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) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) ApplicationStatDecodingContext(com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext) AutomaticBuffer(com.navercorp.pinpoint.common.buffer.AutomaticBuffer) JoinTransactionBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinTransactionBo) Test(org.junit.Test)

Example 10 with ApplicationStatDecodingContext

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

the class ApplicationStatMapper method mapRow.

@Override
public List<T> 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<T> 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<T> candidates = this.decoder.decodeValue(valueBuffer, decodingContext);
            for (T 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) OffsetFixedBuffer(com.navercorp.pinpoint.common.buffer.OffsetFixedBuffer) Cell(org.apache.hadoop.hbase.Cell)

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