devmadhuu commented on code in PR #12160:
URL: https://github.com/apache/ozone/pull/12160#discussion_r4706529048
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1535,27 +1542,66 @@ public OzoneOutputStream rewriteKeyIfMatch(String
volumeName,
String bucketName, String keyName, long size, String expectedETag,
ReplicationConfig replicationConfig, Map<String, String> metadata,
Map<String, String> tags, boolean derivedKeyPiggyBacking) throws
IOException {
+ return rewriteKeyIfMatch(volumeName, bucketName, keyName, expectedETag,
+ toCreateKeyOptions(size, replicationConfig, metadata, tags,
derivedKeyPiggyBacking));
+ }
+
+ @Override
+ public OzoneOutputStream rewriteKeyIfMatch(String volumeName, String
bucketName, String keyName,
+ String expectedETag, CreateKeyOptions options) throws IOException {
+ Objects.requireNonNull(options, "options == null");
if (!OzoneManagerVersion.ATOMIC_REWRITE_KEY.isSupportedBy(omVersion)) {
throw new IOException(
"OzoneManager does not support conditional key rewrite.");
}
+ checkStoragePolicySupport(options.getStoragePolicy());
OmKeyArgs.Builder builder = createWriteKeyArgsBuilder(volumeName,
- bucketName, keyName, size, replicationConfig, metadata, tags);
+ bucketName, keyName, options.getSize(),
options.getReplicationConfig(), options.getMetadata(),
+ options.getTags());
builder.setExpectedETag(expectedETag);
-
builder.setDerivedKeyPiggyBacking(shouldPiggybackDerivedKey(derivedKeyPiggyBacking));
- return openOutputStream(builder.build(), size);
+
builder.setDerivedKeyPiggyBacking(shouldPiggybackDerivedKey(options.isDerivedKeyPiggyBacking()));
+ builder.setStoragePolicy(options.getStoragePolicy());
+ return openOutputStream(builder.build(), options.getSize());
}
@Override
@SuppressWarnings("checkstyle:parameternumber")
public OzoneOutputStream createKeyIfNoneMatch(String volumeName, String
bucketName, String keyName, long size,
String excludedETag, ReplicationConfig replicationConfig, Map<String,
String> metadata, Map<String, String> tags,
boolean derivedKeyPiggyBacking) throws IOException {
+ return createKeyIfNoneMatch(volumeName, bucketName, keyName, excludedETag,
+ toCreateKeyOptions(size, replicationConfig, metadata, tags,
derivedKeyPiggyBacking));
+ }
+
+ @Override
+ public OzoneOutputStream createKeyIfNoneMatch(String volumeName, String
bucketName, String keyName,
+ String excludedETag, CreateKeyOptions options) throws IOException {
+ Objects.requireNonNull(options, "options == null");
checkIfNoneMatchETagSupport();
- OmKeyArgs.Builder builder = createWriteKeyArgsBuilder(volumeName,
bucketName, keyName, size, replicationConfig,
- metadata, tags);
-
builder.setExcludedETag(excludedETag).setDerivedKeyPiggyBacking(derivedKeyPiggyBacking);
- return openOutputStream(builder.build(), size);
+ checkStoragePolicySupport(options.getStoragePolicy());
+ OmKeyArgs.Builder builder = createWriteKeyArgsBuilder(volumeName,
bucketName, keyName, options.getSize(),
+ options.getReplicationConfig(), options.getMetadata(),
options.getTags());
+
builder.setExcludedETag(excludedETag).setDerivedKeyPiggyBacking(options.isDerivedKeyPiggyBacking());
+ builder.setStoragePolicy(options.getStoragePolicy());
+ return openOutputStream(builder.build(), options.getSize());
+ }
+
+ private static CreateKeyOptions toCreateKeyOptions(long size,
ReplicationConfig replicationConfig,
+ Map<String, String> metadata, Map<String, String> tags, boolean
derivedKeyPiggyBacking) {
+ return CreateKeyOptions.builder()
+ .setSize(size)
+ .setReplicationConfig(replicationConfig)
+ .setMetadata(metadata)
+ .setTags(tags)
+ .setDerivedKeyPiggyBacking(derivedKeyPiggyBacking)
+ .build();
+ }
+
+ /** Rejects a key storage policy before sending it to an OM that would
ignore it. */
+ private void checkStoragePolicySupport(StoragePolicy storagePolicy) throws
IOException {
Review Comment:
Done. `checkStoragePolicySupported()` now throws `OMException` with
`NOT_SUPPORTED_OPERATION` (still an IOException, same message), so S3 Gateway's
existing mapping returns `NotImplemented (501)` for `PutObject, CopyObject and
CreateMultipartUpload` instead of `500`, and the same request works once the OM
upgrade is finalized. Added tests for the client result code and for the 501
responses. Other OM-version checks in `RpcClient` (object tags, If-None-Match,
atomic rewrite, …) still return 500 through S3 Gateway; I'll track those in a
separate JIRA.
--
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]