Search in sources :

Example 11 with JvmGcBo

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

the class AgentStatBatchMapper method map.

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

Example 12 with JvmGcBo

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

the class JvmGcCodecV1 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> 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.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)

Example 13 with JvmGcBo

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

the class GcCountCheckerTest method before.

@BeforeClass
public static void before() {
    jvmGcDao = new AgentStatDao<JvmGcBo>() {

        @Override
        public List<JvmGcBo> getAgentStatList(String agentId, Range range) {
            List<JvmGcBo> jvmGcs = new LinkedList<>();
            for (int i = 36; i > 0; i--) {
                JvmGcBo jvmGc = new JvmGcBo();
                jvmGc.setGcOldCount(i);
                jvmGcs.add(jvmGc);
            }
            return jvmGcs;
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return true;
        }
    };
    cpuLoadDao = new AgentStatDao<CpuLoadBo>() {

        @Override
        public List<CpuLoadBo> getAgentStatList(String agentId, Range range) {
            return Collections.emptyList();
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return false;
        }
    };
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        public List<String> selectAgentIds(String applicationName) {
            if (SERVICE_NAME.equals(applicationName)) {
                List<String> agentIds = new LinkedList<String>();
                agentIds.add("local_tomcat");
                return agentIds;
            }
            throw new IllegalArgumentException();
        }

        @Override
        public void deleteApplicationName(String applicationName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentId(String applicationName, String agentId) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) Range(com.navercorp.pinpoint.web.vo.Range) List(java.util.List) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

Example 14 with JvmGcBo

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

the class JvmCpuUsageRateCheckerTest method before.

@BeforeClass
public static void before() {
    jvmGcDao = new AgentStatDao<JvmGcBo>() {

        @Override
        public List<JvmGcBo> getAgentStatList(String agentId, Range range) {
            return Collections.emptyList();
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return false;
        }
    };
    cpuLoadDao = new AgentStatDao<CpuLoadBo>() {

        public List<CpuLoadBo> getAgentStatList(String agentId, Range range) {
            List<CpuLoadBo> cpuLoads = new LinkedList<>();
            for (int i = 0; i < 36; i++) {
                CpuLoadBo cpuLoad = new CpuLoadBo();
                cpuLoad.setJvmCpuLoad(0.6);
                cpuLoads.add(cpuLoad);
            }
            return cpuLoads;
        }

        @Override
        public boolean agentStatExists(String agentId, Range range) {
            return true;
        }
    };
    applicationIndexDao = new ApplicationIndexDao() {

        @Override
        public List<Application> selectAllApplicationNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        public List<String> selectAgentIds(String applicationName) {
            if (SERVICE_NAME.equals(applicationName)) {
                List<String> agentIds = new LinkedList<String>();
                agentIds.add("local_tomcat");
                return agentIds;
            }
            throw new IllegalArgumentException();
        }

        @Override
        public void deleteApplicationName(String applicationName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentIds(Map<String, List<String>> applicationAgentIdMap) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void deleteAgentId(String applicationName, String agentId) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) ApplicationIndexDao(com.navercorp.pinpoint.web.dao.ApplicationIndexDao) Range(com.navercorp.pinpoint.web.vo.Range) List(java.util.List) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

Example 15 with JvmGcBo

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

the class JvmGcSamplerTest method gcCalculation_jvmRestarts_uncollectedValues_noPrevious.

@Test
public void gcCalculation_jvmRestarts_uncollectedValues_noPrevious() {
    // Given
    long firstAgentStartTimestamp = 10L;
    long secondAgentStartTimestamp = 1000L;
    JvmGcBo uncollectedJvmGcBo1_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    long firstGcCount_1 = randomGcCount();
    long firstGcTime_1 = randomGcTime();
    JvmGcBo firstJvmGcBo_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, firstGcCount_1, firstGcTime_1);
    JvmGcBo uncollectedJvmGcBo2_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    long firstGcCount_2 = randomGcCount();
    long firstGcTime_2 = randomGcTime();
    JvmGcBo firstJvmGcBo_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, firstGcCount_2, firstGcTime_2);
    JvmGcBo uncollectedJvmGcBo1_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    long secondGcCount_2 = randomGcCount() + firstGcCount_2;
    long secondGcTime_2 = randomGcTime() + firstGcTime_2;
    JvmGcBo secondJvmGcBo_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, secondGcCount_2, secondGcTime_2);
    long thirdGcCount_2 = randomGcCount() + secondGcCount_2;
    long thirdGcTime_2 = randomGcCount() + secondGcTime_2;
    JvmGcBo thirdJvmGcBo_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, thirdGcCount_2, thirdGcTime_2);
    JvmGcBo uncollectedJvmGcBo2_2 = createJvmGcBoForGcTest(secondAgentStartTimestamp, JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    // must be in descending order
    List<JvmGcBo> jvmGcBos = Arrays.asList(uncollectedJvmGcBo2_2, thirdJvmGcBo_2, secondJvmGcBo_2, uncollectedJvmGcBo1_2, firstJvmGcBo_2, uncollectedJvmGcBo2_1, firstJvmGcBo_1, uncollectedJvmGcBo1_1);
    // When
    SampledJvmGc sampledJvmGc = sampler.sampleDataPoints(0, System.currentTimeMillis(), jvmGcBos, null);
    // Then
    long gcCountsBeforeJvmRestart = 0L;
    long gcCountsAfterJvmRestart = thirdGcCount_2;
    long gcTimesBeforeJvmRestart = 0L;
    long gcTimesAfterJvmRestart = thirdGcTime_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)

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