adutra commented on code in PR #1896:
URL: 
https://github.com/apache/cassandra-java-driver/pull/1896#discussion_r1446225748


##########
core/src/main/java/com/datastax/oss/driver/internal/core/loadbalancing/BasicLoadBalancingPolicy.java:
##########
@@ -325,24 +338,63 @@ protected Queue<Node> maybeAddDcFailover(@Nullable 
Request request, @NonNull Que
 
           @Override
           protected Object[] computeNodes() {
-            Object[] remoteNodes =
-                liveNodes.dcs().stream()
-                    .filter(Predicates.not(Predicates.equalTo(localDc)))
-                    .flatMap(dc -> 
liveNodes.dc(dc).stream().limit(maxNodesPerRemoteDc))
-                    .toArray();
-
-            int remoteNodesLength = remoteNodes.length;
-            if (remoteNodesLength == 0) {
-              return EMPTY_NODES;
+            if (!preferredRemoteLocalDcs.isEmpty()) {

Review Comment:
   However I realize I owe you an apology: using `Arrays.binarySearch` is wrong 
because `preferredRemoteDcs` is not necessarily sorted. We need 
`preferredRemoteDcs` to become a `List<String>` again and use `indexOf` instead:
   
   ```java
   .sorted(
     Comparator.comparingInt(
         dc -> {
           int i = preferredRemoteDcs.indexOf(dc);
           return i < 0 ? Integer.MAX_VALUE : i;
         }))
   ```
   
   Sorry for that 😅 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to