diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-18 14:38:50 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-18 15:52:16 +0200 |
commit | 9ed09aa7bd0e0541b45ff6c4ac0238d10769448c (patch) | |
tree | 5bf30cc64ae7b9a28ef6ec787ea405cdb4b9b915 /server/sonar-search | |
parent | c3174fada2ab193d03661209bee3291772b8f347 (diff) | |
download | sonarqube-9ed09aa7bd0e0541b45ff6c4ac0238d10769448c.tar.gz sonarqube-9ed09aa7bd0e0541b45ff6c4ac0238d10769448c.zip |
SONAR-5408 - ProcessWrapper passes properties file as args[0]
Diffstat (limited to 'server/sonar-search')
-rw-r--r-- | server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java b/server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java index 29d0d880b72..a98e9e3b27b 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java +++ b/server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java @@ -19,6 +19,7 @@ */ package org.sonar.search; +import com.google.common.annotations.VisibleForTesting; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.unit.TimeValue; @@ -44,12 +45,32 @@ public class ElasticSearch extends Process { public static final String DEFAULT_CLUSTER_NAME = "sonarqube"; - private final Node node; + private Node node; + public ElasticSearch(String... args) { + super(args); + } + + @VisibleForTesting public ElasticSearch(Props props) { super(props); + } + @Override + public boolean isReady() { + try { + return (node.client().admin().cluster().prepareHealth() + .setWaitForYellowStatus() + .setTimeout(TimeValue.timeValueSeconds(3L)) + .get() + .getStatus() != ClusterHealthStatus.RED); + } catch (Exception e) { + return false; + } + } + @Override + public void onStart() { String home = props.of(ES_HOME_PROPERTY); if (home == null) { throw new IllegalStateException(MISSING_ES_HOME); @@ -99,25 +120,7 @@ public class ElasticSearch extends Process { node = NodeBuilder.nodeBuilder() .settings(esSettings) .build(); - } - - @Override - public boolean isReady() { - try { - return (node.client().admin().cluster().prepareHealth() - .setWaitForYellowStatus() - .setTimeout(TimeValue.timeValueSeconds(3L)) - .get() - .getStatus() != ClusterHealthStatus.RED); - } catch (Exception e) { - return false; - } - } - - @Override - public void onStart() { - node.start(); while (!node.isClosed()) { try { Thread.sleep(1000); @@ -134,8 +137,7 @@ public class ElasticSearch extends Process { } public static void main(String... args) throws InterruptedException { - Props props = Props.create(System.getProperties()); - final ElasticSearch elasticSearch = new ElasticSearch(props); + final ElasticSearch elasticSearch = new ElasticSearch(args); elasticSearch.start(); } } |