@Test public void testRunOneIteration() throws Exception { Config config = ConfigFactory.empty(); ContainerHealthMetricsService service = new ContainerHealthMetricsService(config); service.runOneIteration(); Assert.assertTrue(service.getCurrentGcStats() == service.getLastGcStats()); ContainerHealthMetricsService.GcStats previousLastGcStats = service.getLastGcStats(); Assert.assertTrue( service.minorGcCount.get() >= 0); Assert.assertTrue( service.minorGcDuration.get() >= 0); Assert.assertTrue( service.majorGcCount.get() >= 0); Assert.assertTrue( service.minorGcDuration.get() >= 0); Assert.assertTrue( service.unknownGcCount.get() >= 0); Assert.assertTrue( service.unknownGcDuration.get() >= 0); double processCpuTime1 = service.processCpuTime.get(); Thread.sleep(10); service.runOneIteration(); Assert.assertTrue(service.getCurrentGcStats() == service.getLastGcStats()); Assert.assertTrue(service.getLastGcStats() != previousLastGcStats); double processCpuTime2 = service.processCpuTime.get(); Assert.assertTrue( processCpuTime1 <= processCpuTime2); Assert.assertTrue( service.minorGcCount.get() >= 0); Assert.assertTrue( service.minorGcDuration.get() >= 0); Assert.assertTrue( service.majorGcCount.get() >= 0); Assert.assertTrue( service.minorGcDuration.get() >= 0); Assert.assertTrue( service.unknownGcCount.get() >= 0); Assert.assertTrue( service.unknownGcDuration.get() >= 0); }
@Override protected void runOneIteration() throws Exception { this.processCpuLoad.set(this.operatingSystemMXBean.getProcessCpuLoad()); this.systemCpuLoad.set(this.operatingSystemMXBean.getSystemCpuLoad()); this.systemLoadAvg.set(this.operatingSystemMXBean.getSystemLoadAverage()); this.committedVmemSize.set(this.operatingSystemMXBean.getCommittedVirtualMemorySize()); this.processCpuTime.set(this.operatingSystemMXBean.getProcessCpuTime()); this.freeSwapSpaceSize.set(this.operatingSystemMXBean.getFreeSwapSpaceSize()); this.numAvailableProcessors.set(this.operatingSystemMXBean.getAvailableProcessors()); this.totalPhysicalMemSize.set(this.operatingSystemMXBean.getTotalPhysicalMemorySize()); this.totalSwapSpaceSize.set(this.operatingSystemMXBean.getTotalSwapSpaceSize()); this.freePhysicalMemSize.set(this.operatingSystemMXBean.getFreePhysicalMemorySize()); this.processHeapUsedSize.set(this.memoryMXBean.getHeapMemoryUsage().getUsed()); this.currentGcStats = collectGcStats(); this.minorGcCount.set(this.currentGcStats.getMinorCount() - this.lastGcStats.getMinorCount()); this.minorGcDuration.set(this.currentGcStats.getMinorDuration() - this.lastGcStats.getMinorDuration()); this.majorGcCount.set(this.currentGcStats.getMajorCount() - this.lastGcStats.getMajorCount()); this.majorGcDuration.set(this.currentGcStats.getMajorDuration() - this.lastGcStats.getMajorDuration()); this.unknownGcCount.set(this.currentGcStats.getUnknownCount() - this.lastGcStats.getUnknownCount()); this.unknownGcDuration.set(this.currentGcStats.getUnknownDuration() - this.lastGcStats.getUnknownDuration()); this.lastGcStats = this.currentGcStats; }
ContainerHealthMetricsService extends AbstractScheduledService { @Override protected void runOneIteration() throws Exception { this.processCpuLoad.set(this.operatingSystemMXBean.getProcessCpuLoad()); this.systemCpuLoad.set(this.operatingSystemMXBean.getSystemCpuLoad()); this.systemLoadAvg.set(this.operatingSystemMXBean.getSystemLoadAverage()); this.committedVmemSize.set(this.operatingSystemMXBean.getCommittedVirtualMemorySize()); this.processCpuTime.set(this.operatingSystemMXBean.getProcessCpuTime()); this.freeSwapSpaceSize.set(this.operatingSystemMXBean.getFreeSwapSpaceSize()); this.numAvailableProcessors.set(this.operatingSystemMXBean.getAvailableProcessors()); this.totalPhysicalMemSize.set(this.operatingSystemMXBean.getTotalPhysicalMemorySize()); this.totalSwapSpaceSize.set(this.operatingSystemMXBean.getTotalSwapSpaceSize()); this.freePhysicalMemSize.set(this.operatingSystemMXBean.getFreePhysicalMemorySize()); this.processHeapUsedSize.set(this.memoryMXBean.getHeapMemoryUsage().getUsed()); this.currentGcStats = collectGcStats(); this.minorGcCount.set(this.currentGcStats.getMinorCount() - this.lastGcStats.getMinorCount()); this.minorGcDuration.set(this.currentGcStats.getMinorDuration() - this.lastGcStats.getMinorDuration()); this.majorGcCount.set(this.currentGcStats.getMajorCount() - this.lastGcStats.getMajorCount()); this.majorGcDuration.set(this.currentGcStats.getMajorDuration() - this.lastGcStats.getMajorDuration()); this.unknownGcCount.set(this.currentGcStats.getUnknownCount() - this.lastGcStats.getUnknownCount()); this.unknownGcDuration.set(this.currentGcStats.getUnknownDuration() - this.lastGcStats.getUnknownDuration()); this.lastGcStats = this.currentGcStats; } }
ContainerHealthMetricsService extends AbstractScheduledService { @Override protected void runOneIteration() throws Exception { this.processCpuLoad.set(this.operatingSystemMXBean.getProcessCpuLoad()); this.systemCpuLoad.set(this.operatingSystemMXBean.getSystemCpuLoad()); this.systemLoadAvg.set(this.operatingSystemMXBean.getSystemLoadAverage()); this.committedVmemSize.set(this.operatingSystemMXBean.getCommittedVirtualMemorySize()); this.processCpuTime.set(this.operatingSystemMXBean.getProcessCpuTime()); this.freeSwapSpaceSize.set(this.operatingSystemMXBean.getFreeSwapSpaceSize()); this.numAvailableProcessors.set(this.operatingSystemMXBean.getAvailableProcessors()); this.totalPhysicalMemSize.set(this.operatingSystemMXBean.getTotalPhysicalMemorySize()); this.totalSwapSpaceSize.set(this.operatingSystemMXBean.getTotalSwapSpaceSize()); this.freePhysicalMemSize.set(this.operatingSystemMXBean.getFreePhysicalMemorySize()); this.processHeapUsedSize.set(this.memoryMXBean.getHeapMemoryUsage().getUsed()); this.currentGcStats = collectGcStats(); this.minorGcCount.set(this.currentGcStats.getMinorCount() - this.lastGcStats.getMinorCount()); this.minorGcDuration.set(this.currentGcStats.getMinorDuration() - this.lastGcStats.getMinorDuration()); this.majorGcCount.set(this.currentGcStats.getMajorCount() - this.lastGcStats.getMajorCount()); this.majorGcDuration.set(this.currentGcStats.getMajorDuration() - this.lastGcStats.getMajorDuration()); this.unknownGcCount.set(this.currentGcStats.getUnknownCount() - this.lastGcStats.getUnknownCount()); this.unknownGcDuration.set(this.currentGcStats.getUnknownDuration() - this.lastGcStats.getUnknownDuration()); this.lastGcStats = this.currentGcStats; } ContainerHealthMetricsService(Config config); }
ContainerHealthMetricsService extends AbstractScheduledService { @Override protected void runOneIteration() throws Exception { this.processCpuLoad.set(this.operatingSystemMXBean.getProcessCpuLoad()); this.systemCpuLoad.set(this.operatingSystemMXBean.getSystemCpuLoad()); this.systemLoadAvg.set(this.operatingSystemMXBean.getSystemLoadAverage()); this.committedVmemSize.set(this.operatingSystemMXBean.getCommittedVirtualMemorySize()); this.processCpuTime.set(this.operatingSystemMXBean.getProcessCpuTime()); this.freeSwapSpaceSize.set(this.operatingSystemMXBean.getFreeSwapSpaceSize()); this.numAvailableProcessors.set(this.operatingSystemMXBean.getAvailableProcessors()); this.totalPhysicalMemSize.set(this.operatingSystemMXBean.getTotalPhysicalMemorySize()); this.totalSwapSpaceSize.set(this.operatingSystemMXBean.getTotalSwapSpaceSize()); this.freePhysicalMemSize.set(this.operatingSystemMXBean.getFreePhysicalMemorySize()); this.processHeapUsedSize.set(this.memoryMXBean.getHeapMemoryUsage().getUsed()); this.currentGcStats = collectGcStats(); this.minorGcCount.set(this.currentGcStats.getMinorCount() - this.lastGcStats.getMinorCount()); this.minorGcDuration.set(this.currentGcStats.getMinorDuration() - this.lastGcStats.getMinorDuration()); this.majorGcCount.set(this.currentGcStats.getMajorCount() - this.lastGcStats.getMajorCount()); this.majorGcDuration.set(this.currentGcStats.getMajorDuration() - this.lastGcStats.getMajorDuration()); this.unknownGcCount.set(this.currentGcStats.getUnknownCount() - this.lastGcStats.getUnknownCount()); this.unknownGcDuration.set(this.currentGcStats.getUnknownDuration() - this.lastGcStats.getUnknownDuration()); this.lastGcStats = this.currentGcStats; } ContainerHealthMetricsService(Config config);  }
ContainerHealthMetricsService extends AbstractScheduledService { @Override protected void runOneIteration() throws Exception { this.processCpuLoad.set(this.operatingSystemMXBean.getProcessCpuLoad()); this.systemCpuLoad.set(this.operatingSystemMXBean.getSystemCpuLoad()); this.systemLoadAvg.set(this.operatingSystemMXBean.getSystemLoadAverage()); this.committedVmemSize.set(this.operatingSystemMXBean.getCommittedVirtualMemorySize()); this.processCpuTime.set(this.operatingSystemMXBean.getProcessCpuTime()); this.freeSwapSpaceSize.set(this.operatingSystemMXBean.getFreeSwapSpaceSize()); this.numAvailableProcessors.set(this.operatingSystemMXBean.getAvailableProcessors()); this.totalPhysicalMemSize.set(this.operatingSystemMXBean.getTotalPhysicalMemorySize()); this.totalSwapSpaceSize.set(this.operatingSystemMXBean.getTotalSwapSpaceSize()); this.freePhysicalMemSize.set(this.operatingSystemMXBean.getFreePhysicalMemorySize()); this.processHeapUsedSize.set(this.memoryMXBean.getHeapMemoryUsage().getUsed()); this.currentGcStats = collectGcStats(); this.minorGcCount.set(this.currentGcStats.getMinorCount() - this.lastGcStats.getMinorCount()); this.minorGcDuration.set(this.currentGcStats.getMinorDuration() - this.lastGcStats.getMinorDuration()); this.majorGcCount.set(this.currentGcStats.getMajorCount() - this.lastGcStats.getMajorCount()); this.majorGcDuration.set(this.currentGcStats.getMajorDuration() - this.lastGcStats.getMajorDuration()); this.unknownGcCount.set(this.currentGcStats.getUnknownCount() - this.lastGcStats.getUnknownCount()); this.unknownGcDuration.set(this.currentGcStats.getUnknownDuration() - this.lastGcStats.getUnknownDuration()); this.lastGcStats = this.currentGcStats; } ContainerHealthMetricsService(Config config);   }