Skip to content

Commit

Permalink
Service offline speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Aug 9, 2023
1 parent 93c3c66 commit 43fe49e
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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<CompletableFuture<Void>> futures = new LinkedList<>();
Collection<ProviderModel> providerModelList = serviceRepository.allProviderModels();
Expand All @@ -93,8 +92,6 @@ public boolean offline(String servicePattern) {
}
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
} finally {
executorService.shutdown();
}

return hasService;
Expand Down

0 comments on commit 43fe49e

Please sign in to comment.