Search in sources :

Example 6 with CpuLoadBo

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

use of com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo 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 8 with CpuLoadBo

use of com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo 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 9 with CpuLoadBo

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

the class CpuLoadBoMapper method map.

@Override
public CpuLoadBo map(TCpuLoad tCpuLoad) {
    CpuLoadBo cpuLoadBo = new CpuLoadBo();
    cpuLoadBo.setJvmCpuLoad(tCpuLoad.getJvmCpuLoad());
    cpuLoadBo.setSystemCpuLoad(tCpuLoad.getSystemCpuLoad());
    return cpuLoadBo;
}
Also used : CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)

Example 10 with CpuLoadBo

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

the class CpuLoadCodecV2 method decodeValues.

@Override
public List<CpuLoadBo> 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;
    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> jvmCpuLoadEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    EncodingStrategy<Long> systemCpuLoadEncodingStrategy = UnsignedLongEncodingStrategy.getFromCode(headerDecoder.getCode());
    // decode values
    List<Long> jvmCpuLoads = this.codec.decodeValues(valueBuffer, jvmCpuLoadEncodingStrategy, numValues);
    List<Long> systemCpuLoads = this.codec.decodeValues(valueBuffer, systemCpuLoadEncodingStrategy, numValues);
    List<CpuLoadBo> cpuLoadBos = new ArrayList<CpuLoadBo>(numValues);
    for (int i = 0; i < numValues; ++i) {
        CpuLoadBo cpuLoadBo = new CpuLoadBo();
        cpuLoadBo.setAgentId(agentId);
        cpuLoadBo.setStartTimestamp(startTimestamps.get(i));
        cpuLoadBo.setTimestamp(timestamps.get(i));
        cpuLoadBo.setJvmCpuLoad(AgentStatUtils.convertLongToDouble(jvmCpuLoads.get(i)));
        cpuLoadBo.setSystemCpuLoad(AgentStatUtils.convertLongToDouble(systemCpuLoads.get(i)));
        cpuLoadBos.add(cpuLoadBo);
    }
    return cpuLoadBos;
}
Also used : AgentStatHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.AgentStatHeaderDecoder) CpuLoadBo(com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo) BitCountingHeaderDecoder(com.navercorp.pinpoint.common.server.bo.codec.stat.header.BitCountingHeaderDecoder) ArrayList(java.util.ArrayList)

Aggregations

CpuLoadBo (com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo)15 ArrayList (java.util.ArrayList)7 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)6 Range (com.navercorp.pinpoint.web.vo.Range)6 ApplicationIndexDao (com.navercorp.pinpoint.web.dao.ApplicationIndexDao)3 SampledCpuLoad (com.navercorp.pinpoint.web.vo.stat.SampledCpuLoad)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 TransactionBo (com.navercorp.pinpoint.common.server.bo.stat.TransactionBo)2 TDataSource (com.navercorp.pinpoint.thrift.dto.TDataSource)2