kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 125b3d45cbd8853b53e50ef7d584fe8c4dfcfbbb6b7022840d882c0c448c8ab7 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-09 20:03 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-10 00:28 +01:00 |
| Parents | 5816920af92f |
3 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | - [bug] Rework connection reaper to avoid deadlock (JAVA-556) |
| 12 | 12 | - [bug] Avoid deadlock when multiple connections to the same host get write |
| 13 | 13 | errors (JAVA-557) |
| 14 | +- [improvement] Make shuffle=true the default for TokenAwarePolicy (JAVA-504) | |
| 14 | 15 | |
| 15 | 16 | |
| 16 | 17 | 2.0.8: |
modified driver-core/src/main/java/com/datastax/driver/core/policies/Policies.java +4 −0
| @@ -71,6 +71,10 @@ | ||
| 71 | 71 | * <p> |
| 72 | 72 | * The default load balancing policy is {@link DCAwareRoundRobinPolicy} with token |
| 73 | 73 | * 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. | |
| 74 | 78 | * |
| 75 | 79 | * @return the default load balancing policy. |
| 76 | 80 | */ |
modified driver-core/src/main/java/com/datastax/driver/core/policies/TokenAwarePolicy.java +11 −6
| @@ -55,10 +55,15 @@ | ||
| 55 | 55 | /** |
| 56 | 56 | * Creates a new {@code TokenAware} policy. |
| 57 | 57 | * |
| 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 | + * | |
| 62 | 67 | */ |
| 63 | 68 | public TokenAwarePolicy(LoadBalancingPolicy childPolicy, boolean shuffleReplicas) { |
| 64 | 69 | this.childPolicy = childPolicy; |
| @@ -66,7 +71,7 @@ | ||
| 66 | 71 | } |
| 67 | 72 | |
| 68 | 73 | /** |
| 69 | - * Creates a new {@code TokenAware} policy with no shuffling of replicas. | |
| 74 | + * Creates a new {@code TokenAware} policy with shuffling of replicas. | |
| 70 | 75 | * |
| 71 | 76 | * @param childPolicy the load balancing policy to wrap with token |
| 72 | 77 | * awareness. |
| @@ -74,7 +79,7 @@ | ||
| 74 | 79 | * @see #TokenAwarePolicy(LoadBalancingPolicy, boolean) |
| 75 | 80 | */ |
| 76 | 81 | public TokenAwarePolicy(LoadBalancingPolicy childPolicy) { |
| 77 | - this(childPolicy, false); | |
| 82 | + this(childPolicy, true); | |
| 78 | 83 | } |
| 79 | 84 | |
| 80 | 85 | @Override |