Skip to content

Conversation

@adoroszlai
Copy link
Contributor

@adoroszlai adoroszlai commented Mar 14, 2024

What changes were proposed in this pull request?

Builders in subclasses of WithMetadata and WithObjectID all have their own code for setting the properties from the base classes. The goal of this task is to reduce code duplication by creating builders in the base classes and using them in the subclasses.

Existing subclass builder methods are kept for covariant return to be able to keep existing chained method calls (e.g. return OmBucketInfo instead of WithMetadata). We can remove them after replacing with non-chained calls in a follow-up patch.

https://issues.apache.org/jira/browse/HDDS-10518

How was this patch tested?

CI:
https://github.com/adoroszlai/ozone/actions/runs/8277449313

@adoroszlai adoroszlai self-assigned this Mar 14, 2024
@adoroszlai
Copy link
Contributor Author

@ivandika3 please take a look as well

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch. Mostly LGTM. Few minor comments.

Comment on lines 987 to 986
this.metadata = metadata;
addAllMetadata(metadata);
Copy link
Contributor

@ivandika3 ivandika3 Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Should not affect current usage, but the semantic seems to be changed changed from "replacing" to "adding". Might need to clear the metadata before adding it or can change the method name to addAllMetadata (but OzoneBucket is client-facing class so might not be a good idea).

I'm OK if you decide not to change it at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated to clear any existing metadata for these two classes.


public Builder setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
addAllMetadata(metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment to OzoneBucket.Builder#setMetadata.

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the update. LGTM +1.

@adoroszlai adoroszlai requested a review from szetszwo March 26, 2024 21:22
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adoroszlai , thanks for working on this! The change look good. I just have comments on adding @Override tag.

Comment on lines 984 to 986

public Builder setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
super.setMetadata(metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

Comment on lines 484 to +485

public Builder setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
super.setMetadata(metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

Comment on lines 259 to +260
public Builder addAllMetadata(Map<String, String> map) {
metadata.putAll(map);
super.addAllMetadata(map);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

Comment on lines 458 to +459
public Builder setObjectID(long obId) {
this.objectID = obId;
super.setObjectID(obId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

Comment on lines 463 to +464
public Builder setUpdateID(long id) {
this.updateID = id;
super.setUpdateID(id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

* System.
* @param id - long
*/
public Builder setObjectID(long id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

* increasing values which are updated each time there is an update.
* @param id - long
*/
public Builder setUpdateID(long id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

return this;
}

public Builder addMetadata(String key, String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

return this;
}

public Builder addAllMetadata(Map<String, String> additionalMetaData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

return this;
}

public OmPrefixInfo.Builder addMetadata(String key, String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Override.

@adoroszlai
Copy link
Contributor Author

Thanks @szetszwo for the review, added all missing @Override annotations.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@szetszwo szetszwo merged commit 7feafe9 into apache:master Mar 27, 2024
@adoroszlai
Copy link
Contributor Author

Thanks @ivandika3, @szetszwo for the review.

@adoroszlai adoroszlai deleted the HDDS-10518 branch March 27, 2024 16:22
jojochuang pushed a commit to jojochuang/ozone that referenced this pull request May 29, 2024
swamirishi pushed a commit to swamirishi/ozone that referenced this pull request Dec 3, 2025
…bjectID (apache#6378)

(cherry picked from commit 7feafe9)

 Conflicts:
	hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketArgs.java
	hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmBucketInfo.java
	hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmDirectoryInfo.java
	hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
	hadoop-ozone/interface-storage/src/main/java/org/apache/hadoop/ozone/om/helpers/OmPrefixInfo.java
	hadoop-ozone/interface-storage/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmPrefixInfo.java
	hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/common/CommonUtils.java

Change-Id: Ie89b7ee52e0a8f33341700b03b28983895d72e55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants