Search in sources :

Example 26 with JoinStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo 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 27 with JoinStatBo

use of com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo 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 28 with JoinStatBo

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

the class TBaseFlatMapperTest method flatMapTest.

@Test
public void flatMapTest() throws Exception {
    ApplicationCache applicationCache = newMockApplicationCache();
    TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
    TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch();
    ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
    ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
    RawData rawData = newRawData(tfAgentStatBatch);
    mapper.flatMap(rawData, collector);
    assertEquals(dataList.size(), 2);
    Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
    assertEquals(data1.f0, AGENT_ID);
    assertEquals(data1.f2.longValue(), 1491274143454L);
    JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
    assertEquals(joinAgentStatBo.getId(), AGENT_ID);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
    assertJoinCpuLoadBo(joinAgentStatBo.getJoinCpuLoadBoList());
    Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
    assertEquals(data2.f0, APPLICATION_ID);
    assertEquals(data2.f2.longValue(), 1491274140000L);
    JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
    assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
    assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
    assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
    assertJoinCpuLoadBo(joinApplicationStatBo.getJoinCpuLoadBoList());
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinApplicationStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) ListCollector(org.apache.flink.api.common.functions.util.ListCollector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Test(org.junit.Test)

Example 29 with JoinStatBo

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

the class TBaseFlatMapperTest method flatMap2Test.

@Test
public void flatMap2Test() throws Exception {
    ApplicationCache applicationCache = newMockApplicationCache();
    TBaseFlatMapper mapper = new TBaseFlatMapper(new JoinAgentStatBoMapper(), applicationCache, new DefaultTBaseFlatMapperInterceptor());
    TFAgentStatBatch tfAgentStatBatch = createTFAgentStatBatch2();
    ArrayList<Tuple3<String, JoinStatBo, Long>> dataList = new ArrayList<>();
    ListCollector<Tuple3<String, JoinStatBo, Long>> collector = new ListCollector<>(dataList);
    RawData rawdata = newRawData(tfAgentStatBatch);
    mapper.flatMap(rawdata, collector);
    assertEquals(dataList.size(), 2);
    Tuple3<String, JoinStatBo, Long> data1 = dataList.get(0);
    assertEquals(data1.f0, AGENT_ID);
    assertEquals(data1.f2.longValue(), 1491274143454L);
    JoinAgentStatBo joinAgentStatBo = (JoinAgentStatBo) data1.f1;
    assertEquals(joinAgentStatBo.getId(), AGENT_ID);
    assertEquals(joinAgentStatBo.getAgentStartTimestamp(), 1491274142454L);
    assertEquals(joinAgentStatBo.getTimestamp(), 1491274143454L);
    assertJoinMemoryBo(joinAgentStatBo.getJoinMemoryBoList());
    Tuple3<String, JoinStatBo, Long> data2 = dataList.get(1);
    assertEquals(data2.f0, APPLICATION_ID);
    assertEquals(data2.f2.longValue(), 1491274140000L);
    JoinApplicationStatBo joinApplicationStatBo = (JoinApplicationStatBo) data2.f1;
    assertEquals(joinApplicationStatBo.getId(), APPLICATION_ID);
    assertEquals(joinApplicationStatBo.getTimestamp(), 1491274140000L);
    assertEquals(joinApplicationStatBo.getStatType(), StatType.APP_STST);
    assertJoinMemoryBo(joinApplicationStatBo.getJoinMemoryBoList());
}
Also used : RawData(com.navercorp.pinpoint.flink.vo.RawData) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo) JoinApplicationStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo) TFAgentStatBatch(com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch) JoinAgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo) ListCollector(org.apache.flink.api.common.functions.util.ListCollector) Tuple3(org.apache.flink.api.java.tuple.Tuple3) JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Test(org.junit.Test)

Example 30 with JoinStatBo

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

the class DirectBufferCodecTest method createJoinDirectBufferBoList.

private List<JoinStatBo> createJoinDirectBufferBoList(long currentTime) {
    final String id = "test_app";
    final List<JoinStatBo> joinDirectBufferBoList = new ArrayList<>();
    JoinDirectBufferBo joinDirectBufferBo1 = new JoinDirectBufferBo(id, 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", 80, 1000, "agent1_1", 30, "agent1_2", currentTime);
    JoinDirectBufferBo joinDirectBufferBo2 = new JoinDirectBufferBo(id, 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", 70, 900, "agent2_1", 20, "agent2_2", currentTime + 5000);
    JoinDirectBufferBo joinDirectBufferBo4 = new JoinDirectBufferBo(id, 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", 60, 800, "agent4_1", 15, "agent4_2", currentTime + 15000);
    JoinDirectBufferBo joinDirectBufferBo3 = new JoinDirectBufferBo(id, 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", 50, 700, "agent3_1", 10, "agent3_2", currentTime + 10000);
    JoinDirectBufferBo joinDirectBufferBo5 = new JoinDirectBufferBo(id, 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", 40, 600, "agent5_1", 5, "agent5_2", currentTime + 20000);
    joinDirectBufferBoList.add(joinDirectBufferBo1);
    joinDirectBufferBoList.add(joinDirectBufferBo2);
    joinDirectBufferBoList.add(joinDirectBufferBo3);
    joinDirectBufferBoList.add(joinDirectBufferBo4);
    joinDirectBufferBoList.add(joinDirectBufferBo5);
    return joinDirectBufferBoList;
}
Also used : JoinDirectBufferBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinDirectBufferBo) ArrayList(java.util.ArrayList) JoinStatBo(com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)

Aggregations

JoinStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinStatBo)47 ArrayList (java.util.ArrayList)36 Test (org.junit.Test)15 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)11 ApplicationStatDecodingContext (com.navercorp.pinpoint.common.server.bo.serializer.stat.ApplicationStatDecodingContext)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 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)9 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)9 JoinLongFieldEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldEncodingStrategy)8 JoinLongFieldStrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.JoinLongFieldStrategyAnalyzer)8 JoinLongFieldBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinLongFieldBo)8 JoinAgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinAgentStatBo)5 JoinApplicationStatBo (com.navercorp.pinpoint.common.server.bo.stat.join.JoinApplicationStatBo)5 JoinAgentStatBoMapper (com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper)5 RawData (com.navercorp.pinpoint.flink.vo.RawData)5 TFAgentStatBatch (com.navercorp.pinpoint.thrift.dto.flink.TFAgentStatBatch)5 ListCollector (org.apache.flink.api.common.functions.util.ListCollector)5