You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/06/30 19:50:13 UTC
[GitHub] [ozone] szetszwo commented on a diff in pull request #3559: HDDS-6955. [Ozone-streaming] Add explicit stream flag in ozone shell
szetszwo commented on code in PR #3559:
URL: https://github.com/apache/ozone/pull/3559#discussion_r911387688
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java:
##########
@@ -96,26 +100,21 @@ protected void execute(OzoneClient client, OzoneAddress address)
int chunkSize = (int) getConf().getStorageSize(OZONE_SCM_CHUNK_SIZE_KEY,
OZONE_SCM_CHUNK_SIZE_DEFAULT, StorageUnit.BYTES);
- Boolean useAsync = false;
- if (dataFile.length() <= chunkSize ||
- (replicationConfig != null &&
- replicationConfig.getReplicationType() == EC) ||
- bucket.getReplicationConfig() instanceof ECReplicationConfig) {
- useAsync = true;
- }
- if (useAsync) {
+ if (stream) {
if (isVerbose()) {
- out().println("API: async");
+ out().println("API: streaming");
}
- try (InputStream input = new FileInputStream(dataFile);
- OutputStream output = bucket.createKey(keyName, dataFile.length(),
- replicationConfig, keyMetadata)) {
- IOUtils.copyBytes(input, output, chunkSize);
+ // In streaming mode, always resolve replication config at client side,
+ // because streaming is not compatible for writing EC keys.
+ if (replicationConfig == null) {
+ replicationConfig = bucket.getReplicationConfig();
}
- } else {
- if (isVerbose()) {
- out().println("API: streaming");
+ if (replicationConfig == null) {
+ replicationConfig = ReplicationConfig.parse(null, null, getConf());
Review Comment:
Use ReplicationConfig.getDefault(..) and check bucket default. Let's add a resolve method to ReplicationConfig:
```
static ReplicationConfig resolve(ReplicationConfig replicationConfig,
ReplicationConfig bucketReplicationConfig, ConfigurationSource conf) {
if (replicationConfig == null) {
replicationConfig = bucketReplicationConfig;
}
if (replicationConfig == null) {
replicationConfig = getDefault(conf);
}
return replicationConfig;
}
```
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java:
##########
@@ -96,26 +100,21 @@ protected void execute(OzoneClient client, OzoneAddress address)
int chunkSize = (int) getConf().getStorageSize(OZONE_SCM_CHUNK_SIZE_KEY,
OZONE_SCM_CHUNK_SIZE_DEFAULT, StorageUnit.BYTES);
- Boolean useAsync = false;
- if (dataFile.length() <= chunkSize ||
- (replicationConfig != null &&
- replicationConfig.getReplicationType() == EC) ||
- bucket.getReplicationConfig() instanceof ECReplicationConfig) {
- useAsync = true;
- }
- if (useAsync) {
+ if (stream) {
Review Comment:
Let's move the stream code to a separated method.
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java:
##########
@@ -130,6 +129,15 @@ protected void execute(OzoneClient client, OzoneAddress address)
len -= writeLen;
}
}
+ } else {
+ if (isVerbose()) {
+ out().println("API: async");
+ }
+ try (InputStream input = new FileInputStream(dataFile);
+ OutputStream output = bucket.createKey(keyName, dataFile.length(),
+ replicationConfig, keyMetadata)) {
+ IOUtils.copyBytes(input, output, chunkSize);
+ }
Review Comment:
Move it to a separated method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org