fixup! Remove DB related modules

pull/630/head
ivinokur 2024-01-22 15:57:26 +02:00
parent 0c30568b3f
commit 627a9cbb84
2 changed files with 27 additions and 0 deletions

View File

@ -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.RUNNING;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import jakarta.annotation.PreDestroy;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -143,4 +145,14 @@ public class SystemManager {
shutdownLatch.countDown();
}
}
@PreDestroy
@VisibleForTesting
void shutdown() throws InterruptedException {
if (!statusRef.compareAndSet(RUNNING, PREPARING_TO_SHUTDOWN)) {
shutdownLatch.await();
} else {
doSuspendServices();
}
}
}

View File

@ -80,6 +80,21 @@ public class SystemManagerTest {
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 {
verify(terminator, timeout(2000)).terminateAll();
verifyEvents();