Repository navigation
Conversation
peterxcli
marked this pull request as ready for review
October 6, 2026 03:19
peterxcli
requested review from
adoroszlai,
amaliujia,
ivandika3,
sodonnel and
szetszwo
October 6, 2026 03:19
# Conflicts: # hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
amaliujia
reviewed
Oct 7, 2026
| * | ||
| * @return the number of bytes written to the stream | ||
| */ | ||
| static long streamReadBlock(ContainerDispatcher dispatcher, ContainerCommandRequestProto request, |
Contributor
There was a problem hiding this comment.
Curious why we make this as static? Is it for easy testing?
amaliujia
reviewed
Oct 7, 2026
| CertificateClient caClient, StateContext context) throws IOException { | ||
| Parameters parameters = createTlsParameters( | ||
| new SecurityConfig(ozoneConf), caClient); | ||
| if (parameters == null) { |
Contributor
There was a problem hiding this comment.
In this case, createTlsParameters could just return new Parameters() than null?
rich7420
reviewed
Oct 7, 2026
| } catch (IOException e) { | ||
| error.set(e); | ||
| // Throw to stop reading the block | ||
| throw new UncheckedIOException(e); |
Contributor
There was a problem hiding this comment.
Could we let UncheckedIOException propagate through KeyValueHandler.readBlock? It currently becomes CONTAINER_INTERNAL_ERROR and triggers a container scan on client disconnect. Please add a test asserting no scan is triggered.
| } | ||
|
|
||
| final Container<?> container = containerController.getContainer(requestProto.getContainerID()); | ||
| if (container == null || container.getContainerState() != CLOSED) { |
Contributor
There was a problem hiding this comment.
Should this also accept QUASI_CLOSED? SCM returns a read pipeline without an existing Raft group for that state too.
Contributor
|
@peterxcli thanks for the patch! |
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?
HDDS-9904 adds block reads over Ratis data streams. Ratis 3.3.1 supports read-only data streams (RATIS-1240): the client sends one request, and the server sends the data back in a sequence of replies. This PR adds the datanode side for ReadBlock. The client side comes in later sub-tasks of HDDS-9904.
Changes:
ContainerStateMachine#transferToserves ReadBlock and rejects other commands. It passes the request to the dispatcher's streaming read (streamDataReadOnly, the same one the gRPC streaming read uses) and writes each response to the stream as one reply, with layout:[int: metadata length][the response without its data][data].CONTAINER_NOT_FOUND, is sent as a reply with no data, so the client still gets the result code.ClosedContainerReadResolveris a RatisDataStreamApi.Resolver(RATIS-2603), registered inXceiverServerRatis. Ratis asks it before it looks up the Raft group. It serves the read by container ID when the request is a ReadBlock, the container is CLOSED, and the request names this datanode. For any other request it returns null, and Ratis uses the Raft group as before. A closed container does not change, so its read needs neither the group nor the leader.Block tokens are checked as in the gRPC read path: the dispatcher validates the token when the
DispatcherContextis null.Each reply is built in one heap buffer, which copies the data once more. Removing that copy is left to a later sub-task. because it require:
streamDataReadOnlyandHandler.readBlocktake a new observer type that keeps data outside the protobuf and supplies the buffer to read into.readBlockImpl, which would be easier to do after HDDS-16258. Refactor streaming block reads and fix checksum verification for variable-sized chunks #11302 is merged.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16722
How was this patch tested?
ContainerStateMachineTests(run byTestContainerStateMachineLeaderandTestContainerStateMachineFollower):TestClosedContainerReadResolver: the resolver serves ReadBlock only for a closed container on this datanode.TestStreamRead#testRatisStreamReadBlock: on a mini cluster, a plain Ratis client reads a block on a read-only stream, first from the open container through its Raft group, then, after the container is closed, through the read pipeline from SCM, which has a random ID and no Raft group. Both reads match the block file.