sodonnel commented on PR #6385:
URL: https://github.com/apache/ozone/pull/6385#issuecomment-2035638173

   @kerneltime After a discussion we had, you suggested the 
OzoneBucket.overwriteKey(...) API does not seem correct. I agree that the Java 
doc and the method name are not good and should be changed. However the way the 
API works is in the same pattern as the existing similar methods.
   
   For example createKey looks like:
   
   ```
     public OzoneOutputStream createKey(String key, long size,
         ReplicationConfig replicationConfig,
         Map<String, String> keyMetadata)
         throws IOException {
       return proxy
           .createKey(volumeName, name, key, size, replicationConfig, 
keyMetadata);
     }
   ```
   Note it takes the keyName and repConfig and returns an output stream.
   
   The way the new API is intended to be used, is to replace an existing key 
with a new replication type. To do that, the user must first get the 
OzoneKeyDetails of the existing key, which will container the updateID along 
with the keyName etc. Therefore the new API allows those key details to be 
passed in directly.
   
   ```
   OzoneKeyDetails exisitingKey = bucket.getKey(keyName);
   try (OutputStream os = bucket.overwriteKey(existingKey, newRepConfig) {
     os.write(bucket.readKey(keyName))
   }
   ```
   
   To me this makes perfect sense as a usable API without any extra 
manipulation of the key read. It is pretty much in the same pattern as the the 
other existing APIs, which was my intention.
   
   It would be possible to change the parameter list to something like:
   
   ```
   bucket.atomicallyOverwriteKey(String keyName, long existingKeyUpdateID, 
ReplicationConfig newRepConfig)
   ```
   
   But I actually think that is worse to use, as you then have to extract 
pieces from the keyInfo you loaded. And it directly exposes the updateID, which 
at the moment is hidden. Perhaps we want to expose it, but perhaps not at this 
stage. I may also be possible to overload the API to have both options.


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