Skip to content
Closed
Show file tree
Hide file tree
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 @@ -126,11 +126,14 @@ public static void main(String[] args) {
service.dispose();
LOG.info("AMS service has been shut down");
}));
service.startRestServices();
while (true) {
try {
service.waitLeaderShip();
service.startService();
service.startOptimizingService();
service.waitFollowerShip();
// become follower, dispose optimizingService stop
service.stopOptimizingService();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you put this in service.dispose? or you may change service.dispose in finally block to service.stopOptimizingService ???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dispose will be close all service (include rest) .if this node become follower,we just close optimizingService,and will be run waitting become Leader service.waitLeaderShip()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the finally block will dispose all services. so you should use stopOptimizingService to repalce dsipose in finally block ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the dispose process will close the rest service. It should be fixed.

I open a PR to fix it: czy006#2
@czy006 You can checkout it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I am using the new logic to verify it, which will take some time. At the same time, we are designing a more general high-availability solution, which will support K8S in the future and will be launched later. cc @Aireed @zhoujinsong @klion26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great! Look forward it!

} catch (Exception e) {
LOG.error("AMS start error", e);
} finally {
Expand All @@ -143,6 +146,14 @@ public static void main(String[] args) {
}
}

private void stopOptimizingService() {
if (optimizingService != null) {
LOG.info("AMS Become follower and Stopping optimizing service...");
optimizingService.dispose();
optimizingService = null;
}
}

public void waitLeaderShip() throws Exception {
haContainer.waitLeaderShip();
}
Expand All @@ -151,14 +162,21 @@ public void waitFollowerShip() throws Exception {
haContainer.waitFollowerShip();
}

public void startService() throws Exception {
public void startRestServices() throws Exception {
EventsManager.getInstance();
MetricManager.getInstance();

catalogManager = new DefaultCatalogManager(serviceConfig);
tableManager = new DefaultTableManager(serviceConfig, catalogManager);
optimizerManager = new DefaultOptimizerManager(serviceConfig, catalogManager);
terminalManager = new TerminalManager(serviceConfig, catalogManager);

initHttpService();
startHttpService();
registerAmsServiceMetric();
}

public void startOptimizingService() throws Exception {
tableService = new DefaultTableService(serviceConfig, catalogManager);

optimizingService =
Expand All @@ -180,14 +198,9 @@ public void startService() throws Exception {
tableService.initialize();
LOG.info("AMS table service have been initialized");
tableManager.setTableService(tableService);
terminalManager = new TerminalManager(serviceConfig, catalogManager);

initThriftService();
startThriftService();

initHttpService();
startHttpService();
registerAmsServiceMetric();
}

private void addHandlerChain(RuntimeHandlerChain chain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ private void startAms() throws Exception {
serviceConfig.set(
AmoroManagementConf.REFRESH_EXTERNAL_CATALOGS_INTERVAL,
Duration.ofMillis(1000L));
serviceContainer.startService();
serviceContainer.startRestServices();
serviceContainer.startOptimizingService();
break;
} catch (TTransportException e) {
if (e.getCause() instanceof BindException) {
Expand Down