Elffuss BraidHub

kikocis/java-driver public

Make shuffle=true the default for TokenAwarePolicy (JAVA-504).
Changeset125b3d45cbd8853b53e50ef7d584fe8c4dfcfbbb6b7022840d882c0c448c8ab7
Authorolim7t <omichallat+github@gmail.com> · 2014-12-09 20:03 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-12-10 00:28 +01:00
Parents5816920af92f

Browse the files at this changeset

3 files changed

modified driver-core/CHANGELOG.rst +1 −0
@@ -11,6 +11,7 @@
1111 - [bug] Rework connection reaper to avoid deadlock (JAVA-556)
1212 - [bug] Avoid deadlock when multiple connections to the same host get write
1313 errors (JAVA-557)
14+- [improvement] Make shuffle=true the default for TokenAwarePolicy (JAVA-504)
1415
1516
1617 2.0.8:
modified driver-core/src/main/java/com/datastax/driver/core/policies/Policies.java +4 −0
@@ -71,6 +71,10 @@
7171 * <p>
7272 * The default load balancing policy is {@link DCAwareRoundRobinPolicy} with token
7373 * awareness (so {@code new TokenAwarePolicy(new DCAwareRoundRobinPolicy())}).
74+ * <p>
75+ * Note that this policy shuffles the replicas when token awareness is used, see
76+ * {@link TokenAwarePolicy#TokenAwarePolicy(LoadBalancingPolicy,boolean)} for an
77+ * explanation of the tradeoffs.
7478 *
7579 * @return the default load balancing policy.
7680 */
modified driver-core/src/main/java/com/datastax/driver/core/policies/TokenAwarePolicy.java +11 −6
@@ -55,10 +55,15 @@
5555 /**
5656 * Creates a new {@code TokenAware} policy.
5757 *
58- * @param childPolicy the load balancing policy to wrap with token
59- * awareness.
60- * @param shuffleReplicas whether to shuffle the replicas returned
61- * by {@code getRoutingKey}.
58+ * @param childPolicy the load balancing policy to wrap with token awareness.
59+ * @param shuffleReplicas whether to shuffle the replicas returned by {@code getRoutingKey}.
60+ * Note that setting this parameter to {@code true} might decrease the
61+ * effectiveness of caching (especially at consistency level ONE), since
62+ * the same row will be retrieved from any replica (instead of only the
63+ * "primary" replica without shuffling).
64+ * On the other hand, shuffling will better distribute writes, and can
65+ * alleviate hotspots caused by "fat" partitions.
66+ *
6267 */
6368 public TokenAwarePolicy(LoadBalancingPolicy childPolicy, boolean shuffleReplicas) {
6469 this.childPolicy = childPolicy;
@@ -66,7 +71,7 @@
6671 }
6772
6873 /**
69- * Creates a new {@code TokenAware} policy with no shuffling of replicas.
74+ * Creates a new {@code TokenAware} policy with shuffling of replicas.
7075 *
7176 * @param childPolicy the load balancing policy to wrap with token
7277 * awareness.
@@ -74,7 +79,7 @@
7479 * @see #TokenAwarePolicy(LoadBalancingPolicy, boolean)
7580 */
7681 public TokenAwarePolicy(LoadBalancingPolicy childPolicy) {
77- this(childPolicy, false);
82+ this(childPolicy, true);
7883 }
7984
8085 @Override