Skip to content
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

[BP-62] Bookkeeper client introduce batch read request api. #4188

Merged
merged 5 commits into from
Jan 26, 2024

Conversation

horizonzy
Copy link
Member

Descriptions of the changes in this PR:
This is the third PR for the batch read(#4051) feature.

Bookkeeper client introduces batch read request API.

@horizonzy
Copy link
Member Author

rerun failure checks

@@ -562,6 +562,10 @@ class BatchedReadResponse extends Response implements ReferenceCounted {
final long requestId;
final ByteBufList data;

BatchedReadResponse(byte protocolVersion, int errorCode, long ledgerId, long entryId, long requestId) {
this(protocolVersion, errorCode, ledgerId, entryId, requestId, ByteBufList.get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: No matter what the error code is, don't forget to release the ByteBufList in the client side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the error BatchedReadResponse will also be released.

@@ -123,6 +123,47 @@ public ByteBuf readEntry(BookieId bookieId, int flags, long ledgerId, long entry
return entry;
}

public ByteBufList batchReadEntry(BookieId bookieId, int flags, long ledgerId, long startEntryId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: batchReadEntries ? (plural)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense.

}
data.add(entry);
}
} catch (Throwable e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catching Throwable is always a code smell, why ? what do you want to catch here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, I copy the code from the BatchedReadEntryProcessor, here we don't need catch the exception.

@@ -687,7 +688,7 @@ void connectIfNeededAndDoOp(GenericCallback<PerChannelBookieClient> op) {
void writeLac(final long ledgerId, final byte[] masterKey, final long lac, ByteBufList toSend, WriteLacCallback cb,
Object ctx) {
final long txnId = getTxnId();
final CompletionKey completionKey = new V3CompletionKey(txnId,
final CompletionKey completionKey = new TxnCompletionKey(txnId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change this name ?V3CompletionKey > TxnCompletionKey

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The V3CompletionKey may mislead. In this PR, it's used for the v2 batch read. The V3CompletionKey uses txnId to trace, so I change the name to TxnCompletionKe.

@@ -2340,28 +2467,28 @@ private long getTxnId() {
return txnIdGenerator.incrementAndGet();
}

private final Recycler<V2CompletionKey> v2KeyRecycler = new Recycler<V2CompletionKey>() {
private final Recycler<EntryCompletionKey> v2KeyRecycler = new Recycler<EntryCompletionKey>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you changing this name ? V2CompletionKey > EntryCompletionKey
it will make porting patches to other branches harder.
if it is not strictly needed I won't change the class names

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are renaming V3CompletionKey to TxnCompletionKey. Therefore, I want to downplay the concepts of V2 and V3 and name it based on its purpose.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eolivelli eolivelli merged commit 262be78 into apache:master Jan 26, 2024
16 checks passed
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants