/** * Gets the {@link RuntimeInfoProvider}. The getter method is provided for better testability. * * @return {@link RuntimeInfoProvider}. */ private RuntimeInfoProvider getRuntimeBean() { if (this.runtimeBean == null) { this.runtimeBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getRuntimeInfoProvider(); } return this.runtimeBean; } }
/** * Gets the {@link OperatingSystemInfoProvider}. The getter method is provided for better * testability. * * @return {@link OperatingSystemInfoProvider}. */ private OperatingSystemInfoProvider getOsBean() { if (this.osBean == null) { this.osBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getOperatingSystemInfoProvider(); } return this.osBean; }
/** * Gets the {@link MemoryInfoProvider}. The getter method is provided for better testability. * * @return {@link MemoryInfoProvider}. */ private MemoryInfoProvider getMemoryBean() { if (this.memoryBean == null) { this.memoryBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getMemoryInfoProvider(); } return this.memoryBean; } }
this.systemInformationData.setTimeStamp(timestamp); this.systemInformationData.setTotalPhysMemory(this.getOsBean().getTotalPhysicalMemorySize()); this.systemInformationData.setTotalSwapSpace(this.getOsBean().getTotalSwapSpaceSize()); this.systemInformationData.setAvailableProcessors(this.getOsBean().getAvailableProcessors()); this.systemInformationData.setArchitecture(this.getOsBean().getArch()); this.systemInformationData.setOsName(this.getOsBean().getName()); this.systemInformationData.setOsVersion(this.getOsBean().getVersion()); this.systemInformationData.setJitCompilerName(this.getRuntimeBean().getJitCompilerName()); this.systemInformationData.setClassPath(this.getRuntimeBean().getClassPath()); this.systemInformationData.setBootClassPath(this.getRuntimeBean().getBootClassPath()); this.systemInformationData.setLibraryPath(this.getRuntimeBean().getLibraryPath()); this.systemInformationData.setVmVendor(this.getRuntimeBean().getVmVendor()); this.systemInformationData.setVmVersion(this.getRuntimeBean().getVmVersion()); this.systemInformationData.setVmName(this.getRuntimeBean().getVmName()); this.systemInformationData.setVmSpecName(this.getRuntimeBean().getSpecName()); this.systemInformationData.setInitHeapMemorySize(this.getMemoryBean().getHeapMemoryUsage().getInit()); this.systemInformationData.setMaxHeapMemorySize(this.getMemoryBean().getHeapMemoryUsage().getMax()); this.systemInformationData.setInitNonHeapMemorySize(this.getMemoryBean().getNonHeapMemoryUsage().getInit()); this.systemInformationData.setMaxNonHeapMemorySize(this.getMemoryBean().getNonHeapMemoryUsage().getMax());
protected void mockCollectorWithDefaults() { MemoryUsage heapMemoryUsage = Mockito.mock(MemoryUsage.class); when(heapMemoryUsage.getUsed()).thenReturn(0L); when(heapMemoryUsage.getCommitted()).thenReturn(0L); MemoryUsage nonHeapMemoryUsage = Mockito.mock(MemoryUsage.class); when(nonHeapMemoryUsage.getUsed()).thenReturn(0L); when(nonHeapMemoryUsage.getCommitted()).thenReturn(0L); when(this.osBean.getFreePhysicalMemorySize()).thenReturn(0L); when(this.osBean.getFreeSwapSpaceSize()).thenReturn(0L); when(this.osBean.getCommittedVirtualMemorySize()).thenReturn(0L); when(this.memoryBean.getHeapMemoryUsage()).thenReturn(heapMemoryUsage); when(this.memoryBean.getNonHeapMemoryUsage()).thenReturn(nonHeapMemoryUsage); } }
int daemonThreadCount = this.getThreadBean().getDaemonThreadCount(); int peakThreadCount = this.getThreadBean().getPeakThreadCount(); int threadCount = this.getThreadBean().getThreadCount(); long totalStartedThreadCount = this.getThreadBean().getTotalStartedThreadCount();
int loadedClassCount = this.getRuntimeBean().getLoadedClassCount(); long totalLoadedClassCount = this.getRuntimeBean().getTotalLoadedClassCount(); long unloadedClassCount = this.getRuntimeBean().getUnloadedClassCount();
/** * {@inheritDoc} */ @Override public void gather() { // The timestamp is set in the {@link CpuInformation#reset()} to avoid multiple renewal. It // will not be set on the first execution of {@link CpuInformation#gather()}, but shortly // before. float cpuUsage = this.getOsBean().retrieveCpuUsage(); long cpuTime = this.getOsBean().getProcessCpuTime(); this.cpuInformationData.incrementCount(); this.cpuInformationData.updateProcessCpuTime(cpuTime); this.cpuInformationData.addCpuUsage(cpuUsage); if (cpuUsage < this.cpuInformationData.getMinCpuUsage()) { this.cpuInformationData.setMinCpuUsage(cpuUsage); } if (cpuUsage > this.cpuInformationData.getMaxCpuUsage()) { this.cpuInformationData.setMaxCpuUsage(cpuUsage); } }
/** * {@inheritDoc} */ @Override public void gather() { // The timestamp is set in the {@link CompilationInformation#reset()} to avoid multiple // renewal. It will not be set on the first execution of // {@link CompilationInformation#gather()}, but shortly before. long totalCompilationTime = this.getRuntimeBean().getTotalCompilationTime(); this.compilationInformationData.incrementCount(); this.compilationInformationData.addTotalCompilationTime(totalCompilationTime); if (totalCompilationTime < this.compilationInformationData.getMinTotalCompilationTime()) { this.compilationInformationData.setMinTotalCompilationTime(totalCompilationTime); } else if (totalCompilationTime > this.compilationInformationData.getMaxTotalCompilationTime()) { this.compilationInformationData.setMaxTotalCompilationTime(totalCompilationTime); } }
/** * Gets the {@link ThreadInfoProvider}. The getter method is provided for better testability. * * @return {@link ThreadInfoProvider}. */ private ThreadInfoProvider getThreadBean() { if (this.threadBean == null) { this.threadBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getThreadInfoProvider(); } return this.threadBean; } }
@Test void cpuUsageIsSetForMinAndMaxOnTheFirstRun() { when(this.osBean.retrieveCpuUsage()).thenReturn(10f); this.cut.gather(); CpuInformationData collector = (CpuInformationData) this.cut.get(); assertThat(collector.getMinCpuUsage(), is(10f)); assertThat(collector.getMaxCpuUsage(), is(10f)); assertThat(collector.getTotalCpuUsage(), is(10f)); }
/** * {@inheritDoc} */ @Override public void gather() { // The timestamp is set in the {@link RuntimeInformation#reset()} to avoid multiple renewal. // It will not be set on the first execution of {@link RuntimeInformation#gather()}, but // shortly before. long uptime = this.getRuntimeBean().getUptime(); this.runtimeInformationData.setUptime(uptime); }
long freePhysMemory = this.getOsBean().getFreePhysicalMemorySize(); long freeSwapSpace = this.getOsBean().getFreeSwapSpaceSize(); long comittedVirtualMemSize = this.getOsBean().getCommittedVirtualMemorySize(); long usedHeapMemorySize = this.getMemoryBean().getHeapMemoryUsage().getUsed(); long comittedHeapMemorySize = this.getMemoryBean().getHeapMemoryUsage().getCommitted(); long usedNonHeapMemorySize = this.getMemoryBean().getNonHeapMemoryUsage().getUsed(); long comittedNonHeapMemorySize = this.getMemoryBean().getNonHeapMemoryUsage().getCommitted();
/** * Gets the {@link RuntimeInfoProvider}. The getter method is provided for better testability. * * @return {@link RuntimeInfoProvider}. */ private RuntimeInfoProvider getRuntimeBean() { if (this.runtimeBean == null) { this.runtimeBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getRuntimeInfoProvider(); } return this.runtimeBean; } }
/** * Gets the {@link OperatingSystemInfoProvider}. The getter method is provided for better * testability. * * @return {@link OperatingSystemInfoProvider}. */ private OperatingSystemInfoProvider getOsBean() { if (this.osBean == null) { this.osBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getOperatingSystemInfoProvider(); } return this.osBean; }
/** * Gets the {@link MemoryInfoProvider}. The getter method is provided for better testability. * * @return {@link MemoryInfoProvider}. */ private MemoryInfoProvider getMemoryBean() { if (this.memoryBean == null) { this.memoryBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getMemoryInfoProvider(); } return this.memoryBean; }
@Test void totalCompilationTimeCalculated() { when(this.runtimeBean.getTotalCompilationTime()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); CompilationInformationData collector = (CompilationInformationData) this.cut.get(); assertThat(collector.getMinTotalCompilationTime(), is(9L)); assertThat(collector.getMaxTotalCompilationTime(), is(11L)); assertThat(collector.getTotalTotalCompilationTime(), is(40L)); }
/** * Gets the {@link RuntimeInfoProvider}. The getter method is provided for better testability. * * @return {@link RuntimeInfoProvider}. */ private RuntimeInfoProvider getRuntimeBean() { if (this.runtimeBean == null) { this.runtimeBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getRuntimeInfoProvider(); } return this.runtimeBean; } }
/** * Gets the {@link OperatingSystemInfoProvider}. The getter method is provided for better * testability. * * @return {@link OperatingSystemInfoProvider}. */ private OperatingSystemInfoProvider getOsBean() { if (this.osBean == null) { this.osBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getOperatingSystemInfoProvider(); } return this.osBean; } }
/** * Gets the {@link RuntimeInfoProvider}. The getter method is provided for better testability. * * @return {@link RuntimeInfoProvider}. */ private RuntimeInfoProvider getRuntimeBean() { if (this.runtimeBean == null) { this.runtimeBean = PlatformSensorInfoProviderFactory.getPlatformSensorInfoProvider().getRuntimeInfoProvider(); } return this.runtimeBean; } }