jojochuang commented on code in PR #9815:
URL: https://github.com/apache/ozone/pull/9815#discussion_r3012857605
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1435,6 +1435,68 @@ public OzoneOutputStream rewriteKey(String volumeName,
String bucketName, String
return createOutputStream(openKey);
}
+ @Override
+ public OzoneOutputStream createKeyIfNotExists(String volumeName,
+ String bucketName, String keyName, long size,
+ ReplicationConfig replicationConfig, Map<String, String> metadata,
+ Map<String, String> tags) throws IOException {
+ if (omVersion.compareTo(OzoneManagerVersion.ATOMIC_REWRITE_KEY) < 0) {
+ throw new IOException(
+ "OzoneManager does not support atomic key creation.");
+ }
+
+ createKeyPreChecks(volumeName, bucketName, keyName, replicationConfig);
+
+ OmKeyArgs.Builder builder = new OmKeyArgs.Builder()
+ .setVolumeName(volumeName)
+ .setBucketName(bucketName)
+ .setKeyName(keyName)
+ .setDataSize(size)
+ .setReplicationConfig(replicationConfig)
+ .addAllMetadataGdpr(metadata)
+ .addAllTags(tags)
+ .setLatestVersionLocation(getLatestVersionLocation)
+ .setExpectedDataGeneration(
+ OzoneConsts.EXPECTED_GEN_CREATE_IF_NOT_EXISTS);
+
+ OpenKeySession openKey = ozoneManagerClient.openKey(builder.build());
+ if (isS3GRequest.get() && size == 0) {
+ openKey.getKeyInfo().setDataSize(0);
+ }
+ return createOutputStream(openKey);
+ }
+
+ @Override
+ @SuppressWarnings("checkstyle:parameternumber")
+ public OzoneOutputStream rewriteKeyIfMatch(String volumeName,
Review Comment:
looks like we can refactor & combine rewriteKey() and rewriteKeyIfMatch()
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1435,6 +1435,68 @@ public OzoneOutputStream rewriteKey(String volumeName,
String bucketName, String
return createOutputStream(openKey);
}
+ @Override
+ public OzoneOutputStream createKeyIfNotExists(String volumeName,
Review Comment:
this method looks very much the same as createKey(), except the addition of
expectedDataGeneration field. We should refactor & merge them into the same
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]