Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand All @@ -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();
}
Expand All @@ -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();
Expand Down