Search in sources :

Example 21 with JvmGcBo

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

the class JvmGcSamplerTest method gcCalculation_jvmRestarts_noPrevious.

@Test
public void gcCalculation_jvmRestarts_noPrevious() {
    // Given
    long firstAgentStartTimestamp = 10L;
    long secondAgentStartTimestamp = 1000L;
    long firstGcCount_1 = randomGcCount();
    long firstGcTime_1 = randomGcTime();
    JvmGcBo firstJvmGcBo_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, firstGcCount_1, firstGcTime_1);
    long secondGcCount_1 = randomGcCount() + firstGcCount_1;
    long secondGcTime_1 = randomGcTime() + firstGcTime_1;
    JvmGcBo secondJvmGcBo_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, secondGcCount_1, secondGcTime_1);
    long firstGcCount_2 = randomGcCount();
    long firstGcTime_2 = randomGcTime();
    JvmGcBo firstJvmGcBo_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, firstGcCount_2, firstGcTime_2);
    long secondGcCount_2 = randomGcCount() + firstGcCount_2;
    long secondGcTime_2 = randomGcTime() + firstGcTime_2;
    JvmGcBo secondJvmGcBo_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, secondGcCount_2, secondGcTime_2);
    // must be in descending order
    List<JvmGcBo> jvmGcBos = Arrays.asList(secondJvmGcBo_2, firstJvmGcBo_2, secondJvmGcBo_1, firstJvmGcBo_1);
    // When
    SampledJvmGc sampledJvmGc = sampler.sampleDataPoints(0, System.currentTimeMillis(), jvmGcBos, null);
    // Then
    long gcCountsBeforeJvmRestart = secondGcCount_1 - firstGcCount_1;
    long gcCountsAfterJvmRestart = secondGcCount_2;
    long gcTimesBeforeJvmRestart = secondGcTime_1 - firstGcTime_1;
    long gcTimesAfterJvmRestart = secondGcTime_2;
    long expectedGcCount = gcCountsBeforeJvmRestart + gcCountsAfterJvmRestart;
    long expectedGcTime = gcTimesBeforeJvmRestart + gcTimesAfterJvmRestart;
    long actualGcCount = sampledJvmGc.getGcOldCount().getSumYVal();
    long actualGcTime = sampledJvmGc.getGcOldTime().getSumYVal();
    Assert.assertEquals(expectedGcCount, actualGcCount);
    Assert.assertEquals(expectedGcTime, actualGcTime);
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) SampledJvmGc(com.navercorp.pinpoint.web.vo.stat.SampledJvmGc) Test(org.junit.Test)

Example 22 with JvmGcBo

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

the class AgentStatMapper method map.

@Override
public AgentStatBo map(TAgentStat tAgentStat) {
    if (tAgentStat == null) {
        return null;
    }
    final String agentId = tAgentStat.getAgentId();
    final long startTimestamp = tAgentStat.getStartTimestamp();
    final long timestamp = tAgentStat.getTimestamp();
    AgentStatBo agentStatBo = new AgentStatBo();
    agentStatBo.setAgentId(agentId);
    // jvmGc
    if (tAgentStat.isSetGc()) {
        JvmGcBo jvmGcBo = this.jvmGcBoMapper.map(tAgentStat.getGc());
        setBaseData(jvmGcBo, agentId, startTimestamp, timestamp);
        agentStatBo.setJvmGcBos(Arrays.asList(jvmGcBo));
    }
    // jvmGcDetailed
    if (tAgentStat.isSetGc()) {
        if (tAgentStat.getGc().isSetJvmGcDetailed()) {
            JvmGcDetailedBo jvmGcDetailedBo = this.jvmGcDetailedBoMapper.map(tAgentStat.getGc().getJvmGcDetailed());
            setBaseData(jvmGcDetailedBo, agentId, startTimestamp, timestamp);
            agentStatBo.setJvmGcDetailedBos(Arrays.asList(jvmGcDetailedBo));
        }
    }
    // cpuLoad
    if (tAgentStat.isSetCpuLoad()) {
        CpuLoadBo cpuLoadBo = this.cpuLoadBoMapper.map(tAgentStat.getCpuLoad());
        setBaseData(cpuLoadBo, agentId, startTimestamp, timestamp);
        agentStatBo.setCpuLoadBos(Arrays.asList(cpuLoadBo));
    }
    // transaction
    if (tAgentStat.isSetTransaction()) {
        TransactionBo transactionBo = this.transactionBoMapper.map(tAgentStat.getTransaction());
        setBaseData(transactionBo, agentId, startTimestamp, timestamp);
        transactionBo.setCollectInterval(tAgentStat.getCollectInterval());
        agentStatBo.setTransactionBos(Arrays.asList(transactionBo));
    }
    // activeTrace
    if (tAgentStat.isSetActiveTrace() && tAgentStat.getActiveTrace().isSetHistogram()) {
        ActiveTraceBo activeTraceBo = this.activeTraceBoMapper.map(tAgentStat.getActiveTrace());
        setBaseData(activeTraceBo, agentId, startTimestamp, timestamp);
        agentStatBo.setActiveTraceBos(Arrays.asList(activeTraceBo));
    }
    // datasource
    if (tAgentStat.isSetDataSourceList()) {
        DataSourceListBo dataSourceListBo = new DataSourceListBo();
        setBaseData(dataSourceListBo, agentId, startTimestamp, timestamp);
        TDataSourceList dataSourceList = tAgentStat.getDataSourceList();
        for (TDataSource dataSource : dataSourceList.getDataSourceList()) {
            DataSourceBo dataSourceBo = dataSourceBoMapper.map(dataSource);
            setBaseData(dataSourceBo, agentId, startTimestamp, timestamp);
            dataSourceListBo.add(dataSourceBo);
        }
        agentStatBo.setDataSourceListBos(Arrays.asList(dataSourceListBo));
    }
    return agentStatBo;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) TDataSourceList(com.navercorp.pinpoint.thrift.dto.TDataSourceList) JvmGcDetailedBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo) DataSourceListBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo) DataSourceBo(com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo) TransactionBo(com.navercorp.pinpoint.common.server.bo.stat.TransactionBo) TDataSource(com.navercorp.pinpoint.thrift.dto.TDataSource) ActiveTraceBo(com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)

Example 23 with JvmGcBo

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

the class JvmGcBoMapper method map.

@Override
public JvmGcBo map(TJvmGc tJvmGc) {
    JvmGcBo jvmGcBo = new JvmGcBo();
    jvmGcBo.setGcType(JvmGcType.valueOf(tJvmGc.getType().name()));
    jvmGcBo.setHeapUsed(tJvmGc.getJvmMemoryHeapUsed());
    jvmGcBo.setHeapMax(tJvmGc.getJvmMemoryHeapMax());
    jvmGcBo.setNonHeapUsed(tJvmGc.getJvmMemoryNonHeapUsed());
    jvmGcBo.setNonHeapMax(tJvmGc.getJvmMemoryNonHeapMax());
    jvmGcBo.setGcOldCount(tJvmGc.getJvmGcOldCount());
    jvmGcBo.setGcOldTime(tJvmGc.getJvmGcOldTime());
    return jvmGcBo;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)

Example 24 with JvmGcBo

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

the class JvmGcCodecV2 method encodeValues.

@Override
public void encodeValues(Buffer valueBuffer, List<JvmGcBo> jvmGcBos) {
    if (CollectionUtils.isEmpty(jvmGcBos)) {
        throw new IllegalArgumentException("jvmGcBos must not be empty");
    }
    final int gcTypeCode = jvmGcBos.get(0).getGcType().getTypeCode();
    valueBuffer.putVInt(gcTypeCode);
    final int numValues = jvmGcBos.size();
    valueBuffer.putVInt(numValues);
    List<Long> startTimestamps = new ArrayList<Long>(numValues);
    List<Long> timestamps = new ArrayList<Long>(numValues);
    UnsignedLongEncodingStrategy.Analyzer.Builder heapUsedAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    UnsignedLongEncodingStrategy.Analyzer.Builder heapMaxAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    UnsignedLongEncodingStrategy.Analyzer.Builder nonHeapUsedAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    UnsignedLongEncodingStrategy.Analyzer.Builder nonHeapMaxAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    UnsignedLongEncodingStrategy.Analyzer.Builder gcOldCountAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    UnsignedLongEncodingStrategy.Analyzer.Builder gcOldTimeAnalyzerBuilder = new UnsignedLongEncodingStrategy.Analyzer.Builder();
    for (JvmGcBo jvmGcBo : jvmGcBos) {
        startTimestamps.add(jvmGcBo.getStartTimestamp());
        timestamps.add(jvmGcBo.getTimestamp());
        heapUsedAnalyzerBuilder.addValue(jvmGcBo.getHeapUsed());
        heapMaxAnalyzerBuilder.addValue(jvmGcBo.getHeapMax());
        nonHeapUsedAnalyzerBuilder.addValue(jvmGcBo.getNonHeapUsed());
        nonHeapMaxAnalyzerBuilder.addValue(jvmGcBo.getNonHeapMax());
        gcOldCountAnalyzerBuilder.addValue(jvmGcBo.getGcOldCount());
        gcOldTimeAnalyzerBuilder.addValue(jvmGcBo.getGcOldTime());
    }
    this.codec.encodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, startTimestamps);
    this.codec.encodeTimestamps(valueBuffer, timestamps);
    this.encodeDataPoints(valueBuffer, heapUsedAnalyzerBuilder.build(), heapMaxAnalyzerBuilder.build(), nonHeapUsedAnalyzerBuilder.build(), nonHeapMaxAnalyzerBuilder.build(), gcOldCountAnalyzerBuilder.build(), gcOldTimeAnalyzerBuilder.build());
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) UnsignedLongEncodingStrategy(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedLongEncodingStrategy) ArrayList(java.util.ArrayList) StrategyAnalyzer(com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer)

Example 25 with JvmGcBo

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

the class JvmGcCodecV2 method decodeValues.

@Override
public List<JvmGcBo> decodeValues(Buffer valueBuffer, AgentStatDecodingContext decodingContext) {
    final String agentId = decodingContext.getAgentId();
    final long baseTimestamp = decodingContext.getBaseTimestamp();
    final long timestampDelta = decodingContext.getTimestampDelta();
    final long initialTimestamp = baseTimestamp + timestampDelta;
    final JvmGcType gcType = JvmGcType.getTypeByCode(valueBuffer.readVInt());
    int numValues = valueBuffer.readVInt();
    List<Long> startTimestamps = this.codec.decodeValues(valueBuffer, UnsignedLongEncodingStrategy.REPEAT_COUNT, numValues);
    List<Long> timestamps = this.codec.decodeTimestamps(initialTimestamp, valueBuffer, numValues);
    // decode headers
    final byte[] header = valueBuffer.readPrefixedBytes();
    AgentStatHeaderDecoder headerDecoder = new BitCountingHeaderDecoder(header);
    EncodingStrategy<Long> heapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> heapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapUsedEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> nonHeapMaxEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldCountEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> gcOldTimeEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    // decode values
    List<Long> heapUseds = this.codec.decodeValues(valueBuffer, heapUsedEncodingStrategy, numValues);
    List<Long> heapMaxes = this.codec.decodeValues(valueBuffer, heapMaxEncodingStrategy, numValues);
    List<Long> nonHeapUseds = this.codec.decodeValues(valueBuffer, nonHeapUsedEncodingStrategy, numValues);
    List<Long> nonHeapMaxes = this.codec.decodeValues(valueBuffer, nonHeapMaxEncodingStrategy, numValues);
    List<Long> gcOldCounts = this.codec.decodeValues(valueBuffer, gcOldCountEncodingStrategy, numValues);
    List<Long> gcOldTimes = this.codec.decodeValues(valueBuffer, gcOldTimeEncodingStrategy, numValues);
    List<JvmGcBo> jvmGcBos = new ArrayList<JvmGcBo>(numValues);
    for (int i = 0; i < numValues; ++i) {
        JvmGcBo jvmGcBo = new JvmGcBo();
        jvmGcBo.setAgentId(agentId);
        jvmGcBo.setStartTimestamp(startTimestamps.get(i));
        jvmGcBo.setTimestamp(timestamps.get(i));
        jvmGcBo.setGcType(gcType);
        jvmGcBo.setHeapUsed(heapUseds.get(i));
        jvmGcBo.setHeapMax(heapMaxes.get(i));
        jvmGcBo.setNonHeapUsed(nonHeapUseds.get(i));
        jvmGcBo.setNonHeapMax(nonHeapMaxes.get(i));
        jvmGcBo.setGcOldCount(gcOldCounts.get(i));
        jvmGcBo.setGcOldTime(gcOldTimes.get(i));
        jvmGcBos.add(jvmGcBo);
    }
    return jvmGcBos;
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList) JvmGcType(com.navercorp.pinpoint.common.server.bo.JvmGcType) AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)

Aggregations

JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)28 SampledJvmGc (com.navercorp.pinpoint.web.vo.stat.SampledJvmGc)15 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)7 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)6 Range (com.navercorp.pinpoint.web.vo.Range)6 JvmGcType (com.navercorp.pinpoint.common.server.bo.JvmGcType)3 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 BeforeClass (org.junit.BeforeClass)3 AgentStatHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder)2 BitCountingHeaderDecoder (com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder)2 StrategyAnalyzer (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.StrategyAnalyzer)2 UnsignedLongEncodingStrategy (com.navercorp.pinpoint.common.server.bo.codec.stat.strategy.UnsignedLongEncodingStrategy)2 ActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)2 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)2 DataSourceBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceBo)2 DataSourceListBo (com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo)2 JvmGcDetailedBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcDetailedBo)2