Chu Cheng Li created HDDS-16983:
-----------------------------------
Summary: Reuse chunk streams for positioned reads in
BlockInputStream
Key: HDDS-16983
URL: https://issues.apache.org/jira/browse/HDDS-16983
Project: Apache Ozone
Issue Type: Improvement
Components: Ozone Client
Reporter: Chu Cheng Li
h3. Background
HDDS-16396 added concurrent positioned reads to {{BlockInputStream}}. A
positioned read does not change the stream position or the buffers of
sequential reads.
h3. Problem
For each positioned read, {{BlockInputStream}} creates a new
{{ChunkInputStream}} for each chunk that the read covers. It closes this stream
after the read. But the block already has one {{ChunkInputStream}} for each
chunk. Thus, each positioned read creates objects that the block already has.
The new stream is necessary today because {{ChunkInputStream.readPositioned}}
writes the shared {{datanodeBlockID}} field. A shared stream cannot do this
write safely during concurrent reads.
h3. Changes
* Move the range logic of {{ChunkInputStream}} to a new class, {{ChunkReader}}.
This logic aligns a range to the checksum boundaries and copies the requested
bytes. {{ChunkReader}} keeps no position and no data buffers.
* Positioned reads use the existing chunk streams of the block. They do not
create a new stream for each read.
* A positioned read builds the {{DatanodeBlockID}} as a local value. It does
not write the shared field.
* Each positioned read still gets its own client from {{XceiverClientFactory}}
and releases it after the read. Short-circuit reads still read the local block
file.
* When a positioned read fails, it refreshes the pipeline. It does not release
the clients of the sequential chunk streams.
h3. Tests
* Concurrent positioned reads from a local block file. The test checks that the
file position and the stream position do not change.
* Two {{ChunkReader}} reads at the same time. The test checks that the reads do
not block each other and do not change the source buffers.
HDDS-16325 tracks the larger refactor of the {{BlockInputStream}} state.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]