File tree Expand file tree Collapse file tree
src/main/java/com/datastax/driver/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ CHANGELOG
1414- [bug] Use date string in query build to work-around CASSANDRA-6718 (JAVA-264)
1515- [bug] Always return the PreparedStatement object that is cache internally (JAVA-263)
1616- [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)
1719
1820
19211.0.5:
Original file line number Diff line number Diff line change @@ -1020,14 +1020,30 @@ public void onAdd(final Host host) {
10201020 if (isShutdown .get ())
10211021 return ;
10221022
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+
10231040 try {
10241041 prepareAllQueries (host );
10251042 } catch (InterruptedException e ) {
10261043 Thread .currentThread ().interrupt ();
10271044 // Don't propagate because we don't want to prevent other listener to run
10281045 }
10291046
1030- loadBalancingPolicy ().onAdd (host );
10311047 controlConnection .onAdd (host );
10321048
10331049 List <ListenableFuture <Boolean >> futures = new ArrayList <ListenableFuture <Boolean >>(sessions .size ());
You can’t perform that action at this time.
0 commit comments