]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5484 Add node address in system info
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 27 Aug 2014 15:26:08 +0000 (17:26 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 27 Aug 2014 15:26:28 +0000 (17:26 +0200)
server/sonar-server/src/main/java/org/sonar/server/search/NodeHealth.java
server/sonar-server/src/test/java/org/sonar/server/search/SearchHealthMediumTest.java
server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb

index 1d59e9b65a70eef24160f097cea9cb32e6df4148..51f727e1b425c5f1622247d02fa21a85c61f0082 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Date;
 public class NodeHealth {
 
   private boolean master;
+  private String address;
   private long jvmHeapMax;
   private long jvmHeapUsed;
   private long fsAvailable;
@@ -44,6 +45,14 @@ public class NodeHealth {
     this.master = master;
   }
 
+  public String getAddress() {
+    return address;
+  }
+
+  void setAddress(String address) {
+    this.address = address;
+  }
+
   void setJvmHeapMax(long bytes) {
     this.jvmHeapMax = bytes;
   }
@@ -122,13 +131,13 @@ public class NodeHealth {
     // Master/slave
     setMaster(nodesStats.getNode().isMasterNode());
 
+    // Host IP and port
+    setAddress(nodesStats.getNode().getAddress().toString());
+
     // JVM Heap Usage
     setJvmHeapMax(nodesStats.getJvm().getMem().getHeapMax().bytes());
     setJvmHeapUsed(nodesStats.getJvm().getMem().getHeapUsed().bytes());
 
-    // OS Memory Usage ?
-    // nodesStats.getOs().getMem().freePercent();
-
     // Disk Usage
     setFsTotal(nodesStats.getFs().getTotal().getTotal().bytes());
     setFsAvailable(nodesStats.getFs().getTotal().getAvailable().bytes());
index 4236b4fc85134a28a8171749c4f50e7ab9a73ea0..05440c82ef9bbefe816064b1e1a99f834e367764 100644 (file)
@@ -21,6 +21,11 @@ package org.sonar.server.search;
 
 import org.junit.ClassRule;
 import org.junit.Test;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.server.db.DbClient;
+import org.sonar.server.rule.RuleTesting;
+import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.tester.ServerTester;
 
 import java.util.Date;
@@ -35,6 +40,10 @@ public class SearchHealthMediumTest {
 
   @Test
   public void get_search_health(){
+    DbSession dbSession = tester.get(DbClient.class).openSession(false);
+    tester.get(RuleDao.class).insert(dbSession, RuleTesting.newDto(RuleKey.of("javascript", "S001")));
+    dbSession.commit();
+
     SearchHealth health = tester.get(SearchHealth.class);
     Date now = new Date();
 
@@ -44,6 +53,8 @@ public class SearchHealthMediumTest {
 
     NodeHealth nodeHealth = health.getNodesHealth().values().iterator().next();
     assertThat(nodeHealth.isMaster()).isTrue();
+    System.out.println(nodeHealth.getAddress());
+    assertThat(nodeHealth.getAddress()).contains(":");
     assertThat(nodeHealth.getJvmHeapUsedPercent()).contains("%");
     assertThat(nodeHealth.getFsUsedPercent()).contains("%");
     assertThat(nodeHealth.getJvmThreads()).isGreaterThanOrEqualTo(0L);
index d1116ecf15c9d8dc53418bca9adf96ccc6187f55..8e8514384f4fa03397eeaebfb6352575db534646 100644 (file)
@@ -99,6 +99,7 @@ class Server
       node_info=[]
       add_property(node_info, 'Node Name') { name }
       add_property(node_info, 'Node Type') { node_health.isMaster() ? 'Master' : 'Slave' }
+      add_property(node_info, 'Node Address') { node_health.getAddress() }
       add_property(node_info, 'JVM Heap Usage') { node_health.getJvmHeapUsedPercent() }
       add_property(node_info, 'JVM Threads') { node_health.getJvmThreads() }
       add_property(node_info, 'JVM Uptime') { Internal.i18n.ageFromNow(node_health.getJvmUpSince()) }