E611 JAVA-877: Don't wait NEW_NODE_DELAY_SECONDS if protocol version = V4. by olim7t · Pull Request #482 · apache/cassandra-java-driver · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [improvement] Change default consistency level to LOCAL_QUORUM (JAVA-926)
- [bug] Fix implementation of UserType.hashCode() (JAVA-942)
- [improvement] Don't delay UP/ADDED notifications if protocol version = V4 (JAVA-877)


### 3.0.0-alpha3
Expand Down
43 changes: 24 additions & 19 deletions driver-core/src/main/java/com/datastax/driver/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -2586,26 +2586,31 @@ private ListenableFuture<?> execute(ExceptionCatchingRunnable task) {
private ListenableFuture<?> schedule(final ExceptionCatchingRunnable task) {
// Cassandra tends to send notifications for new/up nodes a bit early (it is triggered once
// gossip is up, but that is before the client-side server is up), so we add a delay
// (otherwise the connection will likely fail and have to be retry which is wasteful). This
// probably should be fixed C* side, after which we'll be able to remove this.
final SettableFuture<?> future = SettableFuture.create();
scheduledTasksExecutor.schedule(new ExceptionCatchingRunnable() {
public void runMayThrow() throws Exception {
ListenableFuture<?> f = execute(task);
Futures.addCallback(f, new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
future.set(null);
}
// (otherwise the connection will likely fail and have to be retry which is wasteful).
// This has been fixed by CASSANDRA-8236 and does not apply to protocol versions >= 4
// and C* versions >= 2.2.0
if (protocolVersion().compareTo(ProtocolVersion.V4) < 0) {
final SettableFuture<?> future = SettableFuture.create();
scheduledTasksExecutor.schedule(new ExceptionCatchingRunnable() {
public void runMayThrow() throws Exception {
ListenableFuture<?> f = execute(task);
Futures.addCallback(f, new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
future.set(null);
}

@Override
public void onFailure(Throwable t) {
future.setException(t);
}
});
}
}, NEW_NODE_DELAY_SECONDS, TimeUnit.SECONDS);
return future;
@Override
public void onFailure(Throwable t) {
future.setException(t);
}
});
}
}, NEW_NODE_DELAY_SECONDS, TimeUnit.SECONDS);
return future;
} else {
return execute(task);
}
}

// Make sure we call controlConnection.refreshNodeInfo(host)
Expand Down
0