rakeshadr commented on code in PR #12112: URL: https://github.com/apache/ozone/pull/12112#discussion_r4668510125
########## hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/protocol/CreateFileOptions.java: ########## @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.client.protocol; + +import org.apache.hadoop.hdds.client.ReplicationConfig; + +/** + * Options for {@link ClientProtocol#createFile(String, String, String, CreateFileOptions)}. + * Encapsulates all optional parameters to allow future extensibility without adding a new overload for each of them. + */ +public final class CreateFileOptions { + Review Comment: Please add toString() to both classes and existing `MultipartUploadOptions` class as well. - When an options object shows up in a log or exception, today it gives CreateKeyOptions@3a7b1c2 and tells nothing. These are public API objects passed across RPC boundaries. - Something like, ``` @Override public String toString() { return "CreateKeyOptions{size=" + size + ", replicationConfig=" + replicationConfig + ", storagePolicy=" + storagePolicy + "}"; ``` ########## 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() Review Comment: Add `public static Builder builder()` factory methods to `CreateKeyOptions` and `CreateFileOptions`, matching the `ListStatusLightOptions.builder() `pattern already in the same package. It hides the internal Builder class from callers and reads as a single concept. Please include this in `MultipartUploadOptions` as well and was introduced as part of the same storage policy feature branch. ``` CreateKeyOptions.java — add after the constructor: public static Builder builder() { return new Builder(); } CreateFileOptions.java — same: public static Builder builder() { return new Builder(); } Callers then change from: new CreateKeyOptions.Builder() .setSize(size) .setReplicationConfig(config) .build(); to: CreateKeyOptions.builder() .setSize(size) .setReplicationConfig(config) .build(); ``` -- 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]
