Elffuss BraidHub

kikocis/java-driver public

Fix PoolingOptionsTest#should_refresh_single_connected_host()

Changed LimitingLoadBalancingPolicy to treat hosts passed in the
constructor as chosen hosts and pass to its delegate
LoadBalancingPolicy as hosts passed into the constructor this way are
to be set to up after LoadBalancingPolicy#init is called in
Cluster.Manager.init().
Changeset352fb5fbfd44701995a6203a9e431ef127a503d2742ae267417e155c99f18bf0
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-15 11:05 -06:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-15 11:07 -06:00
Parentsdd058c9e3c8f

Browse the files at this changeset

2 files changed

modified driver-core/src/test/java/com/datastax/driver/core/PoolingOptionsTest.java +1 −1
@@ -63,7 +63,7 @@
6363 .hasState(State.UP)
6464 .isAtDistance(HostDistance.LOCAL);
6565 assertThat(cluster).host(3)
66- .hasState(State.ADDED)
66+ .hasState(State.UP)
6767 .isAtDistance(HostDistance.IGNORED);
6868 assertThat(session).hasNoPoolFor(3);
6969
modified driver-core/src/test/java/com/datastax/driver/core/policies/LimitingLoadBalancingPolicy.java +7 −5
@@ -46,11 +46,13 @@
4646 @Override
4747 public void init(Cluster cluster, Collection<Host> hosts) {
4848 this.cluster = cluster;
49- for (Host host : hosts)
50- if (host.isUp())
51- this.liveHosts.add(host);
52- this.delegate.init(cluster, Collections.<Host>emptyList());
53- updateChosenHosts();
49+
50+ Iterator<Host> hostIt = hosts.iterator();
51+ while(hostIt.hasNext() && chosenHosts.size() <= maxHosts - threshold) {
52+ chosenHosts.add(hostIt.next());
53+ }
54+
55+ this.delegate.init(cluster, new ArrayList<Host>(chosenHosts));
5456 }
5557
5658 private void updateChosenHosts() {