File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
driver-core/src/main/java/com/datastax/driver/core/policies Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public static Builder builder() {
7878 new CopyOnWriteArrayList <Host >();
7979 private final CopyOnWriteArrayList <Host > liveHostsRemoteRacksLocalDC =
8080 new CopyOnWriteArrayList <Host >();
81- private final AtomicInteger index = new AtomicInteger ();
81+ @ VisibleForTesting final AtomicInteger index = new AtomicInteger ();
8282
8383 @ VisibleForTesting volatile String localDc ;
8484 @ VisibleForTesting volatile String localRack ;
@@ -205,7 +205,13 @@ private static CopyOnWriteArrayList<Host> cloneList(CopyOnWriteArrayList<Host> l
205205 @ Override
206206 public HostDistance distance (Host host ) {
207207 String dc = dc (host );
208- if (dc == UNSET || dc .equals (localDc )) return HostDistance .LOCAL ;
208+ String rack = rack (host );
209+ if (dc == UNSET || dc .equals (localDc )) {
210+ if (rack == UNSET || rack .equals (localRack )) {
211+ return HostDistance .LOCAL ;
212+ }
213+ return HostDistance .REMOTE ;
214+ }
209215
210216 CopyOnWriteArrayList <Host > dcHosts = perDcLiveHosts .get (dc );
211217 if (dcHosts == null || usedHostsPerRemoteDc == 0 ) return HostDistance .IGNORED ;
You can’t perform that action at this time.
0 commit comments