Elffuss BraidHub

kikocis/java-driver public

Ensure control connection reconnects when control host is removed (JAVA-597).
Changeset091573a394239bbdb37edd748b38810994c1e12455b0b6afeb738140c2d0ba79
Authorolim7t <omichallat+github@gmail.com> · 2014-12-21 16:52 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-12-21 16:54 +01:00
Parents43c7e4b6378c

Browse the files at this changeset

2 files changed

modified driver-core/CHANGELOG.rst +2 −0
@@ -21,6 +21,8 @@
2121 (JAVA-593)
2222 - [bug] Ensure state change notifications for a given host are handled serially
2323 (JAVA-594)
24+- [bug] Ensure control connection reconnects when control host is removed
25+ (JAVA-597)
2426
2527
2628 2.0.8:
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +12 −3
@@ -161,9 +161,9 @@
161161
162162 private void signalError() {
163163 Connection connection = connectionRef.get();
164- if (connection != null && connection.isDefunct()) {
165- // If the connection was marked as defunct, this already reported the
166- // node down, which will trigger a reconnect.
164+ if (connection != null && connection.isDefunct() && cluster.metadata.getHost(connection.address) != null) {
165+ // If the connection was marked as defunct and the host hadn't left, this already reported the
166+ // host down, which will trigger a reconnect.
167167 return;
168168 }
169169 // If the connection is not defunct, or the host has left, just reconnect manually
@@ -669,6 +669,15 @@
669669
670670 @Override
671671 public void onRemove(Host host) {
672+ Connection current = connectionRef.get();
673+ if (logger.isDebugEnabled())
674+ logger.debug("[Control connection] {} has been removed, currently connected to {}", host, current == null ? "nobody" : current.address);
675+
676+ // Schedule a reconnection if that was our control host
677+ if (current != null && current.address.equals(host.getSocketAddress())) {
678+ backgroundReconnect(0);
679+ }
680+
672681 refreshNodeListAndTokenMap();
673682 }
674683 }