Gargi-jais11 commented on code in PR #12160:
URL: https://github.com/apache/ozone/pull/12160#discussion_r4705504485


##########
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:
   Refusing the write is the right call, but S3 Gateway turns this plain 
IOException into 500 InternalError. During a rolling OM upgrade, GLACIER PUTs 
(and every STANDARD PUT, if `standard.storage-policy `is configured) would fail 
with 500. Could S3 Gateway map this to a clear 4xx/501 error saying OM doesn't 
support storage policies yet? 



-- 
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]

Reply via email to