Elffuss BraidHub

kikocis/java-driver public

JAVA-630: Don't process DOWN events for nodes that have active connections.

(cherry picked from 2.1)
Changeset34f2d0656c1d43ab57c95d4de2dff6beb2bb06f6aae0f1828888c68148201785
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2016-02-23 18:09 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2016-03-31 16:37 +02:00
Parents65477c3e8004

Browse the files at this changeset

3 files changed

modified changelog/README.md +1 −0
@@ -5,6 +5,7 @@
55 Merged from 2.1 branch:
66
77 - [improvement] JAVA-1011: Expose PoolingOptions default values.
8+- [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections.
89
910
1011 ### 3.0.0
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +11 −7
@@ -2638,8 +2638,16 @@
26382638 // But it is unlikely, and don't have too much consequence since we'll try reconnecting
26392639 // right away, so we favor the detection to make the Host.isUp method more reliable.
26402640 Host downHost = metadata.getHost(address);
2641- if (downHost != null)
2642- futures.add(execute(hostDown(downHost)));
2641+ if (downHost != null) {
2642+ // Only process DOWN events if we have no active connections to the host . Otherwise, we
2643+ // wait for the connections to fail. This is to prevent against a bad control host
2644+ // aggressively marking DOWN all of its peers.
2645+ if (downHost.convictionPolicy.hasActiveConnections()) {
2646+ logger.debug("Ignoring down event on {} because it still has active connections", downHost);
2647+ } else {
2648+ futures.add(execute(hostDown(downHost)));
2649+ }
2650+ }
26432651 break;
26442652 case REMOVED:
26452653 Host removedHost = metadata.getHost(address);
@@ -2720,11 +2728,7 @@
27202728 return new ExceptionCatchingRunnable() {
27212729 @Override
27222730 public void runMayThrow() throws Exception {
2723- if (controlConnection.refreshNodeInfo(host)) {
2724- onDown(host, false, true);
2725- } else {
2726- logger.debug("Not enough info for {}, ignoring host", host);
2727- }
2731+ onDown(host, false, true);
27282732 }
27292733 };
27302734 }
modified driver-core/src/main/java/com/datastax/driver/core/ConvictionPolicy.java +7 −0
@@ -53,6 +53,8 @@
5353
5454 abstract boolean canReconnectNow();
5555
56+ abstract boolean hasActiveConnections();
57+
5658 /**
5759 * Simple factory interface to allow creating {@link ConvictionPolicy} instances.
5860 */
@@ -132,6 +134,11 @@
132134 return canReconnectNow;
133135 }
134136
137+ @Override
138+ boolean hasActiveConnections() {
139+ return openConnections.get() > 0;
140+ }
141+
135142 static class Factory implements ConvictionPolicy.Factory {
136143
137144 @Override