Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.0' into 2.1
Changesetff3be45397085809c8de3b8fa84a804a06105d5fb4b15dbe5606657a81edad6d
Authorolim7t <omichallat+github@gmail.com> · 2014-12-21 17:33 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-12-21 17:37 +01:00
Parents08e9c0652731, 091573a39423

Browse the files at this changeset

2 files changed

modified driver-core/CHANGELOG.rst +4 −0
@@ -23,6 +23,8 @@
2323 (JAVA-593)
2424 - [bug] Ensure state change notifications for a given host are handled serially
2525 (JAVA-594)
26+- [bug] Ensure control connection reconnects when control host is removed
27+ (JAVA-597)
2628
2729
2830 2.1.3:
@@ -167,6 +169,8 @@
167169 (JAVA-593)
168170 - [bug] Ensure state change notifications for a given host are handled serially
169171 (JAVA-594)
172+- [bug] Ensure control connection reconnects when control host is removed
173+ (JAVA-597)
170174
171175
172176 2.0.8:
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +15 −3
@@ -110,6 +110,9 @@
110110 // reconnectInternal only propagate those if we've not decided on the protocol version yet,
111111 // which should only happen on the initial connection and thus in connect() but never here.
112112 throw new AssertionError();
113+ } catch (Exception e) {
114+ logger.error("[Control connection] Unknown error during reconnection, scheduling retry", e);
115+ backgroundReconnect(-1);
113116 }
114117 }
115118
@@ -159,9 +162,9 @@
159162
160163 private void signalError() {
161164 Connection connection = connectionRef.get();
162- if (connection != null && connection.isDefunct()) {
163- // If the connection was marked as defunct, this already reported the
164- // node down, which will trigger a reconnect.
165+ if (connection != null && connection.isDefunct() && cluster.metadata.getHost(connection.address) != null) {
166+ // If the connection was marked as defunct and the host hadn't left, this already reported the
167+ // host down, which will trigger a reconnect.
165168 return;
166169 }
167170 // If the connection is not defunct, or the host has left, just reconnect manually
@@ -691,6 +694,15 @@
691694
692695 @Override
693696 public void onRemove(Host host) {
697+ Connection current = connectionRef.get();
698+ if (logger.isDebugEnabled())
699+ logger.debug("[Control connection] {} has been removed, currently connected to {}", host, current == null ? "nobody" : current.address);
700+
701+ // Schedule a reconnection if that was our control host
702+ if (current != null && current.address.equals(host.getSocketAddress())) {
703+ backgroundReconnect(0);
704+ }
705+
694706 refreshNodeListAndTokenMap();
695707 }
696708 }