fixup! Remove DB related modules
parent
0c30568b3f
commit
627a9cbb84
|
|
@ -16,7 +16,9 @@ import static org.eclipse.che.api.system.shared.SystemStatus.PREPARING_TO_SHUTDO
|
||||||
import static org.eclipse.che.api.system.shared.SystemStatus.READY_TO_SHUTDOWN;
|
import static org.eclipse.che.api.system.shared.SystemStatus.READY_TO_SHUTDOWN;
|
||||||
import static org.eclipse.che.api.system.shared.SystemStatus.RUNNING;
|
import static org.eclipse.che.api.system.shared.SystemStatus.RUNNING;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
import jakarta.annotation.PreDestroy;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
@ -143,4 +145,14 @@ public class SystemManager {
|
||||||
shutdownLatch.countDown();
|
shutdownLatch.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreDestroy
|
||||||
|
@VisibleForTesting
|
||||||
|
void shutdown() throws InterruptedException {
|
||||||
|
if (!statusRef.compareAndSet(RUNNING, PREPARING_TO_SHUTDOWN)) {
|
||||||
|
shutdownLatch.await();
|
||||||
|
} else {
|
||||||
|
doSuspendServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,21 @@ public class SystemManagerTest {
|
||||||
systemManager.stopServices();
|
systemManager.stopServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shutdownDoesNotFailIfServicesAreAlreadyStopped() throws Exception {
|
||||||
|
systemManager.stopServices();
|
||||||
|
systemManager.shutdown();
|
||||||
|
|
||||||
|
verifyShutdownCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shutdownStopsServicesIfNotStopped() throws Exception {
|
||||||
|
systemManager.shutdown();
|
||||||
|
|
||||||
|
verifySuspendCompleted();
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyShutdownCompleted() throws InterruptedException {
|
private void verifyShutdownCompleted() throws InterruptedException {
|
||||||
verify(terminator, timeout(2000)).terminateAll();
|
verify(terminator, timeout(2000)).terminateAll();
|
||||||
verifyEvents();
|
verifyEvents();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue