kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 34f2d0656c1d43ab57c95d4de2dff6beb2bb06f6aae0f1828888c68148201785 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-02-23 18:09 +01:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2016-03-31 16:37 +02:00 |
| Parents | 65477c3e8004 |
3 files changed
modified changelog/README.md +1 −0
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | Merged from 2.1 branch: |
| 6 | 6 | |
| 7 | 7 | - [improvement] JAVA-1011: Expose PoolingOptions default values. |
| 8 | +- [improvement] JAVA-630: Don't process DOWN events for nodes that have active connections. | |
| 8 | 9 | |
| 9 | 10 | |
| 10 | 11 | ### 3.0.0 |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +11 −7
| @@ -2638,8 +2638,16 @@ | ||
| 2638 | 2638 | // But it is unlikely, and don't have too much consequence since we'll try reconnecting |
| 2639 | 2639 | // right away, so we favor the detection to make the Host.isUp method more reliable. |
| 2640 | 2640 | Host downHost = metadata.getHost(address); |
| 2641 | - if (downHost != null) | |
| 2642 | - futures.add(execute(hostDown(downHost))); | |
| 2641 | + if (downHost != null) { | |
| 2642 | + // Only process DOWN events if we have no active connections to the host . Otherwise, we | |
| 2643 | + // wait for the connections to fail. This is to prevent against a bad control host | |
| 2644 | + // aggressively marking DOWN all of its peers. | |
| 2645 | + if (downHost.convictionPolicy.hasActiveConnections()) { | |
| 2646 | + logger.debug("Ignoring down event on {} because it still has active connections", downHost); | |
| 2647 | + } else { | |
| 2648 | + futures.add(execute(hostDown(downHost))); | |
| 2649 | + } | |
| 2650 | + } | |
| 2643 | 2651 | break; |
| 2644 | 2652 | case REMOVED: |
| 2645 | 2653 | Host removedHost = metadata.getHost(address); |
| @@ -2720,11 +2728,7 @@ | ||
| 2720 | 2728 | return new ExceptionCatchingRunnable() { |
| 2721 | 2729 | @Override |
| 2722 | 2730 | public void runMayThrow() throws Exception { |
| 2723 | - if (controlConnection.refreshNodeInfo(host)) { | |
| 2724 | - onDown(host, false, true); | |
| 2725 | - } else { | |
| 2726 | - logger.debug("Not enough info for {}, ignoring host", host); | |
| 2727 | - } | |
| 2731 | + onDown(host, false, true); | |
| 2728 | 2732 | } |
| 2729 | 2733 | }; |
| 2730 | 2734 | } |
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 |