diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-22 19:59:50 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-23 15:34:06 +0200 |
commit | 0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7 (patch) | |
tree | 196271ec789d0462b279d6cb0e735db8d7961c60 /server | |
parent | 94445f214582872ae49e26e675a5483fb2352807 (diff) | |
download | sonarqube-0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7.tar.gz sonarqube-0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7.zip |
SONAR-4898 some refactoring
Diffstat (limited to 'server')
5 files changed, 14 insertions, 23 deletions
diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java index b909bfe550a..435c84ca355 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessWrapper.java @@ -60,7 +60,7 @@ public class ProcessWrapper extends Thread { private final List<String> javaOpts = new ArrayList<String>(); private final List<String> classpath = new ArrayList<String>(); private final Map<String, String> envProperties = new HashMap<String, String>(); - private final Map<String, String> arguments = new HashMap<String, String>(); + private final Map<String, String> properties = new HashMap<String, String>(); private File workDir; private File propertiesFile; private java.lang.Process process; @@ -82,14 +82,14 @@ public class ProcessWrapper extends Thread { return this; } - public ProcessWrapper setArgument(String key, String value) { - arguments.put(key, value); + public ProcessWrapper setProperty(String key, String value) { + properties.put(key, value); return this; } - public ProcessWrapper setArguments(Map<String, String> args) { - arguments.clear(); - arguments.putAll(args); + public ProcessWrapper setProperties(Map<String, String> args) { + properties.clear(); + properties.putAll(args); return this; } @@ -125,7 +125,7 @@ public class ProcessWrapper extends Thread { return this; } - public void execute() { + public ProcessWrapper execute() { List<String> command = new ArrayList<String>(); command.add(buildJavaCommand()); command.addAll(javaOpts); @@ -137,6 +137,7 @@ public class ProcessWrapper extends Thread { ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command(command); processBuilder.directory(workDir); + processBuilder.environment().putAll(envProperties); try { LOGGER.debug("ProcessWrapper::executeProcess() -- Starting process with command '{}'", StringUtils.join(command, " ")); @@ -147,6 +148,7 @@ public class ProcessWrapper extends Thread { outputGobbler.start(); errorGobbler.start(); processMXBean = waitForJMX(); + return this; } catch (IOException e) { throw new IllegalStateException("Fail to start process: " + StringUtils.join(command, " "), e); @@ -214,14 +216,14 @@ public class ProcessWrapper extends Thread { } private List<String> buildClasspath() { - return Arrays.asList("-cp", StringUtils.join(classpath, ";")); + return Arrays.asList("-cp", StringUtils.join(classpath, System.getProperty("path.separator"))); } private File buildPropertiesFile() { try { propertiesFile = File.createTempFile("sq-conf", "properties"); Properties props = new Properties(); - props.putAll(arguments); + props.putAll(properties); props.put(Process.NAME_PROPERTY, processName); props.put(Process.PORT_PROPERTY, String.valueOf(jmxPort)); OutputStream out = new FileOutputStream(propertiesFile); 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 c2c1b2bac96..ea1b4f95b15 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 @@ -34,11 +34,9 @@ import java.io.File; public class ElasticSearch extends Process { public static final String ES_DEBUG_PROPERTY = "esDebug"; - public static final String ES_PORT_PROPERTY = "sonar.es.node.port"; + public static final String ES_PORT_PROPERTY = "sonar.es.port"; public static final String ES_CLUSTER_PROPERTY = "sonar.es.cluster.name"; - public static final String DEFAULT_CLUSTER_NAME = "sonarqube"; - private Node node; public ElasticSearch(String... args) { @@ -121,7 +119,7 @@ public class ElasticSearch extends Process { public void onStart() { String dataDir = props.of("sonar.path.data"); Integer port = props.intOf(ES_PORT_PROPERTY); - String clusterName = props.of(ES_CLUSTER_PROPERTY, DEFAULT_CLUSTER_NAME); + String clusterName = props.of(ES_CLUSTER_PROPERTY); LoggerFactory.getLogger(ElasticSearch.class).info("Starting ES[{}] on port: {}", clusterName, port); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java index cceb7c4cb43..41035bacce9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java @@ -24,7 +24,6 @@ import org.apache.commons.io.filefilter.FileFilterUtils; import org.picocontainer.Startable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.CoreProperties; import org.sonar.api.config.Settings; import org.sonar.api.platform.Server; import org.sonar.api.platform.ServerFileSystem; @@ -32,7 +31,6 @@ import org.sonar.core.persistence.Database; import org.sonar.core.persistence.dialect.H2; import javax.annotation.CheckForNull; - import java.io.File; import java.io.FileFilter; import java.io.IOException; @@ -71,16 +69,10 @@ public class DefaultServerFileSystem implements ServerFileSystem, Startable { @Override public void start() { LOGGER.info("SonarQube home: " + homeDir.getAbsolutePath()); - if (!homeDir.isDirectory() || !homeDir.exists()) { - throw new IllegalStateException("SonarQube home directory does not exist"); - } - try { if (getDeployDir() == null) { throw new IllegalArgumentException("Web app directory does not exist: " + getDeployDir()); } - - LOGGER.info("Deploy dir: " + getDeployDir().getAbsolutePath()); FileUtils.forceMkdir(getDeployDir()); for (File subDirectory : getDeployDir().listFiles((FileFilter) FileFilterUtils.directoryFileFilter())) { FileUtils.cleanDirectory(subDirectory); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/PlatformServletContextListener.java b/server/sonar-server/src/main/java/org/sonar/server/platform/PlatformServletContextListener.java index ab87e7db4b8..250832144d1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/PlatformServletContextListener.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/PlatformServletContextListener.java @@ -100,7 +100,6 @@ public final class PlatformServletContextListener implements ServletContextListe // Line below used in last resort "false"); Map<String, String> variables = ImmutableMap.of( - "RAILS_LOGGER_LEVEL", profilingLevel == Profiling.Level.FULL ? "DEBUG" : "WARN", "LOGFILE_LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? LOGFILE_FULL_LOGGING_FORMAT : LOGFILE_STANDARD_LOGGING_FORMAT, "CONSOLE_LOGGING_FORMAT", profilingLevel == Profiling.Level.FULL ? CONSOLE_FULL_LOGGING_FORMAT : CONSOLE_STANDARD_LOGGING_FORMAT, "CONSOLE_ENABLED", consoleEnabled); diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java b/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java index 007b5689883..996c8ec477c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java +++ b/server/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java @@ -31,7 +31,7 @@ public final class IndexProperties { public static final String TYPE = "sonar.es.type"; public static final String HTTP_PORT = "sonar.es.http.port"; - public static final String NODE_PORT = "sonar.es.node.port"; + public static final String NODE_PORT = "sonar.es.port"; public static final String CLUSTER_NAME = "sonar.es.cluster.name"; } |