-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-4417. Simplify Ozone client code with configuration object #1542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
55deff3
ozone client config
elek e28e737
fix config handling
elek 8f7808f
end
elek b4dd563
fix
elek 911706c
checkstyle fixes
elek d2b553b
retrigger ci
elek 2a75546
finish block output stream
elek 13f3310
fix unit tests
elek 44a3aa6
HDDS-4417. Simplify Ozone client code with configuration object
elek 83a4fe0
Merge remote-tracking branch 'origin/master' into HDDS-4417
elek ea7064c
Restore lines disappeared during the merge
elek eef29d2
fix findbugs problem
elek 3b7018e
fix copy paste typo
elek 76d62e5
retrigger build
elek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
213 changes: 213 additions & 0 deletions
213
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/OzoneClientConfig.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hdds.scm; | ||
|
|
||
| import org.apache.hadoop.hdds.conf.Config; | ||
| import org.apache.hadoop.hdds.conf.ConfigGroup; | ||
| import org.apache.hadoop.hdds.conf.ConfigTag; | ||
| import org.apache.hadoop.hdds.conf.ConfigType; | ||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ChecksumType; | ||
| import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Configuration values for Ozone Client. | ||
| */ | ||
| @ConfigGroup(prefix = "ozone.client") | ||
| public class OzoneClientConfig { | ||
|
|
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(OzoneClientConfig.class); | ||
|
|
||
| @Config(key = "stream.buffer.flush.size", | ||
| defaultValue = "16MB", | ||
| type = ConfigType.SIZE, | ||
| description = "Size which determines at what buffer position a partial " | ||
| + "flush will be initiated during write. It should be a multiple of" | ||
| + " ozone.client.stream.buffer.size", | ||
| tags = ConfigTag.CLIENT) | ||
| private long streamBufferFlushSize = 16 * 1024 * 1024; | ||
|
|
||
| @Config(key = "stream.buffer.size", | ||
| defaultValue = "4MB", | ||
| type = ConfigType.SIZE, | ||
| description = "The size of chunks the client will send to the server", | ||
| tags = ConfigTag.CLIENT) | ||
| private int streamBufferSize = 4 * 1024 * 1024; | ||
|
|
||
| @Config(key = "stream.buffer.flush.delay", | ||
| defaultValue = "true", | ||
| description = "Default true, when call flush() and determine whether " | ||
| + "the data in the current buffer is greater than ozone.client" | ||
| + ".stream.buffer.size, if greater than then send buffer to the " | ||
| + "datanode. You can turn this off by setting this configuration " | ||
| + "to false.", tags = ConfigTag.CLIENT) | ||
| private boolean streamBufferFlushDelay = true; | ||
|
|
||
| @Config(key = "stream.buffer.max.size", | ||
| defaultValue = "32MB", | ||
| type = ConfigType.SIZE, | ||
| description = "Size which determines at what buffer position write call" | ||
| + " be blocked till acknowledgement of the first partial flush " | ||
| + "happens by all servers.", | ||
| tags = ConfigTag.CLIENT) | ||
| private long streamBufferMaxSize = 32 * 1024 * 1024; | ||
|
|
||
| @Config(key = "max.retries", | ||
| defaultValue = "5", | ||
| description = "Maximum number of retries by Ozone Client on " | ||
| + "encountering exception while writing a key", | ||
| tags = ConfigTag.CLIENT) | ||
| private int maxRetryCount = 5; | ||
|
|
||
| @Config(key = "retry.interval", | ||
| defaultValue = "0", | ||
| description = | ||
| "Indicates the time duration a client will wait before retrying a " | ||
| + "write key request on encountering an exception. By default " | ||
| + "there is no wait", | ||
| tags = ConfigTag.CLIENT) | ||
| private int retryInterval = 0; | ||
|
|
||
| @Config(key = "checksum.type", | ||
| defaultValue = "CRC32", | ||
| description = "The checksum type [NONE/ CRC32/ CRC32C/ SHA256/ MD5] " | ||
| + "determines which algorithm would be used to compute checksum for " | ||
| + "chunk data. Default checksum type is CRC32.", | ||
| tags = ConfigTag.CLIENT) | ||
| private String checksumType = ChecksumType.CRC32.name(); | ||
|
|
||
| @Config(key = "bytes.per.checksum", | ||
| defaultValue = "1MB", | ||
| type = ConfigType.SIZE, | ||
| description = "Checksum will be computed for every bytes per checksum " | ||
| + "number of bytes and stored sequentially. The minimum value for " | ||
| + "this config is 256KB.", | ||
| tags = ConfigTag.CLIENT) | ||
| private int bytesPerChecksum = 1024 * 1024; | ||
|
|
||
| @Config(key = "verify.checksum", | ||
| defaultValue = "true", | ||
| description = "Ozone client to verify checksum of the checksum " | ||
| + "blocksize data.", | ||
| tags = ConfigTag.CLIENT) | ||
| private boolean checksumVerify = true; | ||
|
|
||
| public OzoneClientConfig() { | ||
| } | ||
|
|
||
| private void validate() { | ||
| Preconditions.checkState(streamBufferSize > 0); | ||
| Preconditions.checkState(streamBufferFlushSize > 0); | ||
| Preconditions.checkState(streamBufferMaxSize > 0); | ||
|
|
||
| Preconditions.checkState(streamBufferMaxSize % streamBufferFlushSize == 0, | ||
| "expected max. buffer size (%s) to be a multiple of flush size (%s)", | ||
| streamBufferMaxSize, streamBufferFlushSize); | ||
| Preconditions.checkState(streamBufferFlushSize % streamBufferSize == 0, | ||
| "expected flush size (%s) to be a multiple of buffer size (%s)", | ||
| streamBufferFlushSize, streamBufferSize); | ||
|
|
||
| if (bytesPerChecksum < | ||
| OzoneConfigKeys.OZONE_CLIENT_BYTES_PER_CHECKSUM_MIN_SIZE) { | ||
| LOG.warn("The checksum size ({}) is not allowed to be less than the " + | ||
| "minimum size ({}), resetting to the minimum size.", | ||
| bytesPerChecksum, | ||
| OzoneConfigKeys.OZONE_CLIENT_BYTES_PER_CHECKSUM_MIN_SIZE); | ||
| bytesPerChecksum = | ||
| OzoneConfigKeys.OZONE_CLIENT_BYTES_PER_CHECKSUM_MIN_SIZE; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public long getStreamBufferFlushSize() { | ||
| return streamBufferFlushSize; | ||
| } | ||
|
|
||
| public void setStreamBufferFlushSize(long streamBufferFlushSize) { | ||
| this.streamBufferFlushSize = streamBufferFlushSize; | ||
| } | ||
|
|
||
| public int getStreamBufferSize() { | ||
| return streamBufferSize; | ||
| } | ||
|
|
||
| public void setStreamBufferSize(int streamBufferSize) { | ||
| this.streamBufferSize = streamBufferSize; | ||
| } | ||
|
|
||
| public boolean isStreamBufferFlushDelay() { | ||
| return streamBufferFlushDelay; | ||
| } | ||
|
|
||
| public void setStreamBufferFlushDelay(boolean streamBufferFlushDelay) { | ||
| this.streamBufferFlushDelay = streamBufferFlushDelay; | ||
| } | ||
|
|
||
| public long getStreamBufferMaxSize() { | ||
| return streamBufferMaxSize; | ||
| } | ||
|
|
||
| public void setStreamBufferMaxSize(long streamBufferMaxSize) { | ||
| this.streamBufferMaxSize = streamBufferMaxSize; | ||
| } | ||
|
|
||
| public int getMaxRetryCount() { | ||
| return maxRetryCount; | ||
| } | ||
|
|
||
| public void setMaxRetryCount(int maxRetryCount) { | ||
| this.maxRetryCount = maxRetryCount; | ||
| } | ||
|
|
||
| public int getRetryInterval() { | ||
| return retryInterval; | ||
| } | ||
|
|
||
| public void setRetryInterval(int retryInterval) { | ||
| this.retryInterval = retryInterval; | ||
| } | ||
|
|
||
| public ChecksumType getChecksumType() { | ||
| return ChecksumType.valueOf(checksumType); | ||
| } | ||
|
|
||
| public void setChecksumType(ChecksumType checksumType) { | ||
| this.checksumType = checksumType.name(); | ||
| } | ||
|
|
||
| public int getBytesPerChecksum() { | ||
| return bytesPerChecksum; | ||
| } | ||
|
|
||
| public void setBytesPerChecksum(int bytesPerChecksum) { | ||
| this.bytesPerChecksum = bytesPerChecksum; | ||
| } | ||
|
|
||
| public boolean isChecksumVerify() { | ||
| return checksumVerify; | ||
| } | ||
|
|
||
| public void setChecksumVerify(boolean checksumVerify) { | ||
| this.checksumVerify = checksumVerify; | ||
| } | ||
|
|
||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently
validate()is unused. I think it should have@PostConstructannotation.