Skip to content

Add temporary internal only reset capability #1394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public Set<Bookmark> lastBookmarks() {
return session.lastBookmarks();
}

// Temporary private API
@Deprecated
public void reset() {
Futures.blockingGet(
session.resetAsync(),
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while resetting the session"));
}

private <T> T transaction(
AccessMode mode, @SuppressWarnings("deprecation") TransactionWork<T> work, TransactionConfig config) {
// use different code path compared to async so that work is executed in the caller thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ public CompletionStage<UnmanagedTransaction> beginTransactionAsync(
return newTransactionStage;
}

public CompletionStage<Void> resetAsync() {
return existingTransactionOrNull()
.thenAccept(tx -> {
if (tx != null) {
tx.markTerminated(null);
}
})
.thenCompose(ignore -> connectionStage)
.thenCompose(connection -> {
if (connection != null) {
// there exists an active connection, send a RESET message over it
return connection.reset();
}
return completedWithNull();
});
}

public RetryLogic retryLogic() {
return retryLogic;
}
Expand Down
Loading