diff --git a/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java b/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java index ef76e24c65..92f0dff2b9 100644 --- a/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java +++ b/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java @@ -201,7 +201,11 @@ public void dispose() { terminalManager.dispose(); terminalManager = null; } - optimizingService = null; + if (optimizingService != null) { + LOG.info("Stopping optimizing service..."); + optimizingService.dispose(); + optimizingService = null; + } if (amsServiceMetrics != null) { amsServiceMetrics.unregister(); diff --git a/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java b/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java index 3a51b30b40..d77b7f9170 100644 --- a/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java +++ b/amoro-ams/amoro-ams-server/src/main/java/org/apache/amoro/server/DefaultOptimizingService.java @@ -69,7 +69,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.DelayQueue; import java.util.concurrent.Delayed; -import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; @@ -99,7 +99,7 @@ public class DefaultOptimizingService extends StatedPersistentBase private final OptimizerKeeper optimizerKeeper = new OptimizerKeeper(); private final TableService tableService; private final RuntimeHandlerChain tableHandlerChain; - private final Executor planExecutor; + private final ExecutorService planExecutor; public DefaultOptimizingService(Configurations serviceConfig, DefaultTableService tableService) { this.optimizerTouchTimeout = serviceConfig.getLong(AmoroManagementConf.OPTIMIZER_HB_TIMEOUT); @@ -385,6 +385,7 @@ public void dispose() { optimizingQueueByGroup.clear(); optimizingQueueByToken.clear(); authOptimizers.clear(); + planExecutor.shutdown(); } public boolean canDeleteResourceGroup(String name) {