]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9845 Display type of disk in System Info on Linu
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 19 Sep 2017 19:49:28 +0000 (21:49 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 26 Sep 2017 21:49:38 +0000 (23:49 +0200)
server/sonar-process/src/main/java/org/sonar/process/systeminfo/SystemInfoUtils.java
server/sonar-process/src/test/java/org/sonar/process/systeminfo/SystemInfoUtilsTest.java
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/EsStateSection.java

index 0126bbe2ae7d170d1418ad79cd9ef3c629b866ee..58cb458bdeb2a6a3560f32697572666cbca3dfe0 100644 (file)
@@ -55,11 +55,13 @@ public class SystemInfoUtils {
     }
   }
 
-  public static void setAttribute(Section.Builder section, String key, boolean value) {
-    section.addAttributesBuilder()
-      .setKey(key)
-      .setBooleanValue(value)
-      .build();
+  public static void setAttribute(Section.Builder section, String key, @Nullable Boolean value) {
+    if (value != null) {
+      section.addAttributesBuilder()
+        .setKey(key)
+        .setBooleanValue(value)
+        .build();
+    }
   }
 
   public static void setAttribute(Section.Builder section, String key, long value) {
index 03410f34ea9e20040ac4b2c20f9c066158dfb0b3..f7e3c09ca727f45d60098475874136aa53cfd371 100644 (file)
@@ -30,6 +30,19 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 public class SystemInfoUtilsTest {
 
+  @Test
+  public void test_setAttribute_with_boolean_parameter() {
+    Section.Builder builder = Section.newBuilder();
+    SystemInfoUtils.setAttribute(builder, "isNull", (Boolean)null);
+    SystemInfoUtils.setAttribute(builder, "isTrue", true);
+    SystemInfoUtils.setAttribute(builder, "isFalse", false);
+
+    Section section = builder.build();
+    assertThat(SystemInfoUtils.attribute(section, "isNull")).isNull();
+    assertThat(SystemInfoUtils.attribute(section, "isTrue").getBooleanValue()).isTrue();
+    assertThat(SystemInfoUtils.attribute(section, "isFalse").getBooleanValue()).isFalse();
+  }
+
   @Test
   public void test_order() {
     Collection<Section> sections = asList(
index d6f5f0df07d0db2f9266e1496e53ecf5da103947..e0cd9c9bca2e81a65890565f11fa2c7bb0d60a98 100644 (file)
@@ -66,6 +66,7 @@ public class EsStateSection implements SystemInfoSection {
       setAttribute(protobuf, "Disk Available", byteCountToDisplaySize(stats.getFs().getTotal().getAvailable().getBytes()));
       setAttribute(protobuf, "Store Size", byteCountToDisplaySize(stats.getIndices().getStore().getSizeInBytes()));
       setAttribute(protobuf, "Open Files", stats.getProcess().getOpenFileDescriptors());
+      setAttribute(protobuf, "Spinning", stats.getFs().getTotal().getSpins());
       setAttribute(protobuf, "JVM Heap Usage", formatPercent(stats.getJvm().getMem().getHeapUsedPercent()));
       setAttribute(protobuf, "JVM Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getHeapUsed().getBytes()));
       setAttribute(protobuf, "JVM Heap Max", byteCountToDisplaySize(stats.getJvm().getMem().getHeapMax().getBytes()));