|
18 | 18 | package org.apache.hadoop.hdds.scm; |
19 | 19 |
|
20 | 20 | import com.google.common.base.Preconditions; |
| 21 | +import java.time.Duration; |
21 | 22 | import org.apache.hadoop.hdds.conf.Config; |
22 | 23 | import org.apache.hadoop.hdds.conf.ConfigGroup; |
23 | 24 | import org.apache.hadoop.hdds.conf.ConfigTag; |
@@ -281,6 +282,27 @@ public class OzoneClientConfig { |
281 | 282 | tags = ConfigTag.CLIENT) |
282 | 283 | private int maxConcurrentWritePerKey = 1; |
283 | 284 |
|
| 285 | + @Config(key = "ozone.client.stream.read.pre-read-size", |
| 286 | + defaultValue = "33554432", |
| 287 | + type = ConfigType.LONG, |
| 288 | + tags = {ConfigTag.CLIENT}, |
| 289 | + description = "Extra bytes to prefetch during streaming reads.") |
| 290 | + private long streamReadPreReadSize = 32L << 20; |
| 291 | + |
| 292 | + @Config(key = "ozone.client.stream.read.response-data-size", |
| 293 | + defaultValue = "1048576", |
| 294 | + type = ConfigType.INT, |
| 295 | + tags = {ConfigTag.CLIENT}, |
| 296 | + description = "Chunk size of streaming read responses from datanodes.") |
| 297 | + private int streamReadResponseDataSize = 1 << 20; |
| 298 | + |
| 299 | + @Config(key = "ozone.client.stream.read.timeout", |
| 300 | + defaultValue = "10s", |
| 301 | + type = ConfigType.TIME, |
| 302 | + tags = {ConfigTag.CLIENT}, |
| 303 | + description = "Timeout for receiving streaming read responses.") |
| 304 | + private Duration streamReadTimeout = Duration.ofSeconds(10); |
| 305 | + |
284 | 306 | @PostConstruct |
285 | 307 | public void validate() { |
286 | 308 | Preconditions.checkState(streamBufferSize > 0); |
@@ -335,6 +357,33 @@ public void validate() { |
335 | 357 | } |
336 | 358 | // Note: ozone.fs.hsync.enabled is enforced by OzoneFSUtils#canEnableHsync, not here |
337 | 359 | } |
| 360 | + // Validate streaming read configurations. |
| 361 | + // Ensure pre-read size is non-negative. If it's invalid, reset to a sane default. |
| 362 | + if (streamReadPreReadSize < 0) { |
| 363 | + LOG.warn("Invalid ozone.client.stream.read.pre-read-size = {}. " + |
| 364 | + "Resetting to default 32MB.", |
| 365 | + streamReadPreReadSize); |
| 366 | + streamReadPreReadSize = 32L << 20; // 32MB |
| 367 | + } |
| 368 | + |
| 369 | + // Ensure response data size is positive. |
| 370 | + if (streamReadResponseDataSize <= 0) { |
| 371 | + LOG.warn("Invalid ozone.client.stream.read.response-data-size = {}. " + |
| 372 | + "Resetting to default 1MB.", |
| 373 | + streamReadResponseDataSize); |
| 374 | + streamReadResponseDataSize = 1 << 20; // 1MB |
| 375 | + } |
| 376 | + |
| 377 | + // Ensure stream read timeout is a positive duration. |
| 378 | + Duration defaultTimeout = Duration.ofSeconds(10); |
| 379 | + if (streamReadTimeout == null |
| 380 | + || streamReadTimeout.isZero() |
| 381 | + || streamReadTimeout.isNegative()) { |
| 382 | + LOG.warn("Invalid ozone.client.stream.read.timeout = {}. " + |
| 383 | + "Resetting to default {}.", |
| 384 | + streamReadTimeout, defaultTimeout); |
| 385 | + streamReadTimeout = defaultTimeout; |
| 386 | + } |
338 | 387 | } |
339 | 388 |
|
340 | 389 | public long getStreamBufferFlushSize() { |
@@ -553,6 +602,30 @@ public void setStreamReadBlock(boolean streamReadBlock) { |
553 | 602 | this.streamReadBlock = streamReadBlock; |
554 | 603 | } |
555 | 604 |
|
| 605 | + public long getStreamReadPreReadSize() { |
| 606 | + return streamReadPreReadSize; |
| 607 | + } |
| 608 | + |
| 609 | + public int getStreamReadResponseDataSize() { |
| 610 | + return streamReadResponseDataSize; |
| 611 | + } |
| 612 | + |
| 613 | + public Duration getStreamReadTimeout() { |
| 614 | + return streamReadTimeout; |
| 615 | + } |
| 616 | + |
| 617 | + public void setStreamReadPreReadSize(long streamReadPreReadSize) { |
| 618 | + this.streamReadPreReadSize = streamReadPreReadSize; |
| 619 | + } |
| 620 | + |
| 621 | + public void setStreamReadResponseDataSize(int streamReadResponseDataSize) { |
| 622 | + this.streamReadResponseDataSize = streamReadResponseDataSize; |
| 623 | + } |
| 624 | + |
| 625 | + public void setStreamReadTimeout(Duration streamReadTimeout) { |
| 626 | + this.streamReadTimeout = streamReadTimeout; |
| 627 | + } |
| 628 | + |
556 | 629 | /** |
557 | 630 | * Enum for indicating what mode to use when combining chunk and block |
558 | 631 | * checksums to define an aggregate FileChecksum. This should be considered |
|
0 commit comments