diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-16 23:01:11 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-03-25 09:58:44 +0100 |
commit | 6bc55b17ebd87802cb9b55d5b6625e1a935f3909 (patch) | |
tree | 0a50457cc294c211ad7a3ee081dabb93e4231286 /sonar-application | |
parent | 4250bb53f050b5a7f86b211ec2b34f85f7cc3ddc (diff) | |
download | sonarqube-6bc55b17ebd87802cb9b55d5b6625e1a935f3909.tar.gz sonarqube-6bc55b17ebd87802cb9b55d5b6625e1a935f3909.zip |
SONAR-7436 Monitoring of CE process in system WS and console
Diffstat (limited to 'sonar-application')
-rw-r--r-- | sonar-application/src/main/java/org/sonar/application/App.java | 16 | ||||
-rw-r--r-- | sonar-application/src/test/java/org/sonar/application/AppTest.java | 7 |
2 files changed, 11 insertions, 12 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/App.java b/sonar-application/src/main/java/org/sonar/application/App.java index 35e9f491694..de5db3c03e4 100644 --- a/sonar-application/src/main/java/org/sonar/application/App.java +++ b/sonar-application/src/main/java/org/sonar/application/App.java @@ -27,26 +27,24 @@ import java.util.Properties; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.sonar.process.MinimumViableSystem; +import org.sonar.process.ProcessId; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import org.sonar.process.Stoppable; import org.sonar.process.monitor.JavaCommand; import org.sonar.process.monitor.Monitor; +import static org.sonar.process.ProcessId.APP; + /** * Entry-point of process that starts and monitors ElasticSearch, the Web Server and the Compute Engine. */ public class App implements Stoppable { - public static final int APP_PROCESS_NUMBER = 0; - public static final int ES_PROCESS_INDEX = 1; - public static final int WEBSERVER_PROCESS_INDEX = 2; - public static final int CESERVER_PROCESS_INDEX = 3; - private final Monitor monitor; public App(AppFileSystem appFileSystem, boolean watchForHardStop) { - this(Monitor.create(APP_PROCESS_NUMBER, appFileSystem, watchForHardStop)); + this(Monitor.create(APP.getIpcIndex(), appFileSystem, watchForHardStop)); } App(Monitor monitor) { @@ -74,7 +72,7 @@ public class App implements Stoppable { } private static JavaCommand createESCommand(Props props, File homeDir) { - JavaCommand elasticsearch = new JavaCommand("search", ES_PROCESS_INDEX); + JavaCommand elasticsearch = new JavaCommand(ProcessId.ELASTICSEARCH); elasticsearch .setWorkDir(homeDir) .addJavaOptions("-Djava.awt.headless=true") @@ -88,7 +86,7 @@ public class App implements Stoppable { } private static JavaCommand createWebServerCommand(Props props, File homeDir) { - JavaCommand webServer = new JavaCommand("web", WEBSERVER_PROCESS_INDEX) + JavaCommand webServer = new JavaCommand(ProcessId.WEB_SERVER) .setWorkDir(homeDir) .addJavaOptions(ProcessProperties.WEB_ENFORCED_JVM_ARGS) .addJavaOptions(props.nonNullValue(ProcessProperties.WEB_JAVA_OPTS)) @@ -107,7 +105,7 @@ public class App implements Stoppable { } private static JavaCommand createCeServerCommand(Props props, File homeDir) { - JavaCommand webServer = new JavaCommand("ce", CESERVER_PROCESS_INDEX) + JavaCommand webServer = new JavaCommand(ProcessId.COMPUTE_ENGINE) .setWorkDir(homeDir) .addJavaOptions(ProcessProperties.CE_ENFORCED_JVM_ARGS) .addJavaOptions(props.nonNullValue(ProcessProperties.CE_JAVA_OPTS)) diff --git a/sonar-application/src/test/java/org/sonar/application/AppTest.java b/sonar-application/src/test/java/org/sonar/application/AppTest.java index 70f694c97dc..8150639c865 100644 --- a/sonar-application/src/test/java/org/sonar/application/AppTest.java +++ b/sonar-application/src/test/java/org/sonar/application/AppTest.java @@ -28,6 +28,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.mockito.ArgumentCaptor; +import org.sonar.process.ProcessId; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import org.sonar.process.monitor.JavaCommand; @@ -52,7 +53,7 @@ public class AppTest { } @Test - public void start_elasticsearch_and_tomcat_by_default() throws Exception { + public void start_all_processes_by_default() throws Exception { Monitor monitor = mock(Monitor.class); App app = new App(monitor); Props props = initDefaultProps(); @@ -61,7 +62,7 @@ public class AppTest { ArgumentCaptor<List<JavaCommand>> argument = newJavaCommandArgumentCaptor(); verify(monitor).start(argument.capture()); - assertThat(argument.getValue()).extracting("key").containsExactly("search", "web", "ce"); + assertThat(argument.getValue()).extracting("processId").containsExactly(ProcessId.ELASTICSEARCH, ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE); } @Test @@ -75,7 +76,7 @@ public class AppTest { ArgumentCaptor<List<JavaCommand>> argument = newJavaCommandArgumentCaptor(); verify(monitor).start(argument.capture()); - assertThat(argument.getValue()).extracting("key").containsOnly("search"); + assertThat(argument.getValue()).extracting("processId").containsOnly(ProcessId.ELASTICSEARCH); } @Test |