Search in sources :

Example 6 with JvmGcBo

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

the class JvmGcSamplerTest method gcCalculation_uncollectedValues.

@Test
public void gcCalculation_uncollectedValues() {
    // Given
    long previousGcCount = randomGcCount();
    long previousGcTime = randomGcTime();
    JvmGcBo previousJvmGcBo = createJvmGcBoForGcTest(previousGcCount, previousGcTime);
    JvmGcBo uncollectedJvmGcBo1 = createJvmGcBoForGcTest(JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    long firstGcCount = randomGcCount() + previousGcCount;
    long firstGcTime = randomGcTime() + previousGcTime;
    JvmGcBo firstJvmGcBo = createJvmGcBoForGcTest(firstGcCount, firstGcTime);
    JvmGcBo uncollectedJvmGcBo2 = createJvmGcBoForGcTest(JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    JvmGcBo uncollectedJvmGcBo3 = createJvmGcBoForGcTest(JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    long secondGcCount = randomGcCount() + firstGcCount;
    long secondGcTime = randomGcTime() + firstGcTime;
    JvmGcBo secondJvmGcBo = createJvmGcBoForGcTest(secondGcCount, secondGcTime);
    // must be in descending order
    List<JvmGcBo> jvmGcBos = Arrays.asList(secondJvmGcBo, uncollectedJvmGcBo3, uncollectedJvmGcBo2, firstJvmGcBo, uncollectedJvmGcBo1);
    // When
    SampledJvmGc sampledJvmGc = sampler.sampleDataPoints(0, System.currentTimeMillis(), jvmGcBos, previousJvmGcBo);
    // Then
    long expectedGcCount = secondGcCount - previousGcCount;
    long expectedGcTime = secondGcTime - previousGcTime;
    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 7 with JvmGcBo

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

the class JvmGcSamplerTest method gcCalculation_singleDataPoint.

@Test
public void gcCalculation_singleDataPoint() {
    // Given
    long previousGcCount = randomGcCount();
    long previousGcTime = randomGcTime();
    JvmGcBo previousJvmGcBo = createJvmGcBoForGcTest(previousGcCount, previousGcTime);
    long gcCount = randomGcCount() + previousGcCount;
    long gcTime = randomGcTime() + previousGcTime;
    JvmGcBo jvmGcBo = createJvmGcBoForGcTest(gcCount, gcTime);
    List<JvmGcBo> jvmGcBos = Arrays.asList(jvmGcBo);
    // When
    SampledJvmGc sampledJvmGc = sampler.sampleDataPoints(0, System.currentTimeMillis(), jvmGcBos, previousJvmGcBo);
    // Then
    long expectedGcCount = gcCount - previousGcCount;
    long expectedGcTime = gcTime - previousGcTime;
    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 8 with JvmGcBo

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

the class JvmGcSamplerTest method gcCalculation_jvmRestarts.

@Test
public void gcCalculation_jvmRestarts() {
    // Given
    long firstAgentStartTimestamp = 10L;
    long secondAgentStartTimestamp = 1000L;
    long previousGcCount = randomGcCount();
    long previousGcTime = randomGcTime();
    JvmGcBo previousJvmGcBo = createJvmGcBoForGcTest(firstAgentStartTimestamp, previousGcCount, previousGcTime);
    long firstGcCount_1 = randomGcCount() + previousGcCount;
    long firstGcTime_1 = randomGcTime() + previousGcTime;
    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, previousJvmGcBo);
    // Then
    long gcCountsBeforeJvmRestart = secondGcCount_1 - previousGcCount;
    long gcCountsAfterJvmRestart = secondGcCount_2;
    long gcTimesBeforeJvmRestart = secondGcTime_1 - previousGcTime;
    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 9 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 10 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)

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