Skip to content

Commit 19fa917

Browse files
paul-brackinBrianNichols
authored andcommitted
CLIENT-3603 Allow Replica.RANDOM on writes.
1 parent 0caeca5 commit 19fa917

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

client/src/com/aerospike/client/cluster/Cluster.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ public class Cluster implements Runnable, Closeable {
113113
// Password in hashed format in bytes.
114114
private byte[] passwordHash;
115115

116-
// Random node index.
116+
// Random node index counter.
117117
private final AtomicInteger nodeIndex;
118118

119-
// Random partition replica index.
119+
// Random partition replica index counter.
120120
final AtomicInteger replicaIndex;
121121

122122
// Count of connections in recover queue.

client/src/com/aerospike/client/cluster/Partition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ public Node getNodeWrite(Cluster cluster) {
207207

208208
case MASTER:
209209
case MASTER_PROLES:
210-
case RANDOM:
211210
return getMasterNode(cluster);
211+
case RANDOM:
212+
return cluster.getRandomNode();
212213
}
213214
}
214215

client/src/com/aerospike/client/policy/Replica.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 Aerospike, Inc.
2+
* Copyright 2012-2025 Aerospike, Inc.
33
*
44
* Portions may be licensed to Aerospike, Inc. under one or more contributor
55
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
@@ -49,11 +49,16 @@ public enum Replica {
4949
PREFER_RACK,
5050

5151
/**
52-
* Distribute reads across all nodes in cluster in round-robin fashion.
52+
* Distribute reads and writes across all nodes in cluster in round-robin fashion.
5353
* Writes always use node containing key's master partition.
5454
* <p>
55-
* This option is useful when the replication factor equals the number
55+
* This option is useful on reads when the replication factor equals the number
5656
* of nodes in the cluster and the overhead of requesting proles is not desired.
57+
* <p>
58+
* This option could temporarily be useful on writes when the client can't connect
59+
* to a node, but that node is reachable via a proxy from a different node.
60+
* <p>
61+
* This option can also be used to test server proxies.
5762
*/
5863
RANDOM;
5964
}

0 commit comments

Comments
 (0)