aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java33
-rw-r--r--sonar-start/src/main/java/org/sonar/start/StartServer.java16
2 files changed, 32 insertions, 17 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 d8ad63a6201..6dd31880e6a 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
@@ -34,6 +34,8 @@ public class ElasticSearch extends org.sonar.process.Process {
private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearch.class);
+
+ public static final String ES_DEBUG_PROPERTY = "esDebug";
public static final String ES_PORT_PROPERTY = "esPort";
public static final String ES_CLUSTER_PROPERTY = "esCluster";
public static final String ES_HOME_PROPERTY = "esHome";
@@ -74,28 +76,30 @@ public class ElasticSearch extends org.sonar.process.Process {
.put("index.number_of_shards", "1")
.put("index.number_of_replicas", "0")
.put("index.store.type", "mmapfs")
-//
.put("indices.store.throttle.type", "merge")
.put("indices.store.throttle.max_bytes_per_sec", "200mb")
-//
+
.put("script.default_lang", "native")
.put("script.native." + ListUpdate.NAME + ".type", ListUpdate.UpdateListScriptFactory.class.getName())
-//
+
.put("cluster.name", clusterName)
-//
.put("node.name", "sonarqube-" + System.currentTimeMillis())
.put("node.data", true)
.put("node.local", false)
-//
+
// .put("network.bind_host", "127.0.0.1")
- .put("http.enabled", false)
-// .put("http.port", 9200)
-// .put("http.host", "127.0.0.1")
.put("transport.tcp.port", port)
-
.put("path.home", home);
+ if (props.booleanOf(ES_DEBUG_PROPERTY, false)) {
+ esSettings
+ .put("http.enabled", true)
+ .put("http.port", 9200);
+ } else {
+ esSettings.put("http.enabled", false);
+ }
+
node = NodeBuilder.nodeBuilder()
.settings(esSettings)
.build().start();
@@ -103,14 +107,11 @@ public class ElasticSearch extends org.sonar.process.Process {
@Override
public void execute() {
- while (node != null && !node.isClosed()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ try {
+ Thread.currentThread().join();
+ } catch (InterruptedException e) {
+ LOGGER.warn("ES Process has been interrupted");
}
- System.out.println("-- ES is done.");
}
public void shutdown() {
diff --git a/sonar-start/src/main/java/org/sonar/start/StartServer.java b/sonar-start/src/main/java/org/sonar/start/StartServer.java
index a48745f30de..b45fec0e273 100644
--- a/sonar-start/src/main/java/org/sonar/start/StartServer.java
+++ b/sonar-start/src/main/java/org/sonar/start/StartServer.java
@@ -29,6 +29,9 @@ import java.io.File;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -41,15 +44,25 @@ public final class StartServer {
private final ExecutorService executor;
private final MonitorService monitor;
private final String esPort;
+ private final Map<String, String> properties;
private ProcessWrapper elasticsearch;
private ProcessWrapper sonarqube;
public StartServer(Env env) throws IOException {
+ this(env, new String[]{});
+ }
+
+ public StartServer(Env env, String... args) throws IOException {
this.env = env;
this.executor = Executors.newFixedThreadPool(2);
this.monitor = new MonitorService(systemAvailableSocket());
this.esPort = Integer.toString(NetworkUtils.freePort());
+ this.properties = new HashMap<String, String>();
+
+ if (Arrays.binarySearch(args, "--debug") > -1) {
+ properties.put("esDebug", "true");
+ }
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
@@ -116,6 +129,7 @@ public final class StartServer {
"org.sonar.search.ElasticSearch",
new String[]{env.rootDir().getAbsolutePath() + "/lib/search/sonar-search-4.5-SNAPSHOT.jar"},
ImmutableMap.of(
+ "esDebug", properties.containsKey("esDebug") ? properties.get("esDebug") : "false",
"esPort", esPort,
"esHome", env.rootDir().getAbsolutePath()),
"ES", monitor.getMonitoringPort());
@@ -125,6 +139,6 @@ public final class StartServer {
public static void main(String... args) throws InterruptedException, IOException, URISyntaxException {
File home = new File(".");
- new StartServer(new Env(home)).start();
+ new StartServer(new Env(home), args).start();
}
} \ No newline at end of file