aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process-monitor/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-09 11:06:15 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-03-21 16:44:03 +0100
commiteb5e8f7774ee19a58c6796840ec9e71d67bb5a1d (patch)
treeda00f83b2d89cd607f23cb02b4e2c668abb46f13 /server/sonar-process-monitor/src
parent4d3d6b2504673128263eadcec82c8fd64f71e4c5 (diff)
downloadsonarqube-eb5e8f7774ee19a58c6796840ec9e71d67bb5a1d.tar.gz
sonarqube-eb5e8f7774ee19a58c6796840ec9e71d67bb5a1d.zip
SONAR-7435 rename state when process is done starting from ready to up
also clean up code of DefaultProcessCommands and fix it's Javadoc which was out of sync with implementation
Diffstat (limited to 'server/sonar-process-monitor/src')
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java2
-rw-r--r--server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java10
-rw-r--r--server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java28
3 files changed, 20 insertions, 20 deletions
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
index a4e1bfd4b7f..9a9feeab241 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/Monitor.java
@@ -155,7 +155,7 @@ public class Monitor {
watcherThreads.add(watcherThread);
// wait for process to be ready (accept requests or so on)
- processRef.waitForReady();
+ processRef.waitForUp();
LOG.info("{} is up", processRef);
}
diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java
index 5ae2edaaf10..d3523ed2ed4 100644
--- a/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java
+++ b/server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/ProcessRef.java
@@ -58,17 +58,17 @@ class ProcessRef {
return commands;
}
- void waitForReady() {
- boolean ready = false;
- while (!ready) {
+ void waitForUp() {
+ boolean up = false;
+ while (!up) {
if (isStopped()) {
throw new MessageException(String.format("%s failed to start", this));
}
- ready = commands.isReady();
+ up = commands.isUp();
try {
Thread.sleep(200L);
} catch (InterruptedException e) {
- throw new IllegalStateException(String.format("Interrupted while waiting for %s to be ready", this), e);
+ throw new IllegalStateException(String.format("Interrupted while waiting for %s to be up", this), e);
}
}
}
diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java
index ea25a399cfe..9b8a305a7f4 100644
--- a/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java
+++ b/server/sonar-process-monitor/src/test/java/org/sonar/process/monitor/MonitorTest.java
@@ -151,7 +151,7 @@ public class MonitorTest {
// blocks until started
underTest.start(singletonList(client.newCommand()));
- assertThat(client).isReady()
+ assertThat(client).isUp()
.wasStartedBefore(System.currentTimeMillis());
// blocks until stopped
@@ -172,10 +172,10 @@ public class MonitorTest {
// start p2 when p1 is fully started (ready)
assertThat(p1)
- .isReady()
+ .isUp()
.wasStartedBefore(p2);
assertThat(p2)
- .isReady();
+ .isUp();
underTest.stop();
@@ -195,8 +195,8 @@ public class MonitorTest {
HttpProcessClient p1 = new HttpProcessClient(tempDir, "p1");
HttpProcessClient p2 = new HttpProcessClient(tempDir, "p2");
underTest.start(Arrays.asList(p1.newCommand(), p2.newCommand()));
- assertThat(p1).isReady();
- assertThat(p2).isReady();
+ assertThat(p1).isUp();
+ assertThat(p2).isUp();
// emulate CTRL-C
underTest.getShutdownHook().run();
@@ -215,8 +215,8 @@ public class MonitorTest {
HttpProcessClient p2 = new HttpProcessClient(tempDir, "p2");
underTest.start(Arrays.asList(p1.newCommand(), p2.newCommand()));
- assertThat(p1).isReady();
- assertThat(p2).isReady();
+ assertThat(p1).isUp();
+ assertThat(p2).isUp();
p2.restart();
@@ -247,8 +247,8 @@ public class MonitorTest {
HttpProcessClient p1 = new HttpProcessClient(tempDir, "p1");
HttpProcessClient p2 = new HttpProcessClient(tempDir, "p2");
underTest.start(Arrays.asList(p1.newCommand(), p2.newCommand()));
- assertThat(p1.isReady()).isTrue();
- assertThat(p2.isReady()).isTrue();
+ assertThat(p1.isUp()).isTrue();
+ assertThat(p2.isUp()).isTrue();
// kill p1 -> waiting for detection by monitor than termination of p2
p1.kill();
@@ -369,7 +369,7 @@ public class MonitorTest {
/**
* @see org.sonar.process.test.HttpProcess
*/
- boolean isReady() {
+ boolean isUp() {
try {
HttpRequest httpRequest = HttpRequest.get("http://localhost:" + httpPort + "/" + "ping")
.readTimeout(2000).connectTimeout(2000);
@@ -538,12 +538,12 @@ public class MonitorTest {
return this;
}
- public HttpProcessClientAssert isReady() {
+ public HttpProcessClientAssert isUp() {
isNotNull();
// check condition
- if (!actual.isReady()) {
- failWithMessage("HttpClient %s should be ready", actual.commandKey);
+ if (!actual.isUp()) {
+ failWithMessage("HttpClient %s should be up", actual.commandKey);
}
return this;
@@ -552,7 +552,7 @@ public class MonitorTest {
public HttpProcessClientAssert isNotReady() {
isNotNull();
- if (actual.isReady()) {
+ if (actual.isUp()) {
failWithMessage("HttpClient %s should not be ready", actual.commandKey);
}