kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | f34fbd38244733ba9474c48d2696371b13782d4964aa4f222c844bdc4d5f0925 |
|---|---|
| Author | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-25 17:42 +01:00 |
| Committer | Sylvain Lebresne <sylvain@datastax.com> · 2014-02-25 17:42 +01:00 |
| Parents | 4561005cff1a |
2 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -14,6 +14,8 @@ | ||
| 14 | 14 | - [bug] Use date string in query build to work-around CASSANDRA-6718 (JAVA-264) |
| 15 | 15 | - [bug] Always return the PreparedStatement object that is cache internally (JAVA-263) |
| 16 | 16 | - [bug] Fix race when multiple connect are done in parallel (JAVA-261) |
| 17 | +- [bug] Don't connect at all to nodes that are ignored by the load balancing | |
| 18 | + policy (JAVA-270) | |
| 17 | 19 | |
| 18 | 20 | |
| 19 | 21 | 1.0.5: |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +17 −1
| @@ -1020,6 +1020,23 @@ | ||
| 1020 | 1020 | if (isShutdown.get()) |
| 1021 | 1021 | return; |
| 1022 | 1022 | |
| 1023 | + // Adds to the load balancing first and foremost, as doing so might change the decision | |
| 1024 | + // it will make for distance() on that node (not likely but we leave that possibility). | |
| 1025 | + // This does mean the policy may start returning that node for query plan, but as long | |
| 1026 | + // as no pools have been created (below) this will be ignored by RequestHandler so it's fine. | |
| 1027 | + loadBalancingPolicy().onAdd(host); | |
| 1028 | + | |
| 1029 | + // Next, if the host should be ignored, well, ignore it. | |
| 1030 | + if (loadBalancingPolicy().distance(host) == HostDistance.IGNORED) { | |
| 1031 | + // We still mark the node UP though as it should be (and notifiy the listeners). | |
| 1032 | + // We'll mark it down if we have a notification anyway and we've documented that especially | |
| 1033 | + // for IGNORED hosts, the isUp() method was a best effort guess | |
| 1034 | + host.setUp(); | |
| 1035 | + for (Host.StateListener listener : listeners) | |
| 1036 | + listener.onAdd(host); | |
| 1037 | + return; | |
| 1038 | + } | |
| 1039 | + | |
| 1023 | 1040 | try { |
| 1024 | 1041 | prepareAllQueries(host); |
| 1025 | 1042 | } catch (InterruptedException e) { |
| @@ -1027,7 +1044,6 @@ | ||
| 1027 | 1044 | // Don't propagate because we don't want to prevent other listener to run |
| 1028 | 1045 | } |
| 1029 | 1046 | |
| 1030 | - loadBalancingPolicy().onAdd(host); | |
| 1031 | 1047 | controlConnection.onAdd(host); |
| 1032 | 1048 | |
| 1033 | 1049 | List<ListenableFuture<Boolean>> futures = new ArrayList<ListenableFuture<Boolean>>(sessions.size()); |