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

Extract and dry more IO logic out of searchable snapshots module #93512

Conversation

original-brownbear
Copy link
Member

Extracting more of the IO logic to the blob cache to make it reusable as well as dry it up a little. Small changes to the EOF exception message format in 2 cases in here that only remove redundant information.

Extracting more of the IO logic to the blob cache to make it reusable as well as dry it up a little.
Small changes to the EOF exception message format in 2 cases in here that only remove redundant information.
@original-brownbear original-brownbear added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.7.0 labels Feb 6, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Feb 6, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -20,4 +30,56 @@ public class BlobCacheUtils {
public static int toIntBytes(long l) {
return ByteSizeUnit.BYTES.toIntBytes(l);
}

public static void throwEOF(long channelPos, long len, Object file) throws EOFException {
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a unit test to ensure it effectively throws in case someone changes that behavior in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

How do you mean? Just a test that passes random inputs and verifies that it always throws? Why would anybody change that behavior?:) It's the only line in the method?

Copy link
Member

Choose a reason for hiding this comment

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

Oh sorry I meant to have some basic test coverage on readSafe() that throws using this method. We have many Streams.read* and now BlobCacheUtils.readSafe() utility methods but we are lacking basic test coverage I think

@original-brownbear
Copy link
Member Author

Thanks Tanguy!

@original-brownbear original-brownbear merged commit 6498bd1 into elastic:main Feb 6, 2023
@original-brownbear original-brownbear deleted the extract-more-searchable-snapshots branch February 6, 2023 17:21
@original-brownbear original-brownbear restored the extract-more-searchable-snapshots branch April 18, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants