Search in sources :

Example 1 with ActiveTraceHistogramBo

use of com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo in project pinpoint by naver.

the class ActiveTraceHistogramBoTest method null_activeTraceCounts_should_return_valid_map_per_version.

@Test
public void null_activeTraceCounts_should_return_valid_map_per_version() {
    // Given
    final int validVersion = 0;
    final int expectedHistogramSchemaType = 1;
    final Map<SlotType, Integer> expectedActiveTraceCountMap = new HashMap<SlotType, Integer>();
    expectedActiveTraceCountMap.put(SlotType.FAST, 0);
    expectedActiveTraceCountMap.put(SlotType.NORMAL, 0);
    expectedActiveTraceCountMap.put(SlotType.SLOW, 0);
    expectedActiveTraceCountMap.put(SlotType.VERY_SLOW, 0);
    // When
    ActiveTraceHistogramBo expectedBo = new ActiveTraceHistogramBo(validVersion, expectedHistogramSchemaType, null);
    byte[] serializedBo = expectedBo.writeValue();
    ActiveTraceHistogramBo deserializedBo = new ActiveTraceHistogramBo(serializedBo);
    // Then
    assertEquals(validVersion, deserializedBo.getVersion());
    assertEquals(expectedHistogramSchemaType, deserializedBo.getHistogramSchemaType());
    assertEquals(expectedActiveTraceCountMap, deserializedBo.getActiveTraceCountMap());
}
Also used : HashMap(java.util.HashMap) ActiveTraceHistogramBo(com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo) SlotType(com.navercorp.pinpoint.common.trace.SlotType) Test(org.junit.Test)

Example 2 with ActiveTraceHistogramBo

use of com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo in project pinpoint by naver.

the class HbaseAgentStatDao method createPut.

private Put createPut(TAgentStat agentStat) {
    long timestamp = agentStat.getTimestamp();
    byte[] key = getDistributedRowKey(agentStat, timestamp);
    Put put = new Put(key);
    final long collectInterval = agentStat.getCollectInterval();
    put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_INTERVAL, Bytes.toBytes(collectInterval));
    // GC, Memory
    if (agentStat.isSetGc()) {
        TJvmGc gc = agentStat.getGc();
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_GC_TYPE, Bytes.toBytes(gc.getType().name()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_GC_OLD_COUNT, Bytes.toBytes(gc.getJvmGcOldCount()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_GC_OLD_TIME, Bytes.toBytes(gc.getJvmGcOldTime()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_HEAP_USED, Bytes.toBytes(gc.getJvmMemoryHeapUsed()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_HEAP_MAX, Bytes.toBytes(gc.getJvmMemoryHeapMax()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_NON_HEAP_USED, Bytes.toBytes(gc.getJvmMemoryNonHeapUsed()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_NON_HEAP_MAX, Bytes.toBytes(gc.getJvmMemoryNonHeapMax()));
    } else {
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_GC_TYPE, Bytes.toBytes(TJvmGcType.UNKNOWN.name()));
    }
    // CPU
    if (agentStat.isSetCpuLoad()) {
        TCpuLoad cpuLoad = agentStat.getCpuLoad();
        double jvmCpuLoad = AgentStatUtils.convertLongToDouble(AgentStatUtils.convertDoubleToLong(cpuLoad.getJvmCpuLoad()));
        double systemCpuLoad = AgentStatUtils.convertLongToDouble(AgentStatUtils.convertDoubleToLong(cpuLoad.getSystemCpuLoad()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_JVM_CPU, Bytes.toBytes(jvmCpuLoad));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_SYS_CPU, Bytes.toBytes(systemCpuLoad));
    }
    // Transaction
    if (agentStat.isSetTransaction()) {
        TTransaction transaction = agentStat.getTransaction();
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_TRANSACTION_SAMPLED_NEW, Bytes.toBytes(transaction.getSampledNewCount()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_TRANSACTION_SAMPLED_CONTINUATION, Bytes.toBytes(transaction.getSampledContinuationCount()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_TRANSACTION_UNSAMPLED_NEW, Bytes.toBytes(transaction.getUnsampledNewCount()));
        put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_TRANSACTION_UNSAMPLED_CONTINUATION, Bytes.toBytes(transaction.getUnsampledContinuationCount()));
    }
    // Active Trace
    if (agentStat.isSetActiveTrace()) {
        TActiveTrace activeTrace = agentStat.getActiveTrace();
        if (activeTrace.isSetHistogram()) {
            ActiveTraceHistogramBo activeTraceHistogramBo = this.activeTraceHistogramBoMapper.map(activeTrace.getHistogram());
            put.addColumn(AGENT_STAT_CF_STATISTICS, AGENT_STAT_COL_ACTIVE_TRACE_HISTOGRAM, activeTraceHistogramBo.writeValue());
        }
    }
    return put;
}
Also used : TActiveTrace(com.navercorp.pinpoint.thrift.dto.TActiveTrace) ActiveTraceHistogramBo(com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo) TJvmGc(com.navercorp.pinpoint.thrift.dto.TJvmGc) TCpuLoad(com.navercorp.pinpoint.thrift.dto.TCpuLoad) Put(org.apache.hadoop.hbase.client.Put) TTransaction(com.navercorp.pinpoint.thrift.dto.TTransaction)

Example 3 with ActiveTraceHistogramBo

use of com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo in project pinpoint by naver.

the class ActiveTraceHistogramBoMapper method map.

@Override
public ActiveTraceHistogramBo map(TActiveTraceHistogram tActiveTraceHistogram) {
    int version = tActiveTraceHistogram.getVersion();
    int histogramSchemaType = tActiveTraceHistogram.getHistogramSchemaType();
    List<Integer> activeThreadCount = tActiveTraceHistogram.getActiveTraceCount();
    ActiveTraceHistogramBo bo = new ActiveTraceHistogramBo(version, histogramSchemaType, activeThreadCount);
    return bo;
}
Also used : ActiveTraceHistogramBo(com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo)

Example 4 with ActiveTraceHistogramBo

use of com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo in project pinpoint by naver.

the class ActiveTraceHistogramBoTest method unsupported_version_should_return_empty_bo.

@Test
public void unsupported_version_should_return_empty_bo() {
    // Given
    final int unsupportedVersion = 255;
    final int expectedHistogramSchemaType = 1;
    // When
    ActiveTraceHistogramBo givenBo = new ActiveTraceHistogramBo(unsupportedVersion, expectedHistogramSchemaType, Arrays.asList(0, 1));
    byte[] serializedBo = givenBo.writeValue();
    ActiveTraceHistogramBo deserializedBo = new ActiveTraceHistogramBo(serializedBo);
    // Then
    assertEquals(unsupportedVersion, deserializedBo.getVersion());
    assertEquals(expectedHistogramSchemaType, deserializedBo.getHistogramSchemaType());
    assertEquals(Collections.emptyMap(), deserializedBo.getActiveTraceCountMap());
}
Also used : ActiveTraceHistogramBo(com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo) Test(org.junit.Test)

Example 5 with ActiveTraceHistogramBo

use of com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo in project pinpoint by naver.

the class ActiveTraceHistogramBoTest method writeValue_should_be_reconstructed_correctly.

@Test
public void writeValue_should_be_reconstructed_correctly() {
    // Given
    final int validVersion = 0;
    final int expectedHistogramSchemaType = 1;
    final List<Integer> expectedActiveTraceCounts = Arrays.asList(0, 1, 2, 3);
    // When
    ActiveTraceHistogramBo expectedBo = new ActiveTraceHistogramBo(validVersion, expectedHistogramSchemaType, expectedActiveTraceCounts);
    byte[] serializedBo = expectedBo.writeValue();
    ActiveTraceHistogramBo deserializedBo = new ActiveTraceHistogramBo(serializedBo);
    // Then
    assertEquals(expectedBo, deserializedBo);
}
Also used : ActiveTraceHistogramBo(com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo) Test(org.junit.Test)

Aggregations

ActiveTraceHistogramBo (com.navercorp.pinpoint.common.server.bo.ActiveTraceHistogramBo)6 Test (org.junit.Test)3 SlotType (com.navercorp.pinpoint.common.trace.SlotType)1 TActiveTrace (com.navercorp.pinpoint.thrift.dto.TActiveTrace)1 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)1 TCpuLoad (com.navercorp.pinpoint.thrift.dto.TCpuLoad)1 TJvmGc (com.navercorp.pinpoint.thrift.dto.TJvmGc)1 TTransaction (com.navercorp.pinpoint.thrift.dto.TTransaction)1 AgentStat (com.navercorp.pinpoint.web.vo.AgentStat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Put (org.apache.hadoop.hbase.client.Put)1