Search in sources :

Example 6 with SampledJvmGc

use of com.navercorp.pinpoint.web.vo.stat.SampledJvmGc 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 7 with SampledJvmGc

use of com.navercorp.pinpoint.web.vo.stat.SampledJvmGc 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 8 with SampledJvmGc

use of com.navercorp.pinpoint.web.vo.stat.SampledJvmGc in project pinpoint by naver.

the class LegacyAgentStatChartCompatibilityService method selectAgentStatList.

@Override
public LegacyAgentStatChartGroup selectAgentStatList(String agentId, TimeWindow timeWindow) {
    if (agentId == null) {
        throw new NullPointerException("agentId must not be null");
    }
    if (timeWindow == null) {
        throw new NullPointerException("timeWindow must not be null");
    }
    List<SampledJvmGc> jvmGcs = sampledJvmGcDao.getSampledAgentStatList(agentId, timeWindow);
    if (CollectionUtils.isNotEmpty(jvmGcs)) {
        List<SampledCpuLoad> cpuLoads = sampledCpuLoadDao.getSampledAgentStatList(agentId, timeWindow);
        List<SampledTransaction> transactions = sampledTransactionDao.getSampledAgentStatList(agentId, timeWindow);
        List<SampledActiveTrace> activeTraces = sampledActiveTraceDao.getSampledAgentStatList(agentId, timeWindow);
        LegacyAgentStatChartGroup.LegacyAgentStatChartGroupBuilder builder = new LegacyAgentStatChartGroup.LegacyAgentStatChartGroupBuilder(timeWindow);
        builder.jvmGcs(jvmGcs);
        builder.cpuLoads(cpuLoads);
        builder.transactions(transactions);
        builder.activeTraces(activeTraces);
        return builder.build();
    } else {
        long scanFrom = timeWindow.getWindowRange().getFrom();
        long scanTo = timeWindow.getWindowRange().getTo() + timeWindow.getWindowSlotSize();
        Range rangeToScan = new Range(scanFrom, scanTo);
        List<AgentStat> agentStats = legacyAgentStatDao.getAgentStatList(agentId, rangeToScan);
        LegacyAgentStatChartGroup chartGroup = new LegacyAgentStatChartGroup(timeWindow);
        chartGroup.addAgentStats(agentStats);
        chartGroup.buildCharts();
        return chartGroup;
    }
}
Also used : LegacyAgentStatChartGroup(com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup) SampledActiveTrace(com.navercorp.pinpoint.web.vo.stat.SampledActiveTrace) Range(com.navercorp.pinpoint.web.vo.Range) SampledCpuLoad(com.navercorp.pinpoint.web.vo.stat.SampledCpuLoad) SampledTransaction(com.navercorp.pinpoint.web.vo.stat.SampledTransaction) AgentStat(com.navercorp.pinpoint.web.vo.AgentStat) SampledJvmGc(com.navercorp.pinpoint.web.vo.stat.SampledJvmGc)

Example 9 with SampledJvmGc

use of com.navercorp.pinpoint.web.vo.stat.SampledJvmGc 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)

Example 10 with SampledJvmGc

use of com.navercorp.pinpoint.web.vo.stat.SampledJvmGc in project pinpoint by naver.

the class JvmGcSamplerTest method gcCalculation_jvmRestarts_uncollectedValues_previousUncollectedValue.

@Test
public void gcCalculation_jvmRestarts_uncollectedValues_previousUncollectedValue() {
    // Given
    long firstAgentStartTimestamp = 10L;
    long secondAgentStartTimestamp = 1000L;
    JvmGcBo previousJvmGcBo = createJvmGcBoForGcTest(firstAgentStartTimestamp, JvmGcBo.UNCOLLECTED_VALUE, JvmGcBo.UNCOLLECTED_VALUE);
    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);
    long secondGcCount_1 = randomGcCount() + firstGcCount_1;
    long secondGcTime_1 = randomGcTime() + firstGcTime_1;
    JvmGcBo secondJvmGcBo_1 = createJvmGcBoForGcTest(firstAgentStartTimestamp, secondGcCount_1, secondGcTime_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, secondJvmGcBo_1, firstJvmGcBo_1, uncollectedJvmGcBo1_1);
    // When
    SampledJvmGc sampledJvmGc = sampler.sampleDataPoints(0, System.currentTimeMillis(), jvmGcBos, previousJvmGcBo);
    // Then
    long gcCountsBeforeJvmRestart = secondGcCount_1 - firstGcCount_1;
    long gcCountsAfterJvmRestart = thirdGcCount_2;
    long gcTimesBeforeJvmRestart = secondGcTime_1 - firstGcTime_1;
    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

SampledJvmGc (com.navercorp.pinpoint.web.vo.stat.SampledJvmGc)16 JvmGcBo (com.navercorp.pinpoint.common.server.bo.stat.JvmGcBo)15 Test (org.junit.Test)12 Range (com.navercorp.pinpoint.web.vo.Range)3 SampledAgentStatResultExtractor (com.navercorp.pinpoint.web.mapper.stat.SampledAgentStatResultExtractor)2 JvmGcType (com.navercorp.pinpoint.common.server.bo.JvmGcType)1 AgentStat (com.navercorp.pinpoint.web.vo.AgentStat)1 Point (com.navercorp.pinpoint.web.vo.chart.Point)1 UncollectedPoint (com.navercorp.pinpoint.web.vo.chart.UncollectedPoint)1 SampledActiveTrace (com.navercorp.pinpoint.web.vo.stat.SampledActiveTrace)1 SampledCpuLoad (com.navercorp.pinpoint.web.vo.stat.SampledCpuLoad)1 SampledTransaction (com.navercorp.pinpoint.web.vo.stat.SampledTransaction)1 LegacyAgentStatChartGroup (com.navercorp.pinpoint.web.vo.stat.chart.LegacyAgentStatChartGroup)1 ArrayList (java.util.ArrayList)1