Search in sources :

Example 1 with JvmGcBo

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

the class TestAgentStatFactory method createJvmGcBos.

public static List<JvmGcBo> createJvmGcBos(String agentId, long startTimestamp, long initialTimestamp, int numValues) {
    List<JvmGcBo> jvmGcBos = new ArrayList<JvmGcBo>(numValues);
    List<Long> startTimestamps = createStartTimestamps(startTimestamp, numValues);
    List<Long> timestamps = createTimestamps(initialTimestamp, numValues);
    List<Long> heapUseds = TestAgentStatDataPointFactory.LONG.createFluctuatingValues(256 * 1024 * 1024L, 512 * 1024 * 1024L, 10 * 1024 * 1024L, 30 * 1024 * 1024L, numValues);
    List<Long> heapMaxes = TestAgentStatDataPointFactory.LONG.createConstantValues(2 * 1024 * 1024 * 1024L, 2 * 1024 * 1024 * 1024L, numValues);
    List<Long> nonHeapUseds = TestAgentStatDataPointFactory.LONG.createIncreasingValues(16 * 1024 * 1024L, 64 * 1024 * 1024L, 1 * 1024 * 1024L, 3 * 1024 * 1024L, numValues);
    List<Long> nonHeapMaxes = TestAgentStatDataPointFactory.LONG.createConstantValues(128 * 1024 * 1024L, 128 * 1024 * 1024L, numValues);
    List<Long> gcOldCounts = TestAgentStatDataPointFactory.LONG.createIncreasingValues(0L, 1000L, 0L, 10L, numValues);
    List<Long> gcOldTimes = TestAgentStatDataPointFactory.LONG.createIncreasingValues(0L, 100000000L, 100L, 5000L, numValues);
    for (int i = 0; i < numValues; ++i) {
        JvmGcBo jvmGcBo = new JvmGcBo();
        jvmGcBo.setAgentId(agentId);
        jvmGcBo.setStartTimestamp(startTimestamps.get(i));
        jvmGcBo.setGcType(JvmGcType.CMS);
        jvmGcBo.setTimestamp(timestamps.get(i));
        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) ArrayList(java.util.ArrayList)

Example 2 with JvmGcBo

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

the class HbaseSampledJvmGcDao method getSampledAgentStatList.

@Override
public List<SampledJvmGc> getSampledAgentStatList(String agentId, TimeWindow timeWindow) {
    long scanFrom = timeWindow.getWindowRange().getFrom();
    long scanTo = timeWindow.getWindowRange().getTo() + timeWindow.getWindowSlotSize();
    Range range = new Range(scanFrom, scanTo);
    SampledAgentStatResultExtractor<JvmGcBo, SampledJvmGc> resultExtractor = new SampledAgentStatResultExtractor<>(timeWindow, mapper, sampler);
    return operations.getSampledAgentStatList(resultExtractor, agentId, range);
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) SampledAgentStatResultExtractor(com.navercorp.pinpoint.web.mapper.stat.SampledAgentStatResultExtractor) SampledJvmGc(com.navercorp.pinpoint.web.vo.stat.SampledJvmGc) Range(com.navercorp.pinpoint.web.vo.Range)

Example 3 with JvmGcBo

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

the class AgentStatDataCollector method collect.

@Override
public void collect() {
    if (init.get()) {
        return;
    }
    Range range = Range.createUncheckedRange(timeSlotEndTime - slotInterval, timeSlotEndTime);
    List<String> agentIds = applicationIndexDao.selectAgentIds(application.getName());
    for (String agentId : agentIds) {
        List<JvmGcBo> jvmGcBos = jvmGcDao.getAgentStatList(agentId, range);
        List<CpuLoadBo> cpuLoadBos = cpuLoadDao.getAgentStatList(agentId, range);
        long totalHeapSize = 0;
        long usedHeapSize = 0;
        long jvmCpuUsaged = 0;
        for (JvmGcBo jvmGcBo : jvmGcBos) {
            totalHeapSize += jvmGcBo.getHeapMax();
            usedHeapSize += jvmGcBo.getHeapUsed();
        }
        for (CpuLoadBo cpuLoadBo : cpuLoadBos) {
            jvmCpuUsaged += cpuLoadBo.getJvmCpuLoad() * 100;
        }
        if (!jvmGcBos.isEmpty()) {
            long percent = calculatePercent(usedHeapSize, totalHeapSize);
            agentHeapUsageRate.put(agentId, percent);
            long accruedLastGcCount = jvmGcBos.get(0).getGcOldCount();
            long accruedFirstGcCount = jvmGcBos.get(jvmGcBos.size() - 1).getGcOldCount();
            agentGcCount.put(agentId, accruedLastGcCount - accruedFirstGcCount);
        }
        if (!cpuLoadBos.isEmpty()) {
            long percent = calculatePercent(jvmCpuUsaged, 100 * cpuLoadBos.size());
            agentJvmCpuUsageRate.put(agentId, percent);
        }
    }
    init.set(true);
}
Also used : JvmGcBo(com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) Range(com.navercorp.pinpoint.web.vo.Range)

Example 4 with JvmGcBo

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

the class HeapUsageRateCheckerTest 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 = 0; i < 36; i++) {
                JvmGcBo jvmGcBo = new JvmGcBo();
                jvmGcBo.setHeapUsed(70L);
                jvmGcBo.setHeapMax(100L);
                jvmGcs.add(jvmGcBo);
            }
            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 5 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)

Aggregations

JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)39 SampledJvmGc (com.navercorp.pinpoint.web.vo.stat.SampledJvmGc)15 Test (org.junit.Test)13 CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)10 Range (com.navercorp.pinpoint.web.vo.Range)10 ArrayList (java.util.ArrayList)7 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)6 LinkedList (java.util.LinkedList)6 List (java.util.List)6 BeforeClass (org.junit.BeforeClass)6 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)4 JvmGcType (com.navercorp.pinpoint.common.server.bo.JvmGcType)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 JvmGcCodecV2 (com.navercorp.pinpoint.common.server.bo.codec.stat.v2.JvmGcCodecV2)2 ActiveTraceBo (com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo)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 TransactionBo (com.navercorp.pinpoint.common.server.bo.stat.TransactionBo)2