aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process-monitor/src/main/java/org
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-08-17 18:17:30 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-05 14:24:12 +0200
commit92a27e7b4d09b170825ada0cb2c9e971a44c2a8c (patch)
treec702d7ba5f8bf7776dbbf75fe65adee6eacb7d0e /server/sonar-process-monitor/src/main/java/org
parent826cbace35682de7d4eb9ca496a5c277d2120e4c (diff)
downloadsonarqube-92a27e7b4d09b170825ada0cb2c9e971a44c2a8c.tar.gz
sonarqube-92a27e7b4d09b170825ada0cb2c9e971a44c2a8c.zip
SONAR-9590 do not write jvm.options file twice
Diffstat (limited to 'server/sonar-process-monitor/src/main/java/org')
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java4
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/application/process/EsCommand.java10
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java11
3 files changed, 3 insertions, 22 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java
index 35d018126c0..de2174d3e2d 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/CommandFactoryImpl.java
@@ -20,7 +20,6 @@
package org.sonar.application.process;
import java.io.File;
-import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import org.sonar.application.config.AppSettings;
@@ -64,7 +63,6 @@ public class CommandFactoryImpl implements CommandFactory {
File logDir = new File(settingsMap.get("path.logs"));
File confDir = new File(settingsMap.get("path.conf"));
- Path jvmOptionsFile = confDir.toPath().resolve("jvm.options");
EsCommand res = new EsCommand(ProcessId.ELASTICSEARCH)
.setWorkDir(executable.getParentFile().getParentFile())
.setExecutable(executable)
@@ -76,8 +74,6 @@ public class CommandFactoryImpl implements CommandFactory {
.setPort(Integer.valueOf(settingsMap.get("transport.tcp.port")))
.addJvmOption(settings.getProps().nonNullValue(ProcessProperties.SEARCH_JAVA_OPTS))
.addJvmOption(settings.getProps().nonNullValue(ProcessProperties.SEARCH_JAVA_ADDITIONAL_OPTS))
- .setJvmOptionsFile(jvmOptionsFile)
- .setEnvVariable("ES_JVM_OPTIONS", jvmOptionsFile.toString())
.setEnvVariable("JAVA_HOME", System.getProperties().getProperty("java.home"));
settingsMap.forEach((key, value) -> res.addEsOption("-E" + key + "=" + value));
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/EsCommand.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/EsCommand.java
index 3e787eb6736..43974a5ef08 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/EsCommand.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/EsCommand.java
@@ -20,7 +20,6 @@
package org.sonar.application.process;
import java.io.File;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -35,7 +34,6 @@ public class EsCommand extends AbstractCommand<EsCommand> {
private Properties log4j2Properties;
private List<String> esOptions = new ArrayList<>();
private List<String> jvmOptions = new ArrayList<>();
- private Path jvmOptionsFile;
public EsCommand(ProcessId id) {
super(id);
@@ -117,12 +115,4 @@ public class EsCommand extends AbstractCommand<EsCommand> {
return this;
}
- public Path getJvmOptionsFile() {
- return jvmOptionsFile;
- }
-
- public EsCommand setJvmOptionsFile(Path jvmOptionsFile) {
- this.jvmOptionsFile = jvmOptionsFile;
- return this;
- }
}
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
index b2d13441f18..19b8eb6504f 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/process/ProcessLauncherImpl.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -33,7 +32,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,7 +105,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
try {
IOUtils.copy(getClass().getResourceAsStream("elasticsearch.yml"), new FileOutputStream(new File(confDir, "elasticsearch.yml")));
- IOUtils.copy(getClass().getResourceAsStream("jvm.options"), new FileOutputStream(new File(confDir, "jvm.options")));
+ writeJvmOptions(esCommand, new File(confDir, "jvm.options"));
esCommand.getLog4j2Properties().store(new FileOutputStream(new File(confDir, "log4j2.properties")), "log42 properties file for ES bundled in SonarQube");
} catch (IOException e) {
throw new IllegalStateException("Failed to write ES configuration files", e);
@@ -141,13 +139,10 @@ public class ProcessLauncherImpl implements ProcessLauncher {
commands.add(esCommand.getExecutable().getAbsolutePath());
commands.addAll(esCommand.getEsOptions());
- writeJvmOptions(esCommand);
-
return create(esCommand, commands);
}
- private static void writeJvmOptions(EsCommand esCommand) {
- Path jvmOptionsFile = esCommand.getJvmOptionsFile();
+ private static void writeJvmOptions(EsCommand esCommand, File jvmOptionsFile) {
String jvmOptions = esCommand.getJvmOptions()
.stream()
@@ -157,7 +152,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
.collect(Collectors.joining("\n"));
String jvmOptionsContent = ELASTICSEARCH_JVM_OPTIONS_HEADER + jvmOptions;
try {
- Files.write(jvmOptionsFile, jvmOptionsContent.getBytes(Charset.forName("UTF-8")));
+ Files.write(jvmOptionsFile.toPath(), jvmOptionsContent.getBytes(Charset.forName("UTF-8")));
} catch (IOException e) {
throw new IllegalStateException("Cannot write Elasticsearch jvm options file", e);
}