Fix shutdown sequence
Fix a few issues in shutdown sequence and make sure scheduler shutdown without invoking run works Inorder for the main thread to shutdown, the scheduler's final shutdown still needs to be invoked, which only happens via the run method.
This commit is contained in:
parent
037dd7f6c8
commit
6acb51d66e
4 changed files with 13 additions and 2 deletions
|
|
@ -120,6 +120,11 @@
|
||||||
<artifactId>http-client-spi</artifactId>
|
<artifactId>http-client-spi</artifactId>
|
||||||
<version>${awssdk.version}</version>
|
<version>${awssdk.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
|
<artifactId>dynamodb-enhanced</artifactId>
|
||||||
|
<version>${awssdk.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>software.amazon.glue</groupId>
|
<groupId>software.amazon.glue</groupId>
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,9 @@ public final class DynamicMigrationComponentsInitializer {
|
||||||
workerMetricsThreadPool.shutdown();
|
workerMetricsThreadPool.shutdown();
|
||||||
try {
|
try {
|
||||||
if (!lamThreadPool.awaitTermination(SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
if (!lamThreadPool.awaitTermination(SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
||||||
|
log.info(
|
||||||
|
"LamThreadPool did not shutdown in {}s, forcefully shutting down",
|
||||||
|
SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS);
|
||||||
lamThreadPool.shutdownNow();
|
lamThreadPool.shutdownNow();
|
||||||
}
|
}
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
|
|
@ -232,6 +235,9 @@ public final class DynamicMigrationComponentsInitializer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!workerMetricsThreadPool.awaitTermination(SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
if (!workerMetricsThreadPool.awaitTermination(SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
||||||
|
log.info(
|
||||||
|
"WorkerMetricsThreadPool did not shutdown in {}s, forcefully shutting down",
|
||||||
|
SCHEDULER_SHUTDOWN_TIMEOUT_SECONDS);
|
||||||
workerMetricsThreadPool.shutdownNow();
|
workerMetricsThreadPool.shutdownNow();
|
||||||
}
|
}
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class MigrationClientVersion3xWithRollbackState implements MigrationClien
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void leave() {
|
public synchronized void leave() {
|
||||||
if (entered && !left) {
|
if (entered && !left) {
|
||||||
log.info("Leaving {}", this);
|
log.info("Leaving {}", this);
|
||||||
cancelRollbackMonitor();
|
cancelRollbackMonitor();
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ public class MigrationStateMachineImpl implements MigrationStateMachine {
|
||||||
if (!stateMachineThreadPool.isShutdown()) {
|
if (!stateMachineThreadPool.isShutdown()) {
|
||||||
stateMachineThreadPool.shutdown();
|
stateMachineThreadPool.shutdown();
|
||||||
try {
|
try {
|
||||||
if (stateMachineThreadPool.awaitTermination(THREAD_POOL_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
if (!stateMachineThreadPool.awaitTermination(THREAD_POOL_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
||||||
log.info(
|
log.info(
|
||||||
"StateMachineThreadPool did not shutdown within {} seconds, forcefully shutting down",
|
"StateMachineThreadPool did not shutdown within {} seconds, forcefully shutting down",
|
||||||
THREAD_POOL_SHUTDOWN_TIMEOUT_SECONDS);
|
THREAD_POOL_SHUTDOWN_TIMEOUT_SECONDS);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue