HDDS-9549. defaultReadBufferCapacity should be int instead of long#5522
Merged
sumitagrawl merged 2 commits intoapache:masterfrom Nov 3, 2023
Merged
HDDS-9549. defaultReadBufferCapacity should be int instead of long#5522sumitagrawl merged 2 commits intoapache:masterfrom
sumitagrawl merged 2 commits intoapache:masterfrom
Conversation
sadanand48
reviewed
Nov 3, 2023
Contributor
sadanand48
left a comment
There was a problem hiding this comment.
Thanks @Tejaskriya for the patch, LGTM
sumitagrawl
approved these changes
Nov 3, 2023
Contributor
sumitagrawl
left a comment
There was a problem hiding this comment.
@Tejaskriya Thanks for working over this, LGTM
szetszwo
reviewed
Nov 4, 2023
Contributor
szetszwo
left a comment
There was a problem hiding this comment.
@Tejaskriya , thanks for working on this! Individual buffer size is int but len (e.g. file length/chunk length) should be long. Also, we should check range before casting.
Since this is already merge, will fix them in HDDS-9611.
| */ | ||
| public static ByteBuffer[] assignByteBuffers(long totalLen, | ||
| long bufferCapacity) { | ||
| public static ByteBuffer[] assignByteBuffers(int totalLen, |
Contributor
There was a problem hiding this comment.
The totalLen and buffersAllocated should be long. We should allow >= 2GB chunks/files.
| Preconditions.checkNotNull(conf, "Config cannot be null"); | ||
| this.config = conf; | ||
| this.defaultReadBufferCapacity = (long) config.getStorageSize( | ||
| this.defaultReadBufferCapacity = (int) config.getStorageSize( |
Contributor
There was a problem hiding this comment.
Check range before casting to (int).
|
|
||
| long len = info.getLen(); | ||
| long bufferCapacity = ChunkManager.getBufferCapacityForChunkRead(info, | ||
| int len = (int) info.getLen(); |
| long bufferCapacity = 0; | ||
| static int getBufferCapacityForChunkRead(ChunkInfo chunkInfo, | ||
| int defaultReadBufferCapacity) { | ||
| int bufferCapacity = 0; |
Contributor
|
@sumitagrawl , please resolve the JIRA after merge. Thanks. |
xBis7
pushed a commit
to xBis7/ozone
that referenced
this pull request
Nov 6, 2023
ibrusentsev
pushed a commit
to ibrusentsev/ozone
that referenced
this pull request
Nov 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
defaultReadBufferCapacity was changed from long to int in this PR.
This change was made because although defaultReadBufferCapacity was long in BlockManagerImpl/FilePerBlockStrategy/FilePerChunkStrategy, it was casted to int when it is used as shown below.
Using long as buffer capacity does NOT work for Java array, Java ByteBuffer, Protobuf ByteString and Netty ByteBuf. Moreover, if we set ozone.chunk.read.buffer.default.size to "2GB",
((int) bufferCapacity) == -2147483648would throw an IllegalArgumentException from ByteBuffer.allocate(..).What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9549
How was this patch tested?
Existing tests in TestChunkUtils, TestFilePerBlockStrategy, TestFilePerChunkStrategy cover this change