Elffuss BraidHub

kikocis/java-driver public

Merge pull request #595 from datastax/java630

JAVA-630: Don't process DOWN events for nodes that have active connec…
Changeset4e3df79bd0504f5f3e2609a578593e5e46d196497a1d7cf11403b388dbd7b6b9
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2016-02-23 18:09 +01:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2016-02-23 18:09 +01:00
Parents13ff5c33b0a0, 65e685d3eeef

Browse the files at this changeset

3 files changed

modified changelog/README.md +1 −0
@@ -13,6 +13,7 @@
1313 - [improvement] JAVA-843: Disable frozen checks in mapper.
1414 - [improvement] JAVA-833: Improve message when a nested type can't be serialized.
1515 - [improvement] JAVA-1011: Expose PoolingOptions default values.
16+- [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections.
1617
1718 Merged from 2.0 branch:
1819
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +11 −7
@@ -2625,8 +2625,16 @@
26252625 // But it is unlikely, and don't have too much consequence since we'll try reconnecting
26262626 // right away, so we favor the detection to make the Host.isUp method more reliable.
26272627 Host downHost = metadata.getHost(address);
2628- if (downHost != null)
2629- futures.add(execute(hostDown(downHost)));
2628+ if (downHost != null) {
2629+ // Only process DOWN events if we have no active connections to the host . Otherwise, we
2630+ // wait for the connections to fail. This is to prevent against a bad control host
2631+ // aggressively marking DOWN all of its peers.
2632+ if (downHost.convictionPolicy.hasActiveConnections()) {
2633+ logger.debug("Ignoring down event on {} because it still has active connections", downHost);
2634+ } else {
2635+ futures.add(execute(hostDown(downHost)));
2636+ }
2637+ }
26302638 break;
26312639 case REMOVED:
26322640 Host removedHost = metadata.getHost(address);
@@ -2702,11 +2710,7 @@
27022710 return new ExceptionCatchingRunnable() {
27032711 @Override
27042712 public void runMayThrow() throws Exception {
2705- if (controlConnection.refreshNodeInfo(host)) {
2706- onDown(host, false, true);
2707- } else {
2708- logger.debug("Not enough info for {}, ignoring host", host);
2709- }
2713+ onDown(host, false, true);
27102714 }
27112715 };
27122716 }
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