aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-22 19:59:50 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-07-23 15:34:06 +0200
commit0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7 (patch)
tree196271ec789d0462b279d6cb0e735db8d7961c60 /sonar-application
parent94445f214582872ae49e26e675a5483fb2352807 (diff)
downloadsonarqube-0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7.tar.gz
sonarqube-0c9d03f3aa048ebb6e147eb1d3fd341d0602bba7.zip
SONAR-4898 some refactoring
Diffstat (limited to 'sonar-application')
-rw-r--r--sonar-application/pom.xml4
-rw-r--r--sonar-application/src/main/assembly/conf/sonar.properties6
-rw-r--r--sonar-application/src/main/assembly/conf/wrapper.conf4
-rw-r--r--sonar-application/src/main/java/org/sonar/application/Installation.java48
-rw-r--r--sonar-application/src/main/java/org/sonar/application/StartServer.java29
5 files changed, 58 insertions, 33 deletions
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index 2ac77222a32..14d129a9dfc 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -237,8 +237,8 @@
<configuration>
<rules>
<requireFilesSize>
- <minsize>85000000</minsize>
- <maxsize>95000000</maxsize>
+ <minsize>100000000</minsize>
+ <maxsize>105000000</maxsize>
<files>
<file>${project.build.directory}/sonarqube-${project.version}.zip</file>
</files>
diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties
index e2ab2aad13a..bc2243f37da 100644
--- a/sonar-application/src/main/assembly/conf/sonar.properties
+++ b/sonar-application/src/main/assembly/conf/sonar.properties
@@ -4,9 +4,7 @@
# To use an environment variable, use the following syntax : ${env:NAME_OF_ENV_VARIABLE}
# For example:
# sonar.jdbc.url= ${env:SONAR_JDBC_URL}
-#
-#
-# See also the file conf/wrapper.conf for JVM advanced settings
+
#--------------------------------------------------------------------------------------------------
# TO BE DOCUMENTED - WORK IN PROGRESS
@@ -17,7 +15,7 @@
# For debug only
#sonar.es.httpPort=
-#sonar.web.javaOpts=-server -Xmx768m -Djava.awt.headless=true -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Djruby.management.enabled=false
+#sonar.web.javaOpts=-server -Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError
#sonar.web.jmxPort=0
# Paths are absolute or relative to installation root directory
diff --git a/sonar-application/src/main/assembly/conf/wrapper.conf b/sonar-application/src/main/assembly/conf/wrapper.conf
index 74f08ffddf1..21fd822b0f8 100644
--- a/sonar-application/src/main/assembly/conf/wrapper.conf
+++ b/sonar-application/src/main/assembly/conf/wrapper.conf
@@ -4,7 +4,7 @@
wrapper.disable_restarts=TRUE
# Java Additional Parameters
-wrapper.java.additional.1=-Xmx32M
+wrapper.java.additional.1=-Xmx16m
# Initial JVM heap size (in MB)
wrapper.java.initmemory=16
@@ -28,7 +28,6 @@ wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
wrapper.java.classpath.1=../../lib/common/*.jar
wrapper.java.classpath.2=../../lib/*.jar
-
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=./lib
@@ -106,5 +105,4 @@ wrapper.ntservice.starttype=AUTO_START
wrapper.ntservice.interactive=false
#********************************************************************
-# restart the process if CPU is heavily loaded during 240 seconds.
wrapper.ping.timeout=0
diff --git a/sonar-application/src/main/java/org/sonar/application/Installation.java b/sonar-application/src/main/java/org/sonar/application/Installation.java
index 41b87b60b15..924c4f4eb38 100644
--- a/sonar-application/src/main/java/org/sonar/application/Installation.java
+++ b/sonar-application/src/main/java/org/sonar/application/Installation.java
@@ -22,6 +22,9 @@ package org.sonar.application;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.process.NetworkUtils;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -34,18 +37,34 @@ import java.util.Map;
import java.util.Properties;
public class Installation {
+ private static final Logger LOG = LoggerFactory.getLogger(Installation.class);
// guessed from location of sonar-application.jar
private final File homeDir;
private final File tempDir, dataDir, logsDir, webDir;
- private final Map<String, String> props = new HashMap<String, String>();
+ private final Map<String, String> props;
Installation() throws URISyntaxException, IOException {
- // TODO make it configurable with sonar.path.home ?
// lib/sonar-application.jar
File appJar = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
homeDir = appJar.getParentFile().getParentFile();
+ props = initProps(homeDir);
+
+ // init file system
+ props.put("sonar.path.home", homeDir.getAbsolutePath());
+ this.dataDir = existingDir("sonar.path.data", "data");
+ this.tempDir = freshDir("sonar.path.temp", "temp");
+ this.logsDir = existingDir("sonar.path.logs", "logs");
+ this.webDir = existingDir("sonar.path.web", "web");
+
+ initElasticsearch();
+ }
+
+ /**
+ * Load conf/sonar.properties
+ */
+ private static Map<String, String> initProps(File homeDir) throws IOException {
Properties p = new Properties();
File propsFile = new File(homeDir, "conf/sonar.properties");
if (propsFile.exists()) {
@@ -55,22 +74,31 @@ public class Installation {
} finally {
IOUtils.closeQuietly(reader);
}
+ } else {
+ LOG.info("Configuration file not found: " + propsFile.getAbsolutePath());
}
p.putAll(System.getenv());
p.putAll(System.getProperties());
p = ConfigurationUtils.interpolateEnvVariables(p);
+ Map<String, String> result = new HashMap<String, String>();
for (Map.Entry<Object, Object> entry : p.entrySet()) {
Object val = entry.getValue();
if (val != null) {
- this.props.put(entry.getKey().toString(), val.toString());
+ result.put(entry.getKey().toString(), val.toString());
}
}
+ return result;
+ }
- props.put("sonar.path.home", homeDir.getAbsolutePath());
- this.dataDir = existingDir("sonar.path.data", "data");
- this.tempDir = freshDir("sonar.path.temp", "temp");
- this.logsDir = existingDir("sonar.path.logs", "logs");
- this.webDir = existingDir("sonar.path.web", "web");
+ private void initElasticsearch() {
+ // init Elasticsearch
+ if (props.get("sonar.es.port") == null) {
+ props.put("sonar.es.port", String.valueOf(NetworkUtils.freePort()));
+ }
+ if (props.get("sonar.es.cluster.name") == null) {
+ props.put("sonar.es.cluster.name", "sonarqube");
+ }
+ props.put("sonar.es.type", "TRANSPORT");
}
File homeDir() {
@@ -128,6 +156,10 @@ public class Installation {
return props;
}
+ String prop(String key) {
+ return props.get(key);
+ }
+
@CheckForNull
String prop(String key, @Nullable String defaultValue) {
String s = props.get(key);
diff --git a/sonar-application/src/main/java/org/sonar/application/StartServer.java b/sonar-application/src/main/java/org/sonar/application/StartServer.java
index c485c489efe..bb856695260 100644
--- a/sonar-application/src/main/java/org/sonar/application/StartServer.java
+++ b/sonar-application/src/main/java/org/sonar/application/StartServer.java
@@ -34,15 +34,6 @@ public class StartServer {
public StartServer() throws Exception {
Installation installation = new Installation();
- String esPort = installation.prop("sonar.es.node.port", null);
- if (esPort == null) {
- esPort = String.valueOf(NetworkUtils.freePort());
- }
- String esCluster = installation.prop("sonar.es.cluster.name", null);
- if (esCluster == null) {
- installation.setProp("sonar.es.cluster.name", "sonarqube");
- }
-
shutdownHook = new Thread(new Runnable() {
@Override
public void run() {
@@ -57,29 +48,35 @@ public class StartServer {
String opts = installation.prop("sonar.es.javaOpts", "-server -Xmx256m -Xms128m -Xss256k -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly");
elasticsearch = new ProcessWrapper("ES")
.setWorkDir(installation.homeDir())
+ .setJmxPort(NetworkUtils.freePort())
.addJavaOpts(opts)
+ .addJavaOpts("-Djava.io.tmpdir=" + installation.tempDir().getAbsolutePath())
+ .setEnvProperty("SONAR_HOME", installation.homeDir().getAbsolutePath())
.setClassName("org.sonar.search.ElasticSearch")
- .setArguments(installation.props())
- .setArgument("sonar.es.node.port", esPort)
+ .setProperties(installation.props())
.addClasspath(installation.starPath("lib/common"))
- .addClasspath(installation.starPath("lib/search"));
+ .addClasspath(installation.starPath("lib/search"))
+ .execute();
monitor.registerProcess(elasticsearch);
- opts = installation.prop("sonar.web.javaOpts", "-Xmx768m -server -XX:MaxPermSize=160m -Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Djruby.management.enabled=false");
+ opts = installation.prop("sonar.web.javaOpts", "-Xmx768m -server -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError");
server = new ProcessWrapper("SQ")
.setWorkDir(installation.homeDir())
+ .setJmxPort(NetworkUtils.freePort())
.addJavaOpts(opts)
+ .addJavaOpts("-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djruby.management.enabled=false")
+ .addJavaOpts("-Djava.io.tmpdir=" + installation.tempDir().getAbsolutePath())
.setClassName("org.sonar.server.app.ServerProcess")
.setEnvProperty("SONAR_HOME", installation.homeDir().getAbsolutePath())
- .setArguments(installation.props())
- .setArgument("sonar.es.type", "TRANSPORT")
+ .setProperties(installation.props())
.addClasspath(installation.starPath("extensions/jdbc-driver/mysql"))
.addClasspath(installation.starPath("extensions/jdbc-driver/mssql"))
.addClasspath(installation.starPath("extensions/jdbc-driver/oracle"))
.addClasspath(installation.starPath("extensions/jdbc-driver/postgresql"))
.addClasspath(installation.starPath("lib/common"))
- .addClasspath(installation.starPath("lib/server"));
+ .addClasspath(installation.starPath("lib/server"))
+ .execute();
monitor.registerProcess(server);
monitor.start();