devmadhuu commented on code in PR #12112:
URL: https://github.com/apache/ozone/pull/12112#discussion_r4651464166


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -2654,13 +2669,13 @@ public OzoneOutputStream createFile(String volumeName, 
String bucketName,
         .setVolumeName(volumeName)
         .setBucketName(bucketName)
         .setKeyName(keyName)
-        .setDataSize(size)
+        .setDataSize(options.getSize())
         .setReplicationConfig(replicationConfig)
         .setLatestVersionLocation(getLatestVersionLocation)
         .setOwnerName(ownerName)
         .build();

Review Comment:
   Any reason we are not reading storage policy and setting in keyargs from 
options ?
   
   I understand the wiring is planned in HDDS-16991. Until then this is a 
public setter that is silently ignored.
   Could we leave `storagePolicy` out of `CreateFileOptions` in this PR, and 
let HDDS-16991 (#12022) add the field
   together with the request wiring and the version check? #12022 already has 
its own `CreateFileOptions`, so it
   needs a rebase anyway. If you prefer to keep the field, then please throw 
when a non-null policy is set, and
   remove "storage policy" from the two Javadocs until it is supported.
   
   Also pls check `OzoneManagerProtocolClientSideTranslatorPB.createFile` 
doesn't send the field either ?
   
   



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java:
##########
@@ -1317,6 +1307,23 @@ public OzoneOutputStream createFile(String keyName, long 
size,
             overWrite, recursive);
   }
 
+  /**
+   * OzoneFS api to create an output stream for a file.
+   *
+   * @param keyName Key name
+   * @param options Size, replication config, overwrite, recursive flags and 
storage policy of the file

Review Comment:
   Here in javadoc , we are mentioning that accepting storage policy but 
dropping in `RpcClient.CreateFile` ?



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/ClientProtocol.java:
##########
@@ -1292,6 +1279,24 @@ OzoneOutputStream createFile(String volumeName, String 
bucketName,
       String keyName, long size, ReplicationConfig replicationConfig,
       boolean overWrite, boolean recursive) throws IOException;
 
+  /**
+   * Creates an output stream for writing to a file.
+   *
+   * @param volumeName Volume name
+   * @param bucketName Bucket name
+   * @param keyName    Absolute path of the file to be written
+   * @param options    Size, replication config, overwrite, recursive flags 
and storage policy of the file

Review Comment:
   Here in javadoc , we are mentioning that accepting storage policy but 
dropping in RpcClient.CreateFile ?



##########
hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/rpc/TestRpcClient.java:
##########
@@ -751,6 +753,30 @@ public OMResponse submitRequest(OMRequest request) throws 
IOException {
     }
   }
 
+  @Test
+  public void testCreateKeyRejectsNullOptions() throws IOException {

Review Comment:
   nit: `CreateKeyOptions` is the first API that can carry a storage policy and 
derived key piggybacking in one
   request. Before this PR, the `boolean derivedKeyPiggyBacking` overload and 
the `StoragePolicy` overload were
   separate. `testDerivedKeyPiggybackVersionGate` still uses the old overload, 
so no test sends both values together.
   
   Could we add a case that reuses the same `MockOmTransport` capture, calls
   `client.createKey("volume", "bucket", "key", options)` with 
`.setStoragePolicy(OzoneStoragePolicy.HOT)` and
   `.setDerivedKeyPiggyBacking(true)` on an OM that supports `S3_DERIVED_KEY`, 
and checks that the captured
   `CreateKeyRequest` has `getDerivedKeyPiggyBacking() == true` and
   `getKeyArgs().getStoragePolicy() == StoragePolicyProto.HOT`? Then dropping 
either `builder.set...` call in
   `RpcClient#createKey` would fail the test.



##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java:
##########
@@ -581,28 +583,16 @@ public OzoneOutputStream createKey(String key, long size,
   }
 
   /**
-   * Creates a new key in this bucket and places it according to the given 
storage
-   * policy.
+   * Creates a new key in the bucket.
    *
-   * @param key               Name of the key to be created.
-   * @param size              Size of the data the key will hold.
-   * @param replicationConfig Replication configuration.
-   * @param keyMetadata       Custom key metadata.
-   * @param tags              Tags used for S3 object tags.
-   * @param keyStoragePolicy  Storage policy for the key, or null to inherit 
this
-   *                          bucket's policy.
+   * @param key     Name of the key to be created.
+   * @param options Size, replication config, metadata, tags, derived key 
piggybacking and storage policy of the key
    * @return OzoneOutputStream to which the data has to be written.
    * @throws IOException
    */
-  @SuppressWarnings("checkstyle:parameternumber")
-  public OzoneOutputStream createKey(String key, long size,
-      ReplicationConfig replicationConfig,
-      Map<String, String> keyMetadata,
-      Map<String, String> tags,
-      StoragePolicy keyStoragePolicy)
-      throws IOException {
-    return proxy
-        .createKey(volumeName, name, key, size, replicationConfig, 
keyMetadata, tags, keyStoragePolicy);
+  public OzoneOutputStream createKey(String key, CreateKeyOptions options) 
throws IOException {

Review Comment:
   @anuragp010 : One more data point here. This PR's 
`ClientProtocolStub#createKey(..., CreateKeyOptions)` already calls
   `getBucket(volumeName, bucketName).createKey(keyName, options)`. 
`OzoneBucketStub` does not override that
   method, so it goes to `OzoneBucket#createKey`, which calls 
`proxy.createKey(...)`. Stub buckets are created
   by `OzoneVolumeStub#createBucket` through `OzoneBucketStub.newBuilder()`, 
which never sets `proxy`, so this
   throws an NPE.
   
   On the base branch, the same call went to the `ClientProtocol` default 
method, which called the 7-arg
   `createKey` that the stub implements. So the stub path worked before (it 
only dropped the policy) and fails
   now. Nothing calls it today, but S3 storage class support will send the 
policy from `ObjectEndpoint`
   through this method, and every s3gateway write test that uses the stub would 
then fail.
   
   The override is small, so I think it is worth adding here:
   
       @Override
       public OzoneOutputStream createKey(String key, CreateKeyOptions options) 
throws IOException {
         return addDerivedKey(createKey(key, options.getSize(), 
options.getReplicationConfig(),
             options.getMetadata(), options.getTags()), 
options.isDerivedKeyPiggyBacking());
       }



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