aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-07 15:23:27 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-13 15:50:55 +0200
commit46cea1eed83a0abe5b1fd7f50efb6f3b367ed43b (patch)
tree77c62cc14d677c34e33576cbcad329bce0648b86
parentbc792b361a54b02e89fbcb1f22a7c90391bf2d53 (diff)
downloadsonarqube-46cea1eed83a0abe5b1fd7f50efb6f3b367ed43b.tar.gz
sonarqube-46cea1eed83a0abe5b1fd7f50efb6f3b367ed43b.zip
SONAR-9587 exclude non used ES modules from distribution zip
-rw-r--r--pom.xml10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java40
-rw-r--r--sonar-application/assembly.xml6
-rw-r--r--sonar-application/pom.xml4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java2
5 files changed, 56 insertions, 6 deletions
diff --git a/pom.xml b/pom.xml
index 176d71ab43e..daa804740d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -715,6 +715,16 @@
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.elasticsearch.plugin</groupId>
+ <artifactId>lang-mustache-client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.elasticsearch.plugin</groupId>
+ <artifactId>transport-netty3-client</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.github.tlrx</groupId>
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
index 110ae95f6fa..1dbd2eb5f8f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java
@@ -20,14 +20,22 @@
package org.sonar.server.es;
import com.google.common.net.HostAndPort;
+import io.netty.util.ThreadDeathWatcher;
+import io.netty.util.concurrent.GlobalEventExecutor;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.network.NetworkModule;
+import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
-import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.elasticsearch.index.reindex.ReindexPlugin;
+import org.elasticsearch.join.ParentJoinPlugin;
+import org.elasticsearch.percolator.PercolatorPlugin;
+import org.elasticsearch.transport.Netty4Plugin;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.config.Configuration;
@@ -37,6 +45,7 @@ import org.sonar.api.utils.log.Loggers;
import org.sonar.cluster.NodeType;
import org.sonar.process.ProcessProperties;
+import static java.util.Collections.unmodifiableList;
import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
@@ -53,14 +62,14 @@ public class EsClientProvider extends ProviderAdapter {
public EsClient provide(Configuration config) {
if (cache == null) {
- org.elasticsearch.common.settings.Settings.Builder esSettings = org.elasticsearch.common.settings.Settings.builder();
+ Settings.Builder esSettings = Settings.builder();
// mandatory property defined by bootstrap process
esSettings.put("cluster.name", config.get(CLUSTER_NAME).get());
boolean clusterEnabled = config.getBoolean(CLUSTER_ENABLED).orElse(false);
boolean searchNode = !clusterEnabled || SEARCH.equals(NodeType.parse(config.get(CLUSTER_NODE_TYPE).orElse(null)));
- final TransportClient nativeClient = new PreBuiltTransportClient(esSettings.build());
+ final TransportClient nativeClient = new MinimalTransportClient(esSettings.build());
if (clusterEnabled && !searchNode) {
esSettings.put("client.transport.sniff", true);
Arrays.stream(config.getStringArray(CLUSTER_SEARCH_HOSTS))
@@ -89,4 +98,29 @@ public class EsClientProvider extends ProviderAdapter {
private static String displayedAddresses(TransportClient nativeClient) {
return nativeClient.transportAddresses().stream().map(TransportAddress::toString).collect(Collectors.joining(", "));
}
+
+ static class MinimalTransportClient extends TransportClient {
+
+ MinimalTransportClient(Settings settings) {
+ super(settings, unmodifiableList(Arrays.asList(Netty4Plugin.class, ReindexPlugin.class, PercolatorPlugin.class, ParentJoinPlugin.class)));
+ }
+
+ @Override
+ public void close() {
+ super.close();
+ if (!NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings)
+ || NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(Netty4Plugin.NETTY_TRANSPORT_NAME)) {
+ try {
+ GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ try {
+ ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+ }
}
diff --git a/sonar-application/assembly.xml b/sonar-application/assembly.xml
index 16e91b4d690..a2122e2ebff 100644
--- a/sonar-application/assembly.xml
+++ b/sonar-application/assembly.xml
@@ -179,6 +179,12 @@
<exclude>**/*.sh</exclude>
<exclude>**/ant</exclude>
<exclude>**/antRun</exclude>
+ <!--exclude ES modules by default in the distribution that we don't use-->
+ <exclude>elasticsearch/modules/lang-expression/</exclude>
+ <exclude>elasticsearch/modules/lang-groovy/</exclude>
+ <exclude>elasticsearch/modules/lang-mustache/</exclude>
+ <exclude>elasticsearch/modules/lang-painless/</exclude>
+ <exclude>elasticsearch/modules/transport-netty3/</exclude>
</excludes>
<fileMode>0644</fileMode>
</fileSet>
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index 709e73367ad..515f206f3e8 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -240,8 +240,8 @@
<configuration>
<rules>
<requireFilesSize>
- <minsize>165000000</minsize>
- <maxsize>180000000</maxsize>
+ <minsize>160000000</minsize>
+ <maxsize>175000000</maxsize>
<files>
<file>${project.build.directory}/sonarqube-${project.version}.zip</file>
</files>
diff --git a/tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java b/tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java
index 58be6c8df51..b53cb4baad4 100644
--- a/tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/performance/server/ServerPerfTest.java
@@ -60,7 +60,7 @@ public class ServerPerfTest extends AbstractPerfTest {
// compare dates of first and last log
long firstLogDate = ServerLogs.extractFirstDate(readLines(orchestrator.getServer().getAppLogs())).getTime();
long startedAtDate = extractStartedAtDate(orchestrator);
- assertDurationAround(startedAtDate - firstLogDate, 34_000);
+ assertDurationAround(startedAtDate - firstLogDate, 32_000);
ServerLogs.clear(orchestrator);
orchestrator.stop();