diff --git a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java index c9d205a077..97761249bd 100644 --- a/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java +++ b/amoro-ams/src/main/java/org/apache/amoro/server/AmoroServiceContainer.java @@ -132,12 +132,10 @@ public static void main(String[] args) { service.waitLeaderShip(); service.startOptimizingService(); service.waitFollowerShip(); - // become follower, dispose optimizingService stop - service.stopOptimizingService(); } catch (Exception e) { LOG.error("AMS start error", e); } finally { - service.dispose(); + service.disposeOptimizingService(); } } } catch (Throwable t) { @@ -209,7 +207,7 @@ private void addHandlerChain(RuntimeHandlerChain chain) { } } - public void dispose() { + public void disposeOptimizingService() { if (tableManagementServer != null && tableManagementServer.isServing()) { LOG.info("Stopping table management server..."); tableManagementServer.stop(); @@ -218,6 +216,19 @@ public void dispose() { LOG.info("Stopping optimizing server..."); optimizingServiceServer.stop(); } + if (tableService != null) { + LOG.info("Stopping table service..."); + tableService.dispose(); + tableService = null; + } + if (optimizingService != null) { + LOG.info("Stopping optimizing service..."); + optimizingService.dispose(); + optimizingService = null; + } + } + + public void disposeRestService() { if (httpServer != null) { LOG.info("Stopping http server..."); try { @@ -226,22 +237,11 @@ public void dispose() { LOG.error("Error stopping http server", e); } } - if (tableService != null) { - LOG.info("Stopping table service..."); - tableService.dispose(); - tableService = null; - } if (terminalManager != null) { LOG.info("Stopping terminal manager..."); terminalManager.dispose(); terminalManager = null; } - if (optimizingService != null) { - LOG.info("Stopping optimizing service..."); - optimizingService.dispose(); - optimizingService = null; - } - if (amsServiceMetrics != null) { amsServiceMetrics.unregister(); } @@ -250,6 +250,11 @@ public void dispose() { MetricManager.dispose(); } + public void dispose() { + disposeOptimizingService(); + disposeRestService(); + } + private void initConfig() throws Exception { LOG.info("initializing configurations..."); new ConfigurationHelper().init();