kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 650b8bbe497a395b9b54fd67631866fdded2cebc8098ac9623afa3dc67d39c05 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-03 22:50 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-12 11:46 -07:00 |
| Parents | cd12beaa38c0 |
5 files changed
modified driver-core/CHANGELOG.rst +1 −0
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | - [bug] Fix negative HostConnectionPool open count (JAVA-349) |
| 14 | 14 | - [improvement] Log more connection details at trace and debug levels (JAVA-436) |
| 15 | 15 | - [bug] Fix cluster shutdown (JAVA-445) |
| 16 | +- [improvement] Expose child policy in chainable load balancing policies (JAVA-439) | |
| 16 | 17 | |
| 17 | 18 | 2.0.5: |
| 18 | 19 | ------ |
added driver-core/src/main/java/com/datastax/driver/core/policies/ChainableLoadBalancingPolicy.java +28 −0
| @@ -0,0 +1,28 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2014 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.policies; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * A load balancing policy that wraps another policy. | |
| 20 | + */ | |
| 21 | +public interface ChainableLoadBalancingPolicy extends LoadBalancingPolicy { | |
| 22 | + /** | |
| 23 | + * Returns the child policy. | |
| 24 | + * | |
| 25 | + * @return the child policy. | |
| 26 | + */ | |
| 27 | + LoadBalancingPolicy getChildPolicy(); | |
| 28 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/policies/LatencyAwarePolicy.java +6 −1
| @@ -57,7 +57,7 @@ | ||
| 57 | 57 | * |
| 58 | 58 | * @since 1.0.4 |
| 59 | 59 | */ |
| 60 | -public class LatencyAwarePolicy implements LoadBalancingPolicy { | |
| 60 | +public class LatencyAwarePolicy implements ChainableLoadBalancingPolicy { | |
| 61 | 61 | |
| 62 | 62 | private static final Logger logger = LoggerFactory.getLogger(LatencyAwarePolicy.class); |
| 63 | 63 | |
| @@ -87,6 +87,11 @@ | ||
| 87 | 87 | updaterService.scheduleAtFixedRate(new Updater(), updateRate, updateRate, TimeUnit.NANOSECONDS); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | + @Override | |
| 91 | + public LoadBalancingPolicy getChildPolicy() { | |
| 92 | + return childPolicy; | |
| 93 | + } | |
| 94 | + | |
| 90 | 95 | /** |
| 91 | 96 | * Creates a new latency aware policy builder given the child policy |
| 92 | 97 | * that the resulting policy should wrap. |
modified driver-core/src/main/java/com/datastax/driver/core/policies/TokenAwarePolicy.java +6 −1
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | * token aware policy, replicas from remote data centers may only be |
| 47 | 47 | * returned after all the host of the local data center. |
| 48 | 48 | */ |
| 49 | -public class TokenAwarePolicy implements LoadBalancingPolicy { | |
| 49 | +public class TokenAwarePolicy implements ChainableLoadBalancingPolicy { | |
| 50 | 50 | |
| 51 | 51 | private final LoadBalancingPolicy childPolicy; |
| 52 | 52 | private Metadata clusterMetadata; |
| @@ -62,6 +62,11 @@ | ||
| 62 | 62 | this.childPolicy = childPolicy; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + @Override | |
| 66 | + public LoadBalancingPolicy getChildPolicy() { | |
| 67 | + return childPolicy; | |
| 68 | + } | |
| 69 | + | |
| 65 | 70 | @Override |
| 66 | 71 | public void init(Cluster cluster, Collection<Host> hosts) { |
| 67 | 72 | clusterMetadata = cluster.getMetadata(); |
modified driver-core/src/main/java/com/datastax/driver/core/policies/WhiteListPolicy.java +6 −1
| @@ -47,7 +47,7 @@ | ||
| 47 | 47 | * data-center then you should use DCAwareRoundRobinPolicy and *not* this policy |
| 48 | 48 | * in particular. |
| 49 | 49 | */ |
| 50 | -public class WhiteListPolicy implements LoadBalancingPolicy { | |
| 50 | +public class WhiteListPolicy implements ChainableLoadBalancingPolicy { | |
| 51 | 51 | private final LoadBalancingPolicy childPolicy; |
| 52 | 52 | private final Set<InetSocketAddress> whiteList; |
| 53 | 53 | |
| @@ -64,6 +64,11 @@ | ||
| 64 | 64 | this.whiteList = ImmutableSet.copyOf(whiteList); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + @Override | |
| 68 | + public LoadBalancingPolicy getChildPolicy() { | |
| 69 | + return childPolicy; | |
| 70 | + } | |
| 71 | + | |
| 67 | 72 | /** |
| 68 | 73 | * Initialize this load balancing policy. |
| 69 | 74 | * |