diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-08-06 15:33:29 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-08-06 15:33:29 +0200 |
commit | 36bf1c9ec419315e478b247baea9bc1468f305b9 (patch) | |
tree | 0e54591fb1ad2b6cb953c5ca374a0590f613288b | |
parent | 51c7b2f22b09d25e460d9b9b8091733512b3e1f7 (diff) | |
download | sonarqube-36bf1c9ec419315e478b247baea9bc1468f305b9.tar.gz sonarqube-36bf1c9ec419315e478b247baea9bc1468f305b9.zip |
SONAR-4907 - Added naming for search and server within a node.
4 files changed, 19 insertions, 5 deletions
diff --git a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java index de411943c3e..45112359b5d 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java +++ b/server/sonar-search/src/main/java/org/sonar/search/SearchServer.java @@ -39,6 +39,7 @@ import java.util.Set; public class SearchServer extends MonitoredProcess { + public static final String SONAR_NODE_NAME = "sonar.node.name"; public static final String ES_PORT_PROPERTY = "sonar.search.port"; public static final String ES_CLUSTER_PROPERTY = "sonar.cluster.name"; public static final String ES_CLUSTER_INET = "sonar.cluster.master"; @@ -133,10 +134,14 @@ public class SearchServer extends MonitoredProcess { // Set cluster coordinates esSettings.put("cluster.name", clusterName); - try { - esSettings.put("node.name", InetAddress.getLocalHost().getHostName()); - } catch (Exception e) { - esSettings.put("node.name", "sq-" + System.currentTimeMillis()); + if (props.contains(SONAR_NODE_NAME)) { + esSettings.put("node.name", props.of(SONAR_NODE_NAME)); + } else { + try { + esSettings.put("node.name", InetAddress.getLocalHost().getHostName()); + } catch (Exception e) { + esSettings.put("node.name", "sq-" + System.currentTimeMillis()); + } } // Make sure the index settings are up to date. diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java index 3e55619a06d..fbaad7a4834 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java @@ -32,6 +32,7 @@ public final class IndexProperties { public static final String TYPE = "sonar.search.type"; public static final String HTTP_PORT = "sonar.search.http.port"; public static final String NODE_PORT = "sonar.search.port"; - public static final String CLUSTER_NAME = "sonar.search.cluster.name"; + public static final String CLUSTER_NAME = "sonar.cluster.name"; + public static final String NODE_NAME = "sonar.node.name"; } diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 66e3b7a1e26..49c4d30075b 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -56,6 +56,7 @@ public class App implements ProcessMXBean { .addJavaOpts(String.format("-Dsonar.path.logs=%s", installation.logsDir().getAbsolutePath())) .setClassName("org.sonar.search.SearchServer") .addProperties(installation.props().rawProperties()) + .addProperty(DefaultSettings.SONAR_NODE_NAME, installation.prop(DefaultSettings.SONAR_NODE_NAME, DefaultSettings.getNonSetNodeName())) .addClasspath(installation.starPath("lib/common")) .addClasspath(installation.starPath("lib/search")); if (elasticsearch.execute()) { @@ -73,6 +74,7 @@ public class App implements ProcessMXBean { .addJavaOpts(String.format("-Dsonar.path.logs=%s", installation.logsDir().getAbsolutePath())) .setClassName("org.sonar.server.app.WebServer") .addProperties(installation.props().rawProperties()) + .addProperty(DefaultSettings.SONAR_NODE_NAME, installation.prop(DefaultSettings.SONAR_NODE_NAME, DefaultSettings.getNonSetNodeName())) .addClasspath(installation.starPath("extensions/jdbc-driver/mysql")) .addClasspath(installation.starPath("extensions/jdbc-driver/mssql")) .addClasspath(installation.starPath("extensions/jdbc-driver/oracle")) diff --git a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java index 7e3634c5423..e97619c4992 100644 --- a/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/DefaultSettings.java @@ -28,6 +28,12 @@ class DefaultSettings { // only static stuff } + static final String SONAR_NODE_NAME = "sonar.node.name"; + + static String getNonSetNodeName() { + return "sonar-" + System.currentTimeMillis(); + } + static final String SONAR_CLUSTER_MASTER = "sonar.cluster.master"; static final String PATH_LOGS_KEY = "sonar.path.logs"; |