Elffuss BraidHub

kikocis/java-driver public

Merge pull request #482 from datastax/java877

JAVA-877: Don't wait NEW_NODE_DELAY_SECONDS if protocol version = V4.
Changesetccdf5a93b3d2da94436af555d34da408c3b37b3546d88a86a7debd92ec821e1d
AuthorOlivier Michallat <olim7t@users.noreply.github.com> · 2015-10-12 11:58 +02:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2015-10-12 11:58 +02:00
Parents7d4fb0840337, 3ddca2e67dfe

Browse the files at this changeset

2 files changed

modified changelog/README.md +1 −0
@@ -4,6 +4,7 @@
44
55 - [improvement] Change default consistency level to LOCAL_QUORUM (JAVA-926)
66 - [bug] Fix implementation of UserType.hashCode() (JAVA-942)
7+- [improvement] Don't delay UP/ADDED notifications if protocol version = V4 (JAVA-877)
78
89
910 ### 3.0.0-alpha3
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +24 −19
@@ -2586,26 +2586,31 @@
25862586 private ListenableFuture<?> schedule(final ExceptionCatchingRunnable task) {
25872587 // Cassandra tends to send notifications for new/up nodes a bit early (it is triggered once
25882588 // 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+ }
26002602
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+ }
26092614 }
26102615
26112616 // Make sure we call controlConnection.refreshNodeInfo(host)