@Override protected void configureModule() { add( CeConfigurationImpl.class, CeTaskLogging.class, CeDatabaseMBeanImpl.class, new JvmStateSection("Compute Engine JVM State"), new JvmPropertiesSection("Compute Engine JVM Properties"), LoggingSection.class); } }
@Override public ProtobufSystemInfo.Section toProtobuf() { return toProtobuf(ManagementFactory.getMemoryMXBean()); }
ProtobufSystemInfo.Section toProtobuf(MemoryMXBean memoryBean) { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); protobuf.setName(name); addAttributeInMb(protobuf,"Max Memory (MB)", Runtime.getRuntime().maxMemory()); addAttributeInMb(protobuf, "Free Memory (MB)", Runtime.getRuntime().freeMemory()); MemoryUsage heap = memoryBean.getHeapMemoryUsage(); addAttributeInMb(protobuf, "Heap Committed (MB)", heap.getCommitted()); addAttributeInMb(protobuf, "Heap Init (MB)", heap.getInit()); addAttributeInMb(protobuf, "Heap Max (MB)", heap.getMax()); addAttributeInMb(protobuf, "Heap Used (MB)", heap.getUsed()); MemoryUsage nonHeap = memoryBean.getNonHeapMemoryUsage(); addAttributeInMb(protobuf, "Non Heap Committed (MB)", nonHeap.getCommitted()); addAttributeInMb(protobuf, "Non Heap Init (MB)", nonHeap.getInit()); addAttributeInMb(protobuf, "Non Heap Max (MB)", nonHeap.getMax()); addAttributeInMb(protobuf, "Non Heap Used (MB)", nonHeap.getUsed()); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); setAttribute(protobuf,"System Load Average", format(Locale.ENGLISH, "%.1f%% (last minute)", os.getSystemLoadAverage() * 100.0)); ThreadMXBean thread = ManagementFactory.getThreadMXBean(); setAttribute(protobuf, "Threads", thread.getThreadCount()); return protobuf.build(); }
@Test public void should_hide_attributes_without_values() { MemoryMXBean memoryBean = mock(MemoryMXBean.class, Mockito.RETURNS_DEEP_STUBS); when(memoryBean.getHeapMemoryUsage().getCommitted()).thenReturn(-1L); JvmStateSection underTest = new JvmStateSection(PROCESS_NAME); ProtobufSystemInfo.Section section = underTest.toProtobuf(memoryBean); assertThat(section.getAttributesList()).extracting("key").doesNotContain("Heap Committed (MB)"); } }
@Test public void toSystemInfoSection() { JvmStateSection underTest = new JvmStateSection(PROCESS_NAME); ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo(PROCESS_NAME); assertThat(section.getAttributesCount()).isGreaterThan(0); assertThat(section.getAttributesList()).extracting("key") .contains( "Max Memory (MB)", "Free Memory (MB)", "Heap Max (MB)", "System Load Average", "Threads"); }
new JvmStateSection("Web JVM State"), DbSection.class, DbConnectionSection.class,
public static Object[] forStandaloneMode() { return new Object[] { new JvmPropertiesSection("Web JVM Properties"), new JvmStateSection("Web JVM State"), DbSection.class, DbConnectionSection.class, EsStateSection.class, EsIndexesSection.class, LoggingSection.class, PluginsSection.class, SettingsSection.class, StandaloneSystemSection.class, OfficialDistribution.class, StandaloneSystemInfoWriter.class, InfoAction.class }; }
public static Object[] forClusterMode() { return new Object[] { new JvmPropertiesSection("Web JVM Properties"), new JvmStateSection("Web JVM State"), CeQueueGlobalSection.class, DbSection.class, DbConnectionSection.class, EsIndexesSection.class, EsClusterStateSection.class, GlobalSystemSection.class, LoggingSection.class, NodeSystemSection.class, PluginsSection.class, SettingsSection.class, OfficialDistribution.class, ProcessInfoProvider.class, GlobalInfoLoader.class, AppNodesInfoLoaderImpl.class, SearchNodesInfoLoaderImpl.class, ClusterSystemInfoWriter.class, InfoAction.class }; } }
@Override protected void configureModule() { add( CeConfigurationImpl.class, CeLogging.class, CeDatabaseMBeanImpl.class, new JvmStateSection("Compute Engine JVM State"), new JvmPropertiesSection("Compute Engine JVM Properties"), LoggingSection.class); } }