Search in sources :

Example 6 with JoinCpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo in project pinpoint by naver.

the class CpuLoadCodec method decodeValues.

@Override
public List<JoinStatBo> decodeValues(Buffer valueBuffer, ApplicationStatDecodingContext decodingContext) {
    final String id = decodingContext.getApplicationId();
    final long baseTimestamp = decodingContext.getBaseTimestamp();
    final long timestampDelta = decodingContext.getTimestampDelta();
    final long initialTimestamp = baseTimestamp + timestampDelta;
    int numValues = valueBuffer.readVInt();
    List<Long> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
    // decode headers
    final byte[] header = valueBuffer.readPrefixedBytes();
    AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
    JoinLongFieldEncodingStrategy jvmCpuLoadEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
    JoinLongFieldEncodingStrategy systemCpuLoadEncodingStrategy = JoinLongFieldEncodingStrategy.getFromCode(headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode(), headerDecoder.getCode());
    // decode values
    final List<JoinLongFieldBo> jvmCpuLoadList = this.codec.decodeValues(valueBuffer, jvmCpuLoadEncodingStrategy, numValues);
    final List<JoinLongFieldBo> systemCpuLoadList = this.codec.decodeValues(valueBuffer, systemCpuLoadEncodingStrategy, numValues);
    List<JoinStatBo> joinCpuLoadBoList = new ArrayList<>(numValues);
    for (int i = 0; i < numValues; i++) {
        JoinCpuLoadBo joinCpuLoadBo = new JoinCpuLoadBo();
        joinCpuLoadBo.setId(id);
        joinCpuLoadBo.setTimestamp(timestamps.get(i));
        joinCpuLoadBo.setJvmCpuLoadJoinValue(jvmCpuLoadList.get(i).toLongFieldBo());
        joinCpuLoadBo.setSystemCpuLoadJoinValue(systemCpuLoadList.get(i).toLongFieldBo());
        joinCpuLoadBoList.add(joinCpuLoadBo);
    }
    return joinCpuLoadBoList;
}
Also used : BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinLongFieldEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldEncodingStrategy) JoinLongFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinLongFieldBo) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder) JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo)

Example 7 with JoinCpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo in project pinpoint by naver.

the class CpuLoadCodec method encodeValues.

@Override
public void encodeValues(Buffer valueBuffer, List<JoinStatBo> joinCpuLoadBoList) {
    if (CollectionUtils.isEmpty(joinCpuLoadBoList)) {
        throw new IllegalArgumentException("cpuLoadBoList must not be empty");
    }
    final int numValues = joinCpuLoadBoList.size();
    valueBuffer.putVInt(numValues);
    List<Long> timestamps = new ArrayList<>(numValues);
    JoinLongFieldStrategyAnalyzer.Builder jvmCpuLoadAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
    JoinLongFieldStrategyAnalyzer.Builder systemCpuLoadAnalyzerBuilder = new JoinLongFieldStrategyAnalyzer.Builder();
    for (JoinStatBo joinStatBo : joinCpuLoadBoList) {
        JoinCpuLoadBo joinCpuLoadBo = (JoinCpuLoadBo) joinStatBo;
        timestamps.add(joinCpuLoadBo.getTimestamp());
        jvmCpuLoadAnalyzerBuilder.addValue(joinCpuLoadBo.getJvmCpuLoadJoinValue().toLongFieldBo());
        systemCpuLoadAnalyzerBuilder.addValue(joinCpuLoadBo.getSystemCpuLoadJoinValue().toLongFieldBo());
    }
    codec.encodeTimestamps(valueBuffer, timestamps);
    encodeDataPoints(valueBuffer, jvmCpuLoadAnalyzerBuilder.build(), systemCpuLoadAnalyzerBuilder.build());
}
Also used : JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo) JoinLongFieldStrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldStrategyAnalyzer) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)

Example 8 with JoinCpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo in project pinpoint by naver.

the class JoinThriftCpuLoadBoMapperTest method mapTest.

@Test
public void mapTest() throws Exception {
    final TFAgentStat tFAgentStat = new TFAgentStat();
    tFAgentStat.setAgentId("testAgent");
    tFAgentStat.setTimestamp(1491274138454L);
    final TFCpuLoad tfCpuLoad = new TFCpuLoad();
    tfCpuLoad.setJvmCpuLoad(10);
    tfCpuLoad.setSystemCpuLoad(30);
    tFAgentStat.setCpuLoad(tfCpuLoad);
    final JoinCpuLoadBoMapper mapper = new JoinCpuLoadBoMapper();
    final JoinCpuLoadBo joinCpuLoadBo = mapper.map(tFAgentStat);
    assertNotNull(joinCpuLoadBo);
    assertEquals(joinCpuLoadBo.getId(), "testAgent");
    assertEquals(joinCpuLoadBo.getTimestamp(), 1491274138454L);
    final JoinDoubleFieldBo jvmCpuLoadJoinValue = joinCpuLoadBo.getJvmCpuLoadJoinValue();
    assertEquals(jvmCpuLoadJoinValue.getAvg(), 10, 0);
    assertEquals(jvmCpuLoadJoinValue.getMin(), 10, 0);
    assertEquals(jvmCpuLoadJoinValue.getMax(), 10, 0);
    final JoinDoubleFieldBo systemCpuLoadJoinValue = joinCpuLoadBo.getSystemCpuLoadJoinValue();
    assertEquals(systemCpuLoadJoinValue.getAvg(), 30, 0);
    assertEquals(systemCpuLoadJoinValue.getMin(), 30, 0);
    assertEquals(systemCpuLoadJoinValue.getMax(), 30, 0);
}
Also used : JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo) TFCpuLoad(com.navercorp.pinpoint.thrift.dto.flink.TFCpuLoad) JoinDoubleFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDoubleFieldBo) TFAgentStat(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat) Test(org.junit.Test)

Example 9 with JoinCpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo in project pinpoint by naver.

the class JoinAgentStatBoMapperTest method mapTest.

@Test
public void mapTest() {
    final String agentId = "testAgent";
    final JoinAgentStatBoMapper joinAgentStatBoMapper = new JoinAgentStatBoMapper();
    final TFAgentStatBatch tFAgentStatBatch = new TFAgentStatBatch();
    tFAgentStatBatch.setStartTimestamp(1491274138454L);
    tFAgentStatBatch.setAgentId(agentId);
    final TFAgentStat tFAgentStat = new TFAgentStat();
    tFAgentStat.setAgentId(agentId);
    tFAgentStat.setTimestamp(1491274148454L);
    final TFCpuLoad tFCpuLoad = new TFCpuLoad();
    tFCpuLoad.setJvmCpuLoad(10);
    tFCpuLoad.setSystemCpuLoad(30);
    tFAgentStat.setCpuLoad(tFCpuLoad);
    final TFAgentStat tFAgentStat2 = new TFAgentStat();
    tFAgentStat2.setAgentId(agentId);
    tFAgentStat2.setTimestamp(1491275148454L);
    final TFCpuLoad tFCpuLoad2 = new TFCpuLoad();
    tFCpuLoad2.setJvmCpuLoad(20);
    tFCpuLoad2.setSystemCpuLoad(50);
    tFAgentStat2.setCpuLoad(tFCpuLoad2);
    final List<TFAgentStat> tFAgentStatList = new ArrayList<>(2);
    tFAgentStatList.add(tFAgentStat);
    tFAgentStatList.add(tFAgentStat2);
    tFAgentStatBatch.setAgentStats(tFAgentStatList);
    JoinAgentStatBo joinAgentStatBo = joinAgentStatBoMapper.map(tFAgentStatBatch);
    assertEquals(joinAgentStatBo.getId(), agentId);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274138454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274148454L);
    List<JoinCpuLoadBo> joinCpuLoadBoList = joinAgentStatBo.getJoinCpuLoadBoList();
    assertEquals(joinCpuLoadBoList.size(), 2);
    JoinCpuLoadBo joinCpuLoadBo = joinCpuLoadBoList.get(0);
    assertEquals(joinCpuLoadBo.getId(), agentId);
    assertEquals(joinCpuLoadBo.getTimestamp(), 1491274148454L);
    JoinDoubleFieldBo jvmCpuLoadJoinValue = joinCpuLoadBo.getJvmCpuLoadJoinValue();
    assertEquals(jvmCpuLoadJoinValue.getAvg(), 10, 0);
    assertEquals(jvmCpuLoadJoinValue.getMin(), 10, 0);
    assertEquals(jvmCpuLoadJoinValue.getMax(), 10, 0);
    JoinDoubleFieldBo systemCpuLoadJoinValue = joinCpuLoadBo.getSystemCpuLoadJoinValue();
    assertEquals(systemCpuLoadJoinValue.getAvg(), 30, 0);
    assertEquals(systemCpuLoadJoinValue.getMin(), 30, 0);
    assertEquals(systemCpuLoadJoinValue.getMax(), 30, 0);
    joinCpuLoadBo = joinCpuLoadBoList.get(1);
    assertEquals(joinCpuLoadBo.getId(), agentId);
    assertEquals(joinCpuLoadBo.getTimestamp(), 1491275148454L);
    jvmCpuLoadJoinValue = joinCpuLoadBo.getJvmCpuLoadJoinValue();
    assertEquals(jvmCpuLoadJoinValue.getAvg(), 20, 0);
    assertEquals(jvmCpuLoadJoinValue.getMin(), 20, 0);
    assertEquals(jvmCpuLoadJoinValue.getMax(), 20, 0);
    systemCpuLoadJoinValue = joinCpuLoadBo.getSystemCpuLoadJoinValue();
    assertEquals(systemCpuLoadJoinValue.getAvg(), 50, 0);
    assertEquals(systemCpuLoadJoinValue.getMin(), 50, 0);
    assertEquals(systemCpuLoadJoinValue.getMax(), 50, 0);
}
Also used : JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo) TFCpuLoad(com.navercorp.pinpoint.thrift.dto.flink.TFCpuLoad) ArrayList(java.util.ArrayList) JoinDoubleFieldBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDoubleFieldBo) TFAgentStat(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) Test(org.junit.Test)

Example 10 with JoinCpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo in project pinpoint by naver.

the class JoinCpuLoadBoMapper method build.

@Override
public void build(TFAgentStat tFAgentStat, JoinAgentStatBo.Builder builder) {
    JoinCpuLoadBo joinCpuLoadBo = this.map(tFAgentStat);
    if (joinCpuLoadBo == JoinCpuLoadBo.EMPTY_JOIN_CPU_LOAD_BO) {
        return;
    }
    builder.addCpuLoadBo(joinCpuLoadBo);
}
Also used : JoinCpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo)

Aggregations

JoinCpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinCpuLoadBo)11 JoinDoubleFieldBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinDoubleFieldBo)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)3 TFAgentStat (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStat)3 TFCpuLoad (com.navercorp.pinpoint.thrift.dto.flink.TFCpuLoad)3 AggreJoinCpuLoadBo (com.navercorp.pinpoint.web.vo.stat.AggreJoinCpuLoadBo)2 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)1 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)1 JoinLongFieldEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldEncodingStrategy)1 JoinLongFieldStrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldStrategyAnalyzer)1 JoinAgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo)1 JoinLongFieldBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinLongFieldBo)1 TFAgentStatBatch (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch)1 Date (java.util.Date)1