aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main/src/main/java
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2022-03-15 08:40:06 +0100
committersonartech <sonartech@sonarsource.com>2022-03-18 20:02:58 +0000
commit87d3bfccdbac9d330e9ad5a78da0ebbcac4d8284 (patch)
treef1b15343d98283eda2be5ac6ef5c707eb98d1f37 /server/sonar-main/src/main/java
parent3cd52ef6dab2fe5b7369141819fdf8f30b484f90 (diff)
downloadsonarqube-87d3bfccdbac9d330e9ad5a78da0ebbcac4d8284.tar.gz
sonarqube-87d3bfccdbac9d330e9ad5a78da0ebbcac4d8284.zip
SONAR-10179 improve consistency of start/stop log messages and identifiers of processes
Author: Aurelien Poscia <aurelien.poscia@sonarsource.com>
Diffstat (limited to 'server/sonar-main/src/main/java')
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java6
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java12
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/process/AbstractManagedProcess.java4
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java14
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessLifecycle.java2
5 files changed, 19 insertions, 19 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java b/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java
index b81cd0f4f79..f63f0e9307f 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java
@@ -117,7 +117,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
if (process != null) {
process.destroyForcibly();
}
- throw new IllegalStateException(format("Fail to launch monitor of process [%s]", processId.getKey()), e);
+ throw new IllegalStateException(format("Fail to launch monitor of process [%s]", processId.getHumanReadableName()), e);
}
}
@@ -127,7 +127,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
logLaunchedCommand(esScriptCommand, processBuilder);
return processBuilder.start();
} catch (Exception e) {
- throw new IllegalStateException(format("Fail to launch process [%s]", esScriptCommand.getProcessId().getKey()), e);
+ throw new IllegalStateException(format("Fail to launch process [%s]", esScriptCommand.getProcessId().getHumanReadableName()), e);
}
}
@@ -223,7 +223,7 @@ public class ProcessLauncherImpl implements ProcessLauncher {
logLaunchedCommand(javaCommand, processBuilder);
return processBuilder.start();
} catch (Exception e) {
- throw new IllegalStateException(format("Fail to launch process [%s]", processId.getKey()), e);
+ throw new IllegalStateException(format("Fail to launch process [%s]", processId.getHumanReadableName()), e);
}
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
index 3e4b2cdb72e..391a8bc7f63 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
@@ -202,7 +202,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
// this early stop of the process will be picked up by onProcessStop (which calls hardStopAsync)
// through interface ProcessLifecycleListener#onProcessState implemented by SchedulerImpl
LOG.trace("Failed to start process [{}] (currentThread={})",
- processHandler.getProcessId().getKey(), Thread.currentThread().getName(), e);
+ processHandler.getProcessId().getHumanReadableName(), Thread.currentThread().getName(), e);
}
}
@@ -240,7 +240,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
private void stopProcess(ProcessId processId) throws InterruptedException {
ManagedProcessHandler process = processesById.get(processId);
if (process != null) {
- LOG.debug("Stopping [{}]...", process.getProcessId().getKey());
+ LOG.debug("Stopping [{}]...", process.getProcessId().getHumanReadableName());
process.stop();
}
}
@@ -331,7 +331,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
if (type == Type.OPERATIONAL) {
onProcessOperational(processId);
} else if (type == Type.ASK_FOR_RESTART && nodeLifecycle.tryToMoveTo(RESTARTING)) {
- LOG.info("SQ restart requested by Process[{}]", processId.getKey());
+ LOG.info("SQ restart requested by Process[{}]", processId.getHumanReadableName());
stopAsyncForRestart();
}
}
@@ -341,7 +341,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
appState.setOperational(processId);
boolean lastProcessStarted = operationalCountDown.decrementAndGet() == 0;
if (lastProcessStarted && nodeLifecycle.tryToMoveTo(NodeLifecycle.State.OPERATIONAL)) {
- LOG.info("SonarQube is up");
+ LOG.info("SonarQube is operational");
}
}
@@ -352,7 +352,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
tryToStartAll();
} catch (InterruptedException e) {
// startup process was interrupted, let's assume it means shutdown was requested
- LOG.debug("Startup process was interrupted on notification that process [{}] was operation", processId.getKey(), e);
+ LOG.debug("Startup process was interrupted on notification that process [{}] was operational", processId.getHumanReadableName(), e);
hardStopAsync();
Thread.currentThread().interrupt();
}
@@ -375,7 +375,7 @@ public class SchedulerImpl implements Scheduler, ManagedProcessEventListener, Pr
}
private void onProcessStop(ProcessId processId) {
- LOG.info("Process[{}] is stopped", processId.getKey());
+ LOG.info("Process[{}] is stopped", processId.getHumanReadableName());
boolean lastProcessStopped = stopCountDown.decrementAndGet() == 0;
switch (nodeLifecycle.getState()) {
case RESTARTING:
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/AbstractManagedProcess.java b/server/sonar-main/src/main/java/org/sonar/application/process/AbstractManagedProcess.java
index 73c9942a32b..9584c3eaa26 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/process/AbstractManagedProcess.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/process/AbstractManagedProcess.java
@@ -78,9 +78,9 @@ abstract class AbstractManagedProcess implements ManagedProcess {
int exitValue = process.waitFor();
if (exitValueLogged.compareAndSet(false, true)) {
if (exitValue != EXPECTED_EXIT_VALUE) {
- LOG.warn("Process exited with exit value [{}]: {}", processId.getKey(), exitValue);
+ LOG.warn("Process exited with exit value [{}]: {}", processId.getHumanReadableName(), exitValue);
} else {
- LOG.debug("Process exited with exit value [{}]: {}", processId.getKey(), exitValue);
+ LOG.debug("Process exited with exit value [{}]: {}", processId.getHumanReadableName(), exitValue);
}
}
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java
index ef57c88b61c..272232292bf 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessHandler.java
@@ -75,7 +75,7 @@ public class ManagedProcessHandler {
try {
this.process = commandLauncher.get();
} catch (RuntimeException e) {
- LOG.error("Fail to launch process [{}]", processId.getKey(), e);
+ LOG.error("Failed to launch process [{}]", processId.getHumanReadableName(), e);
lifecycle.tryToMoveTo(ManagedProcessLifecycle.State.STOPPING);
finalizeStop();
throw e;
@@ -104,7 +104,7 @@ public class ManagedProcessHandler {
if (lifecycle.tryToMoveTo(ManagedProcessLifecycle.State.STOPPING)) {
stopImpl();
if (process != null && process.isAlive()) {
- LOG.info("{} failed to stop in a graceful fashion. Hard stopping it.", processId.getKey());
+ LOG.info("{} failed to stop in a graceful fashion. Hard stopping it.", processId.getHumanReadableName());
hardStop();
} else {
// enforce stop and clean-up even if process has been quickly stopped
@@ -124,7 +124,7 @@ public class ManagedProcessHandler {
if (lifecycle.tryToMoveTo(ManagedProcessLifecycle.State.HARD_STOPPING)) {
hardStopImpl();
if (process != null && process.isAlive()) {
- LOG.info("{} failed to stop in a quick fashion. Killing it.", processId.getKey());
+ LOG.info("{} failed to stop in a quick fashion. Killing it.", processId.getHumanReadableName());
}
// enforce stop and clean-up even if process has been quickly stopped
finalizeStop();
@@ -233,7 +233,7 @@ public class ManagedProcessHandler {
@Override
public String toString() {
- return format("Process[%s]", processId.getKey());
+ return format("Process[%s]", processId.getHumanReadableName());
}
/**
@@ -250,7 +250,7 @@ public class ManagedProcessHandler {
// this name is different than Thread#toString(), which includes name, priority
// and thread group
// -> do not override toString()
- super(format("StopWatcher[%s]", processId.getKey()));
+ super(format("StopWatcher[%s]", processId.getHumanReadableName()));
}
@Override
@@ -267,7 +267,7 @@ public class ManagedProcessHandler {
try {
hardStop();
} catch (InterruptedException e) {
- LOG.debug("Interrupted while stopping [{}] after process ended", processId.getKey(), e);
+ LOG.debug("Interrupted while stopping [{}] after process ended", processId.getHumanReadableName(), e);
Thread.currentThread().interrupt();
}
}
@@ -278,7 +278,7 @@ public class ManagedProcessHandler {
// this name is different than Thread#toString(), which includes name, priority
// and thread group
// -> do not override toString()
- super(format("EventWatcher[%s]", processId.getKey()));
+ super(format("EventWatcher[%s]", processId.getHumanReadableName()));
}
@Override
diff --git a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessLifecycle.java b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessLifecycle.java
index 2bb67237683..f0d25cf2ed0 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessLifecycle.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/process/ManagedProcessLifecycle.java
@@ -91,7 +91,7 @@ public class ManagedProcessLifecycle {
res = true;
listeners.forEach(listener -> listener.onProcessState(processId, to));
}
- LOG.debug("{} tryToMoveTo {} from {} to {} => {}", Thread.currentThread().getName(), processId.getKey(), currentState, to, res);
+ LOG.debug("{} tryToMoveTo {} from {} to {} => {}", Thread.currentThread().getName(), processId.getHumanReadableName(), currentState, to, res);
return res;
}
}