kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 091573a394239bbdb37edd748b38810994c1e12455b0b6afeb738140c2d0ba79 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-12-21 16:52 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-12-21 16:54 +01:00 |
| Parents | 43c7e4b6378c |
2 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -21,6 +21,8 @@ | ||
| 21 | 21 | (JAVA-593) |
| 22 | 22 | - [bug] Ensure state change notifications for a given host are handled serially |
| 23 | 23 | (JAVA-594) |
| 24 | +- [bug] Ensure control connection reconnects when control host is removed | |
| 25 | + (JAVA-597) | |
| 24 | 26 | |
| 25 | 27 | |
| 26 | 28 | 2.0.8: |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +12 −3
| @@ -161,9 +161,9 @@ | ||
| 161 | 161 | |
| 162 | 162 | private void signalError() { |
| 163 | 163 | 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. | |
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | 169 | // If the connection is not defunct, or the host has left, just reconnect manually |
| @@ -669,6 +669,15 @@ | ||
| 669 | 669 | |
| 670 | 670 | @Override |
| 671 | 671 | 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 | + | |
| 672 | 681 | refreshNodeListAndTokenMap(); |
| 673 | 682 | } |
| 674 | 683 | } |