kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | ccdf5a93b3d2da94436af555d34da408c3b37b3546d88a86a7debd92ec821e1d |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-10-12 11:58 +02:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2015-10-12 11:58 +02:00 |
| Parents | 7d4fb0840337, 3ddca2e67dfe |
2 files changed
modified changelog/README.md +1 −0
| @@ -4,6 +4,7 @@ | ||
| 4 | 4 | |
| 5 | 5 | - [improvement] Change default consistency level to LOCAL_QUORUM (JAVA-926) |
| 6 | 6 | - [bug] Fix implementation of UserType.hashCode() (JAVA-942) |
| 7 | +- [improvement] Don't delay UP/ADDED notifications if protocol version = V4 (JAVA-877) | |
| 7 | 8 | |
| 8 | 9 | |
| 9 | 10 | ### 3.0.0-alpha3 |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +24 −19
| @@ -2586,26 +2586,31 @@ | ||
| 2586 | 2586 | private ListenableFuture<?> schedule(final ExceptionCatchingRunnable task) { |
| 2587 | 2587 | // Cassandra tends to send notifications for new/up nodes a bit early (it is triggered once |
| 2588 | 2588 | // gossip is up, but that is before the client-side server is up), so we add a delay |
| 2589 | - // (otherwise the connection will likely fail and have to be retry which is wasteful). This | |
| 2590 | - // probably should be fixed C* side, after which we'll be able to remove this. | |
| 2591 | - final SettableFuture<?> future = SettableFuture.create(); | |
| 2592 | - scheduledTasksExecutor.schedule(new ExceptionCatchingRunnable() { | |
| 2593 | - public void runMayThrow() throws Exception { | |
| 2594 | - ListenableFuture<?> f = execute(task); | |
| 2595 | - Futures.addCallback(f, new FutureCallback<Object>() { | |
| 2596 | - @Override | |
| 2597 | - public void onSuccess(Object result) { | |
| 2598 | - future.set(null); | |
| 2599 | - } | |
| 2589 | + // (otherwise the connection will likely fail and have to be retry which is wasteful). | |
| 2590 | + // This has been fixed by CASSANDRA-8236 and does not apply to protocol versions >= 4 | |
| 2591 | + // and C* versions >= 2.2.0 | |
| 2592 | + if (protocolVersion().compareTo(ProtocolVersion.V4) < 0) { | |
| 2593 | + final SettableFuture<?> future = SettableFuture.create(); | |
| 2594 | + scheduledTasksExecutor.schedule(new ExceptionCatchingRunnable() { | |
| 2595 | + public void runMayThrow() throws Exception { | |
| 2596 | + ListenableFuture<?> f = execute(task); | |
| 2597 | + Futures.addCallback(f, new FutureCallback<Object>() { | |
| 2598 | + @Override | |
| 2599 | + public void onSuccess(Object result) { | |
| 2600 | + future.set(null); | |
| 2601 | + } | |
| 2600 | 2602 | |
| 2601 | - @Override | |
| 2602 | - public void onFailure(Throwable t) { | |
| 2603 | - future.setException(t); | |
| 2604 | - } | |
| 2605 | - }); | |
| 2606 | - } | |
| 2607 | - }, NEW_NODE_DELAY_SECONDS, TimeUnit.SECONDS); | |
| 2608 | - return future; | |
| 2603 | + @Override | |
| 2604 | + public void onFailure(Throwable t) { | |
| 2605 | + future.setException(t); | |
| 2606 | + } | |
| 2607 | + }); | |
| 2608 | + } | |
| 2609 | + }, NEW_NODE_DELAY_SECONDS, TimeUnit.SECONDS); | |
| 2610 | + return future; | |
| 2611 | + } else { | |
| 2612 | + return execute(task); | |
| 2613 | + } | |
| 2609 | 2614 | } |
| 2610 | 2615 | |
| 2611 | 2616 | // Make sure we call controlConnection.refreshNodeInfo(host) |