From 43fe49ed47b76fcc2d6a98de2f9a4adc92fd2705 Mon Sep 17 00:00:00 2001 From: Albumen Kevin Date: Wed, 9 Aug 2023 11:14:29 +0800 Subject: [PATCH] Service offline speedup --- .../org/apache/dubbo/qos/command/impl/BaseOffline.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/BaseOffline.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/BaseOffline.java index 875866527dc..1eda8f6a768 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/BaseOffline.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/BaseOffline.java @@ -18,8 +18,8 @@ import org.apache.dubbo.common.logger.Logger; import org.apache.dubbo.common.logger.LoggerFactory; +import org.apache.dubbo.common.threadpool.manager.FrameworkExecutorRepository; import org.apache.dubbo.common.utils.ArrayUtils; -import org.apache.dubbo.common.utils.NamedThreadFactory; import org.apache.dubbo.qos.api.BaseCommand; import org.apache.dubbo.qos.api.CommandContext; import org.apache.dubbo.registry.Registry; @@ -35,14 +35,15 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; public class BaseOffline implements BaseCommand { private static final Logger logger = LoggerFactory.getLogger(BaseOffline.class); public FrameworkServiceRepository serviceRepository; + private ExecutorService executorService; public BaseOffline(FrameworkModel frameworkModel) { this.serviceRepository = frameworkModel.getServiceRepository(); + this.executorService = frameworkModel.getBeanFactory().getBean(FrameworkExecutorRepository.class).getSharedExecutor(); } @Override @@ -69,8 +70,6 @@ protected boolean doExecute(String servicePattern) { public boolean offline(String servicePattern) { boolean hasService = false; - ExecutorService executorService = Executors.newFixedThreadPool(200, new NamedThreadFactory("Dubbo-offline-processor", true)); - try { List> futures = new LinkedList<>(); Collection providerModelList = serviceRepository.allProviderModels(); @@ -93,8 +92,6 @@ public boolean offline(String servicePattern) { } } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); - } finally { - executorService.shutdown(); } return hasService;