Skip to content

Commit

Permalink
Merge pull request #32 from Bouncheck/random-replica-ordering
Browse files Browse the repository at this point in the history
Switch to `ReplicaOrdering.RANDOM` for select LBPs
  • Loading branch information
CodeLieutenant authored Nov 19, 2024
2 parents 1be85b6 + c09fd08 commit 58ff646
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,25 @@ public JavaDriverClient(StressSettings settings, List<String> hosts, int port, E
private LoadBalancingPolicy loadBalancingPolicy(StressSettings settings)
{
LoadBalancingPolicy ret = null;
ReplicaOrdering replicaOrdering = null;

if (settings.node.rack != null) {
RackAwareRoundRobinPolicy.Builder policyBuilder = RackAwareRoundRobinPolicy.builder();
if (settings.node.datacenter != null)
policyBuilder.withLocalDc(settings.node.datacenter);
policyBuilder = policyBuilder.withLocalRack(settings.node.rack);
ret = policyBuilder.build();
replicaOrdering = ReplicaOrdering.NEUTRAL;
} else {
DCAwareRoundRobinPolicy.Builder policyBuilder = DCAwareRoundRobinPolicy.builder();
if (settings.node.datacenter != null)
policyBuilder.withLocalDc(settings.node.datacenter);
ret = policyBuilder.build();
replicaOrdering = ReplicaOrdering.RANDOM;
}
if (settings.node.isWhiteList)
ret = new WhiteListPolicy(ret, settings.node.resolveAll(settings.port.nativePort));
return new TokenAwarePolicy(ret, ReplicaOrdering.NEUTRAL);
return new TokenAwarePolicy(ret, replicaOrdering);
}

public PreparedStatement prepare(String query)
Expand Down

0 comments on commit 58ff646

Please sign in to comment.