aboutsummaryrefslogtreecommitdiffstats
path: root/server/process/sonar-process
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@sonarsource.com>2014-08-26 12:57:27 +0200
committerStephane Gamard <stephane.gamard@sonarsource.com>2014-08-26 12:59:31 +0200
commitdcfe048ad461dd07bf663586ca510e3a945b98ff (patch)
tree2826769ac7a68286042df9b2cfe026c74daf16e3 /server/process/sonar-process
parent1c93070c66b1d0d0666c5ef5189bdade11633626 (diff)
downloadsonarqube-dcfe048ad461dd07bf663586ca510e3a945b98ff.tar.gz
sonarqube-dcfe048ad461dd07bf663586ca510e3a945b98ff.zip
Synchronized monitored list of processes
Diffstat (limited to 'server/process/sonar-process')
-rw-r--r--server/process/sonar-process/src/main/java/org/sonar/process/Monitor.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/server/process/sonar-process/src/main/java/org/sonar/process/Monitor.java b/server/process/sonar-process/src/main/java/org/sonar/process/Monitor.java
index 18b4f11d927..f1891535b37 100644
--- a/server/process/sonar-process/src/main/java/org/sonar/process/Monitor.java
+++ b/server/process/sonar-process/src/main/java/org/sonar/process/Monitor.java
@@ -67,7 +67,7 @@ public class Monitor extends Thread implements Terminable {
@Override
public void run() {
for (ProcessWrapper process : processes) {
- LOGGER.debug("Pinging process[{}]",process.getName());
+ LOGGER.debug("Pinging process[{}]", process.getName());
try {
ProcessMXBean mBean = process.getProcessMXBean();
if (mBean != null) {
@@ -85,25 +85,31 @@ public class Monitor extends Thread implements Terminable {
* Registers and monitors process. Note that process is probably not ready yet.
*/
public void registerProcess(ProcessWrapper process) throws InterruptedException {
- processes.add(process);
+ LOGGER.info("Registering process[{}] for monitoring.", process.getName());
+ synchronized (processes) {
+ processes.add(process);
+ }
// starts a monitoring thread
process.start();
}
/**
* Check continuously that registered processes are still up. If any process is down or does not answer to pings
- * during the max allowed period, then thread exits.
+ * during the max allowed period, then thread exits.
*/
@Override
public void run() {
try {
boolean ok = true;
while (isRunning && ok) {
- for (ProcessWrapper process : processes) {
- if (!ProcessUtils.isAlive(process.process())) {
- LOGGER.info("{} is down, stopping all other processes", process.getName());
- ok = false;
- interrupt();
+ synchronized (processes) {
+ LOGGER.debug("Monitoring {} processes.", processes.size());
+ for (ProcessWrapper process : processes) {
+ if (!ProcessUtils.isAlive(process.process())) {
+ LOGGER.info("{} is down, stopping all other processes", process.getName());
+ ok = false;
+ interrupt();
+ }
}
}
if (ok) {