]> source.dussan.org Git - sonarqube.git/commitdiff
Elasticsearch : disable multicast discovery of Elasticsearch (typo in property)
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 14 Jul 2014 08:56:18 +0000 (10:56 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 14 Jul 2014 08:56:31 +0000 (10:56 +0200)
and remove dependencies on logback and commons-io

server/sonar-search/pom.xml
server/sonar-search/src/main/java/org/sonar/search/ElasticSearch.java
server/sonar-search/src/main/java/org/sonar/search/package-info.java [new file with mode: 0644]
server/sonar-search/src/main/java/org/sonar/search/script/ListUpdate.java
server/sonar-search/src/main/java/org/sonar/search/script/package-info.java [new file with mode: 0644]

index a5b6e7fc9361f0ed185a0ee37d186601d2953fd0..f9803aa76a944e5147b5681df145d34aab4cb405 100644 (file)
   <artifactId>sonar-search</artifactId>
   <packaging>jar</packaging>
   <name>SonarQube :: Search</name>
-  <description>Elasticsearch Wrapper</description>
+  <description>Wrapper to start Elasticsearch</description>
 
   <dependencies>
     <dependency>
       <groupId>org.codehaus.sonar</groupId>
       <artifactId>sonar-process</artifactId>
-      <version>${project.version}</version>
+      <version>${pom.version}</version>
     </dependency>
     <dependency>
       <groupId>org.elasticsearch</groupId>
       <artifactId>elasticsearch</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <scope>provided</scope>
     </dependency>
 
+    <!-- testing -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
@@ -75,9 +67,9 @@
           </execution>
         </executions>
         <configuration>
-          <finalName>${artifactId}-${version}</finalName>
+          <finalName>${pom.artifactId}-${pom.version}</finalName>
         </configuration>
       </plugin>
     </plugins>
   </build>
-</project>
\ No newline at end of file
+</project>
index ece3f384ad2a4f579923d11a698878608bafdeeb..bbcdaa05d18b35723d6700ec1eb7217a26ac2272 100644 (file)
  */
 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 (file)
index 0000000..7d4341c
--- /dev/null
@@ -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;
index d0acd6b339342d1cbfcad1e0086b1ce9158b09de..41c4c34f965cacf4e6453f25714e4f0af62b37d9 100644 (file)
@@ -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 (file)
index 0000000..86177fd
--- /dev/null
@@ -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;