kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 65e685d3eeefcd4a6b60e3eee2c83ddbcb658de335f3558a7b283cd91c53c426 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2016-02-16 20:02 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-02-23 17:58 +01:00 |
| Parents | 13ff5c33b0a0 |
3 files changed
modified changelog/README.md +1 −0
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | - [improvement] JAVA-843: Disable frozen checks in mapper. |
| 14 | 14 | - [improvement] JAVA-833: Improve message when a nested type can't be serialized. |
| 15 | 15 | - [improvement] JAVA-1011: Expose PoolingOptions default values. |
| 16 | +- [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections. | |
| 16 | 17 | |
| 17 | 18 | Merged from 2.0 branch: |
| 18 | 19 |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +11 −7
| @@ -2625,8 +2625,16 @@ | ||
| 2625 | 2625 | // But it is unlikely, and don't have too much consequence since we'll try reconnecting |
| 2626 | 2626 | // right away, so we favor the detection to make the Host.isUp method more reliable. |
| 2627 | 2627 | 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 | + } | |
| 2630 | 2638 | break; |
| 2631 | 2639 | case REMOVED: |
| 2632 | 2640 | Host removedHost = metadata.getHost(address); |
| @@ -2702,11 +2710,7 @@ | ||
| 2702 | 2710 | return new ExceptionCatchingRunnable() { |
| 2703 | 2711 | @Override |
| 2704 | 2712 | 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); | |
| 2710 | 2714 | } |
| 2711 | 2715 | }; |
| 2712 | 2716 | } |
modified driver-core/src/main/java/com/datastax/driver/core/ConvictionPolicy.java +7 −0
| @@ -53,6 +53,8 @@ | ||
| 53 | 53 | |
| 54 | 54 | abstract boolean canReconnectNow(); |
| 55 | 55 | |
| 56 | + abstract boolean hasActiveConnections(); | |
| 57 | + | |
| 56 | 58 | /** |
| 57 | 59 | * Simple factory interface to allow creating {@link ConvictionPolicy} instances. |
| 58 | 60 | */ |
| @@ -132,6 +134,11 @@ | ||
| 132 | 134 | return canReconnectNow; |
| 133 | 135 | } |
| 134 | 136 | |
| 137 | + @Override | |
| 138 | + boolean hasActiveConnections() { | |
| 139 | + return openConnections.get() > 0; | |
| 140 | + } | |
| 141 | + | |
| 135 | 142 | static class Factory implements ConvictionPolicy.Factory { |
| 136 | 143 | |
| 137 | 144 | @Override |