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

[Backport stable/1.2] Add API to probe the logstream batch writer if more bytes can be written without writing them #8809

Merged
4 commits merged into from
Feb 17, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Description

Backport of #8798 to stable/1.2.

relates to #5525

Adds a new public API method to the Dispatcher,
`#canClaimFragmentBatch(int, int)`. This method determines whether the batch
with the given fragment count and of the given length can actually be
claimed for this dispatcher instance.

This method is mostly useful to determine if something will be claimable
before you wish to claim it, mostly to avoid having to abort your claim
unnecessarily if the batch isn't finished yet when calling this method.

(cherry picked from commit 9281e81)
Introduces a new API to the `LogStreamBatchWriter` API,
`#canWriteAdditionalEvent(int)`. This API lets one probe whether a batch
including an additional event of the given size could be written.

While this could be done via tryWrite, there are cases, such as with the
job activation, where you want to know if adding data to a record (not
to the writer, but the record) will cause it to be unwritable, at which
point you want to handle it differently. Rolling back changes to the
record itself is more complicated than to the writer, so as a compromise
you can probe the writer to know if it will be able to write more bytes
before writing them, even, as in our example, to your DTO.

(cherry picked from commit e706d94)
Adds a common case test for `canClaimFragmentBatch`. The idea is that
the previous test was testing a corner case - i.e. when the given batch
length fits the max fragment length, but will not when it's framed and
aligned.

(cherry picked from commit 471f3c7)
Copy link
Member

@npepinpe npepinpe left a comment

Choose a reason for hiding this comment

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

bors merge

@ghost ghost merged commit 6a9913e into stable/1.2 Feb 17, 2022
@ghost ghost deleted the backport-8798-to-stable/1.2 branch February 17, 2022 12:43
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant