anuragp010 commented on code in PR #12112:
URL: https://github.com/apache/ozone/pull/12112#discussion_r4651094239
##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java:
##########
@@ -1447,27 +1449,27 @@ public OzoneOutputStream createKey(
ReplicationConfig replicationConfig,
Map<String, String> metadata, Map<String, String> tags,
boolean derivedKeyPiggyBacking) throws IOException {
- String ownerName = getRealUserInfo().getShortUserName();
- OmKeyArgs.Builder builder = createWriteKeyArgsBuilder(volumeName,
- bucketName, keyName, size, replicationConfig, metadata, tags);
- builder.setOwnerName(ownerName);
-
builder.setDerivedKeyPiggyBacking(shouldPiggybackDerivedKey(derivedKeyPiggyBacking));
- return openOutputStream(builder.build(), size);
+ return createKey(volumeName, bucketName, keyName, new
CreateKeyOptions.Builder()
+ .setSize(size)
+ .setReplicationConfig(replicationConfig)
+ .setMetadata(metadata)
+ .setTags(tags)
+ .setDerivedKeyPiggyBacking(derivedKeyPiggyBacking)
+ .build());
}
@Override
- @SuppressWarnings("checkstyle:parameternumber")
public OzoneOutputStream createKey(
- String volumeName, String bucketName, String keyName, long size,
- ReplicationConfig replicationConfig,
- Map<String, String> metadata, Map<String, String> tags,
- StoragePolicy storagePolicy) throws IOException {
+ String volumeName, String bucketName, String keyName, CreateKeyOptions
options) throws IOException {
+ Objects.requireNonNull(options, "options == null");
String ownerName = getRealUserInfo().getShortUserName();
OmKeyArgs.Builder builder = createWriteKeyArgsBuilder(volumeName,
- bucketName, keyName, size, replicationConfig, metadata, tags);
+ bucketName, keyName, options.getSize(),
options.getReplicationConfig(), options.getMetadata(),
+ options.getTags());
builder.setOwnerName(ownerName);
- builder.setStoragePolicy(storagePolicy);
- return openOutputStream(builder.build(), size);
+
builder.setDerivedKeyPiggyBacking(shouldPiggybackDerivedKey(options.isDerivedKeyPiggyBacking()));
+ builder.setStoragePolicy(options.getStoragePolicy());
Review Comment:
Thanks for pointing this out @fmorg-git . Yes, the check should be there. I
was planning to take it up as part of
[HDDS-17530](https://issues.apache.org/jira/browse/HDDS-17530).
##########
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:
As of now, no storage policy tests use `OzoneBucketStub`. If a stub-based
test needs this method later, we can override it then with the required
functionality. What do you think?
--
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]