<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>
</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>
*/
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";
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")
.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);
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();
}
}
ElasticSearch elasticSearch = new ElasticSearch(props);
elasticSearch.start();
}
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * 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;
import java.util.Collection;
import java.util.Map;
-/**
- * @since 4.4
- */
public class ListUpdate extends AbstractExecutableScript {
public static final String NAME = "listUpdate";
--- /dev/null
+/*
+ * 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;