From d1b7b7fe1da734dbaedb805f31953a81927b85d8 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Fri, 3 May 2019 13:43:12 +0200 Subject: SONAR-12043 change restartDisabled to restarting for easier understanding this internal flag of class SchedulerImpl is easier to understand with this name --- .../src/main/java/org/sonar/application/SchedulerImpl.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 ad6f315c43c..9431f3a9565 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 @@ -56,7 +56,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi private final CountDownLatch awaitTermination = new CountDownLatch(1); private final AtomicBoolean firstWaitingEsLog = new AtomicBoolean(true); private final AtomicBoolean restartRequested = new AtomicBoolean(false); - private final AtomicBoolean restartDisabled = new AtomicBoolean(false); + private final AtomicBoolean restarting = new AtomicBoolean(false); private final EnumMap processesById = new EnumMap<>(ProcessId.class); private final AtomicInteger operationalCountDown = new AtomicInteger(); private final AtomicInteger stopCountDown = new AtomicInteger(0); @@ -191,9 +191,8 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi */ @Override public void hardStop() { - // disable ability to request for restart restartRequested.set(false); - restartDisabled.set(true); + restarting.set(false); if (nodeLifecycle.tryToMoveTo(NodeLifecycle.State.STOPPING)) { LOG.info("Stopping SonarQube"); @@ -222,6 +221,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi if (type == Type.OPERATIONAL) { onProcessOperational(processId); } else if (type == Type.ASK_FOR_RESTART && restartRequested.compareAndSet(false, true)) { + restarting.set(true); hardStopAsync(); } } @@ -245,7 +245,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi public void onProcessState(ProcessId processId, Lifecycle.State to) { switch (to) { case STOPPED: - onProcessHardStop(processId); + onProcessStop(processId); break; case STARTING: stopCountDown.incrementAndGet(); @@ -256,11 +256,10 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi } } - private void onProcessHardStop(ProcessId processId) { + private void onProcessStop(ProcessId processId) { LOG.info("Process [{}] is stopped", processId.getKey()); if (stopCountDown.decrementAndGet() == 0 && nodeLifecycle.tryToMoveTo(NodeLifecycle.State.STOPPED)) { - if (!restartDisabled.get() && - restartRequested.compareAndSet(true, false)) { + if (restarting.get() && restartRequested.compareAndSet(true, false)) { LOG.info("SonarQube is restarting"); restartAsync(); } else { -- cgit v1.2.3