Skip to content

HDDS-9904. Add Ratis-backed streaming reads [POC] #10743

Draft
peterxcli wants to merge 2 commits into
apache:masterfrom
peterxcli:ratis-stream-read-poc-squash
Draft

HDDS-9904. Add Ratis-backed streaming reads [POC] #10743
peterxcli wants to merge 2 commits into
apache:masterfrom
peterxcli:ratis-stream-read-poc-squash

Conversation

@peterxcli

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

(this is unable to compile at ci for now because the this patch use ratis 3.3.0-snapshot.)

Add Ratis-backed streaming reads

  • The RatisDataStreamBlockInputStream at client use DataStreamInput(returned by DataStreamApi.streamReadOnly(ByteBuffer headerMessage) DataStreamInput) to consume the data that DN write to via StateMachine.DataApi.query(Message request, WritableByteChannel stream)
  • Add a ClosedContainerReadResolver, which is a DataStreamResovler implmentation for closed container to prevent the fake id of read pipeline cause the GroupMismatchException when open the data stream by bypass the ratis side live group id lookup and validation.

What is the link to the Apache JIRA

issues.apache.org/jira/browse/HDDS-9904

How was this patch tested?

(Please explain how this patch was tested. Ex: unit tests, manual tests, workflow run on the fork git repo.)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this.)

Copilot AI review requested due to automatic review settings July 13, 2026 19:00
@peterxcli peterxcli changed the title [POC] HDDS-9904. Add Ratis-backed streaming reads HDDS-9904. Add Ratis-backed streaming reads [POC] Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR is a proof-of-concept adding a new client read path that reads RATIS-replicated blocks via the Ratis DataStream read-only API, and adds server-side handling to stream ReadBlock responses efficiently (metadata + raw bytes) including a resolver to support group-independent reads for closed containers.

Changes:

  • Add RatisDataStreamBlockInputStream and client selection logic gated by ozone.client.ratis.stream.readblock.enable plus a new read window config.
  • Implement server-side DataStream query(..., WritableByteChannel) handling for ReadBlock, including an on-DN ClosedContainerReadResolver for closed-container reads after group removal.
  • Add unit/integration tests and a manually enabled benchmark to exercise and compare the new read path.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pom.xml Bumps Ratis dependency version to 3.3.0-SNAPSHOT for POC support.
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestRatisDataStreamReadBlockBenchmark.java Adds a manually enabled benchmark comparing ReadBlock streaming vs Ratis DataStream reads.
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestRatisDataStreamReadBlock.java Adds integration tests for Ratis DataStream ReadBlock and closed-container read after group removal.
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandler.java Updates ReadBlock streaming tests to use DataStreamObserver<ReadBlockResponse>.
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestClosedContainerReadResolver.java Adds unit coverage for the closed-container read resolver behavior.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java Switches ReadBlock streaming callback to deliver protobuf metadata + separate ByteBuffer payload.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java Registers the ClosedContainerReadResolver into Ratis parameters.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java Implements DataStream query streaming for ReadBlock and a compatibility query path that merges responses.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ClosedContainerReadResolver.java Adds resolver that bypasses Raft group lookup for closed-container ReadBlock streaming.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/GrpcXceiverService.java Adapts ReadBlock streaming to new ReadBlockResponse (metadata + ByteBuffer data).
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Handler.java Updates handler ReadBlock streaming API to use DataStreamObserver<ReadBlockResponse>.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerDispatcher.java Introduces ReadBlockResponse wrapper and updates streamDataReadOnly signature.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java Updates dispatcher ReadBlock streaming to forward ReadBlockResponse and propagate failures.
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ContainerCommandResponseBuilders.java Adds overload to build ReadBlock responses with a provided ByteString payload.
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/DatanodeVersion.java Adds a new DN feature version constant for Ratis DataStream ReadBlock support.
hadoop-hdds/client/src/test/java/org/apache/hadoop/ozone/client/io/TestBlockInputStreamFactoryImpl.java Adds tests covering selection and compatibility fallback for the new stream type.
hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestRatisDataStreamBlockInputStream.java Adds unit coverage for read window sizing logic.
hadoop-hdds/client/src/main/java/org/apache/hadoop/ozone/client/io/BlockInputStreamFactoryImpl.java Adds selection of RatisDataStreamBlockInputStream when enabled and supported.
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/RatisDataStreamBlockInputStream.java Introduces the new client-side DataStream-based RATIS block input stream implementation.
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/MultipartInputStream.java Treats the new stream type as a “stream block input stream” for multipart reads.
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java Adds client config toggles and validation for the Ratis DataStream read window and enable flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pom.xml
Comment on lines +95 to +101
} else if (config.isRatisStreamReadBlock()
&& repConfig.getReplicationType().equals(HddsProtos.ReplicationType.RATIS)
&& allDataNodesSupport(pipeline,
RATIS_DATASTREAM_READ_BLOCK_SUPPORT)) {
return new RatisDataStreamBlockInputStream(blockInfo.getBlockID(),
blockInfo.getLength(), pipeline, token, xceiverFactory,
config);
Copilot AI review requested due to automatic review settings July 13, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings July 13, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Comment thread pom.xml
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.

2 participants