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;
}
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);
}
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);
}
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();
}
};
}
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;
}
Aggregations