kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 352fb5fbfd44701995a6203a9e431ef127a503d2742ae267417e155c99f18bf0 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-15 11:05 -06:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-15 11:07 -06:00 |
| Parents | dd058c9e3c8f |
2 files changed
modified driver-core/src/test/java/com/datastax/driver/core/PoolingOptionsTest.java +1 −1
| @@ -63,7 +63,7 @@ | ||
| 63 | 63 | .hasState(State.UP) |
| 64 | 64 | .isAtDistance(HostDistance.LOCAL); |
| 65 | 65 | assertThat(cluster).host(3) |
| 66 | - .hasState(State.ADDED) | |
| 66 | + .hasState(State.UP) | |
| 67 | 67 | .isAtDistance(HostDistance.IGNORED); |
| 68 | 68 | assertThat(session).hasNoPoolFor(3); |
| 69 | 69 |
modified driver-core/src/test/java/com/datastax/driver/core/policies/LimitingLoadBalancingPolicy.java +7 −5
| @@ -46,11 +46,13 @@ | ||
| 46 | 46 | @Override |
| 47 | 47 | public void init(Cluster cluster, Collection<Host> hosts) { |
| 48 | 48 | 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)); | |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | private void updateChosenHosts() { |