You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/12/05 05:55:08 UTC

[GitHub] [dubbo] CrazyHZM commented on a diff in pull request #11063: 【fix】forking cluster

CrazyHZM commented on code in PR #11063:
URL: https://github.com/apache/dubbo/pull/11063#discussion_r1039155346


##########
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java:
##########
@@ -29,11 +29,9 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;

Review Comment:
   Please fix code style



##########
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ForkingClusterInvoker.java:
##########
@@ -83,26 +81,29 @@ public Result doInvoke(final Invocation invocation, List<Invoker<T>> invokers, L
             }
             RpcContext.getServiceContext().setInvokers((List) selected);
             final AtomicInteger count = new AtomicInteger();
-            final BlockingQueue<Object> ref = new LinkedBlockingQueue<>(1);
-            for (final Invoker<T> invoker : selected) {
+            final CountDownLatch countDownLatch = new CountDownLatch(1);
+            AtomicReference<Object> result = new AtomicReference<>();
+            selected.forEach(invoker -> {

Review Comment:
   It looks like `CompletableFuture.anyOf` can satisfy this requirement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org