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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]