From: Simon Brandhof Date: Mon, 14 Jul 2014 08:56:18 +0000 (+0200) Subject: Elasticsearch : disable multicast discovery of Elasticsearch (typo in property) X-Git-Tag: 4.5-RC1~601 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a55c20b4fa5ea3082decc45614c79630f0b38e1;p=sonarqube.git Elasticsearch : disable multicast discovery of Elasticsearch (typo in property) and remove dependencies on logback and commons-io --- diff --git a/server/sonar-search/pom.xml b/server/sonar-search/pom.xml index a5b6e7fc936..f9803aa76a9 100644 --- a/server/sonar-search/pom.xml +++ b/server/sonar-search/pom.xml @@ -13,33 +13,25 @@ sonar-search jar SonarQube :: Search - Elasticsearch Wrapper + Wrapper to start Elasticsearch org.codehaus.sonar sonar-process - ${project.version} + ${pom.version} org.elasticsearch elasticsearch - commons-io - commons-io - - - - org.slf4j - slf4j-api - - - - ch.qos.logback - logback-classic + com.google.code.findbugs + jsr305 + provided + junit junit @@ -75,9 +67,9 @@ - ${artifactId}-${version} + ${pom.artifactId}-${pom.version} - \ No newline at end of file + 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 ece3f384ad2..bbcdaa05d18 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,22 +19,14 @@ */ package org.sonar.search; -import org.apache.commons.lang.StringUtils; -import org.elasticsearch.common.logging.ESLoggerFactory; -import org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.sonar.process.Props; import org.sonar.search.script.ListUpdate; 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"; @@ -51,25 +43,21 @@ public class ElasticSearch extends org.sonar.process.Process { super(props); - if (StringUtils.isEmpty(props.of(ES_HOME_PROPERTY, null))) { + String home = props.of(ES_HOME_PROPERTY); + if (home == null) { throw new IllegalStateException(MISSING_ES_HOME); } - String home = props.of(ES_HOME_PROPERTY); - - if (StringUtils.isEmpty(props.of(ES_PORT_PROPERTY, null))) { + Integer port = props.intOf(ES_PORT_PROPERTY); + if (port == null) { throw new IllegalStateException(MISSING_ES_PORT); } - Integer port = props.intOf(ES_PORT_PROPERTY); - String clusterName = props.of(ES_CLUSTER_PROPERTY, DEFAULT_CLUSTER_NAME); - ESLoggerFactory.setDefaultFactory(new Slf4jESLoggerFactory()); - ImmutableSettings.Builder esSettings = ImmutableSettings.settingsBuilder() - .put("discovery.zen.ping.multicast.enable", "false") + .put("discovery.zen.ping.multicast.enabled", "false") .put("index.merge.policy.max_merge_at_once", "200") .put("index.merge.policy.segments_per_tier", "200") @@ -86,9 +74,6 @@ public class ElasticSearch extends org.sonar.process.Process { .put("node.name", "sonarqube-" + System.currentTimeMillis()) .put("node.data", true) .put("node.local", false) - -// .put("network.bind_host", "127.0.0.1") - .put("transport.tcp.port", port) .put("path.home", home); @@ -110,13 +95,14 @@ public class ElasticSearch extends org.sonar.process.Process { try { Thread.currentThread().join(); } catch (InterruptedException e) { - LOGGER.warn("ES Process has been interrupted"); + // TODO use java.util.logging + e.printStackTrace(); } } public void onStop() { if (node != null) { - this.node.close(); + node.close(); } } @@ -125,4 +111,4 @@ public class ElasticSearch extends org.sonar.process.Process { ElasticSearch elasticSearch = new ElasticSearch(props); elasticSearch.start(); } -} \ No newline at end of file +} diff --git a/server/sonar-search/src/main/java/org/sonar/search/package-info.java b/server/sonar-search/src/main/java/org/sonar/search/package-info.java new file mode 100644 index 00000000000..7d4341cf6f2 --- /dev/null +++ b/server/sonar-search/src/main/java/org/sonar/search/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.search; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java index d0acd6b3393..41c4c34f965 100644 --- a/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java +++ b/server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java @@ -28,9 +28,6 @@ import org.elasticsearch.script.NativeScriptFactory; import java.util.Collection; import java.util.Map; -/** - * @since 4.4 - */ public class ListUpdate extends AbstractExecutableScript { public static final String NAME = "listUpdate"; diff --git a/server/sonar-search/src/main/java/org/sonar/search/script/package-info.java b/server/sonar-search/src/main/java/org/sonar/search/script/package-info.java new file mode 100644 index 00000000000..86177fd7841 --- /dev/null +++ b/server/sonar-search/src/main/java/org/sonar/search/script/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.search.script; + +import javax.annotation.ParametersAreNonnullByDefault;