kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | b1c77be54e84d44e159fc06f072fc17a7ca41184869677aa17c0ea9f42f4ba77 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2014-12-15 18:15 +01:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2014-12-15 18:15 +01:00 |
| Parents | 54d271b1655c, 352fb5fbfd44 |
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() { |