You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/05/01 09:47:41 UTC

[GitHub] [ozone] adoroszlai commented on a diff in pull request #3333: HDDS-6622. Avoid constructor telescoping in OmMultipartUpload

adoroszlai commented on code in PR #3333:
URL: https://github.com/apache/ozone/pull/3333#discussion_r862435446


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartUpload.java:
##########
@@ -41,32 +41,13 @@ public class OmMultipartUpload {
 
   private ReplicationConfig replicationConfig;
 
-  public OmMultipartUpload(String volumeName, String bucketName,
-      String keyName, String uploadId) {
-    this.volumeName = volumeName;
-    this.bucketName = bucketName;
-    this.keyName = keyName;
-    this.uploadId = uploadId;
-  }
-
-  public OmMultipartUpload(String volumeName, String bucketName,
-      String keyName, String uploadId, Instant creationDate) {
-    this.volumeName = volumeName;
-    this.bucketName = bucketName;
-    this.keyName = keyName;
-    this.uploadId = uploadId;
-    this.creationTime = creationDate;
-  }

Review Comment:
   This one is unused, can be removed without builder.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartUpload.java:
##########
@@ -41,32 +41,13 @@ public class OmMultipartUpload {
 
   private ReplicationConfig replicationConfig;
 
-  public OmMultipartUpload(String volumeName, String bucketName,
-      String keyName, String uploadId) {
-    this.volumeName = volumeName;
-    this.bucketName = bucketName;
-    this.keyName = keyName;
-    this.uploadId = uploadId;
-  }

Review Comment:
   This constructor sets the "DB key" part of `OmMultipartUpload`.  It is used by `KeyManagerImpl.listMultipartUploads` (via `from()`), which looks up the object by the DB key, then fills the rest of the info (creation time, replication config).  Other code expects these additional data to be present in `OmMultipartUpload`, so they are not optional, but the incomplete constructor does not enforce this.
   
   https://github.com/apache/ozone/blob/d2ac33627ad83e8a3e5e8ec6db113a9d4779612b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java#L619-L640
   
   I think it would be better to extract these fields of `OmMultipartUpload` (plus the constructor and `from()`) into a separate class (`OmMultipartUploadDbKey`?).  `from()` would create an instance of the DB key instead of the incomplete `OmMultipartUpload`.  This would allow `OmMultipartUpload` to always be completely initialized (with `OmMultipartUploadDbKey`, creation time and replication config), and only one constructor would be left in `OmMultipartUpload`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org