Skip to content

Commit

Permalink
[3.0] Patch DefaultApplicationDeployer for delay exporting (apache#9183)
Browse files Browse the repository at this point in the history
* synchronize at the entrance of getServiceExportExecutor

* remove useless codes

* format codes

* synchronize at the entrance of getServiceReferExecutor

* shutdown export,refer executor at destroyExecutorRepository
  • Loading branch information
zrlw authored Nov 4, 2021
1 parent d981788 commit c1f29cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,11 @@ public ExecutorService nextExecutorExecutor() {

@Override
public ScheduledExecutorService getServiceExportExecutor() {
if (serviceExportExecutor == null) {
synchronized (LOCK) {
if (serviceExportExecutor == null) {
int coreSize = getExportThreadNum();
serviceExportExecutor = Executors.newScheduledThreadPool(coreSize,
synchronized (LOCK) {
if (serviceExportExecutor == null) {
int coreSize = getExportThreadNum();
serviceExportExecutor = Executors.newScheduledThreadPool(coreSize,
new NamedThreadFactory("Dubbo-service-export", true));
}
}
}
return serviceExportExecutor;
Expand All @@ -241,13 +239,11 @@ public void shutdownServiceExportExecutor() {

@Override
public ExecutorService getServiceReferExecutor() {
if (serviceReferExecutor == null) {
synchronized (LOCK) {
if (serviceReferExecutor == null) {
int coreSize = getReferThreadNum();
serviceReferExecutor = Executors.newFixedThreadPool(coreSize,
synchronized (LOCK) {
if (serviceReferExecutor == null) {
int coreSize = getReferThreadNum();
serviceReferExecutor = Executors.newFixedThreadPool(coreSize,
new NamedThreadFactory("Dubbo-service-refer", true));
}
}
}
return serviceReferExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,9 +1013,6 @@ private void onStarted() {
} catch (Exception e) {
logger.error("refresh metadata failed: " + e.getMessage(), e);
}
// shutdown export/refer executor after started
executorRepository.shutdownServiceExportExecutor();
executorRepository.shutdownServiceReferExecutor();
} finally {
// complete future
completeStartFuture(true);
Expand Down Expand Up @@ -1057,6 +1054,9 @@ private void onStopped() {
}

private void destroyExecutorRepository() {
// shutdown export/refer executor
executorRepository.shutdownServiceExportExecutor();
executorRepository.shutdownServiceReferExecutor();
getExtensionLoader(ExecutorRepository.class).getDefaultExtension().destroyAll();
}

Expand Down

0 comments on commit c1f29cd

Please sign in to comment.