-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-10518. Create base Builder in WithMetadata and WithObjectID #6378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
176f2fd
d13984a
21d7db7
50107d4
4c2f5cd
65e61d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |
| */ | ||
| package org.apache.hadoop.ozone.om.helpers; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.Map; | ||
|
|
||
|
|
@@ -67,7 +66,7 @@ public final class OmBucketArgs extends WithMetadata implements Auditable { | |
| private final String ownerName; | ||
|
|
||
| private OmBucketArgs(Builder b) { | ||
| setMetadata(b.metadata); | ||
| super(b); | ||
| this.volumeName = b.volumeName; | ||
| this.bucketName = b.bucketName; | ||
| this.isVersionEnabled = b.isVersionEnabled; | ||
|
|
@@ -214,12 +213,11 @@ public Map<String, String> toAuditMap() { | |
| /** | ||
| * Builder for OmBucketArgs. | ||
| */ | ||
| public static class Builder { | ||
| public static class Builder extends WithMetadata.Builder { | ||
| private String volumeName; | ||
| private String bucketName; | ||
| private Boolean isVersionEnabled; | ||
| private StorageType storageType; | ||
| private final Map<String, String> metadata = new HashMap<>(); | ||
| private boolean quotaInBytesSet = false; | ||
| private long quotaInBytes; | ||
| private boolean quotaInNamespaceSet = false; | ||
|
|
@@ -258,8 +256,9 @@ public Builder setBucketEncryptionKey(BucketEncryptionKeyInfo info) { | |
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder addAllMetadata(Map<String, String> map) { | ||
| metadata.putAll(map); | ||
| super.addAllMetadata(map); | ||
|
Comment on lines
260
to
+261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| return this; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
|
|
||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -110,9 +109,7 @@ public static Codec<OmBucketInfo> getCodec() { | |
| private String owner; | ||
|
|
||
| private OmBucketInfo(Builder b) { | ||
| setMetadata(b.metadata); | ||
| setObjectID(b.objectID); | ||
| setUpdateID(b.updateID); | ||
| super(b); | ||
| this.volumeName = b.volumeName; | ||
| this.bucketName = b.bucketName; | ||
| this.acls = b.acls; | ||
|
|
@@ -361,20 +358,17 @@ public OmBucketInfo copyObject() { | |
| } | ||
|
|
||
| public Builder toBuilder() { | ||
| return new Builder() | ||
| return new Builder(this) | ||
| .setVolumeName(volumeName) | ||
| .setBucketName(bucketName) | ||
| .setStorageType(storageType) | ||
| .setIsVersionEnabled(isVersionEnabled) | ||
| .setCreationTime(creationTime) | ||
| .setModificationTime(modificationTime) | ||
| .setObjectID(getObjectID()) | ||
| .setUpdateID(getUpdateID()) | ||
| .setBucketEncryptionKey(bekInfo) | ||
| .setSourceVolume(sourceVolume) | ||
| .setSourceBucket(sourceBucket) | ||
| .setAcls(acls) | ||
| .addAllMetadata(getMetadata()) | ||
| .setUsedBytes(usedBytes) | ||
| .setUsedNamespace(usedNamespace) | ||
| .setQuotaInBytes(quotaInBytes) | ||
|
|
@@ -387,37 +381,30 @@ public Builder toBuilder() { | |
| /** | ||
| * Builder for OmBucketInfo. | ||
| */ | ||
| public static class Builder { | ||
| public static class Builder extends WithObjectID.Builder { | ||
| private String volumeName; | ||
| private String bucketName; | ||
| private List<OzoneAcl> acls; | ||
| private Boolean isVersionEnabled; | ||
| private StorageType storageType; | ||
| private final List<OzoneAcl> acls = new ArrayList<>(); | ||
| private boolean isVersionEnabled; | ||
| private StorageType storageType = StorageType.DISK; | ||
| private long creationTime; | ||
| private long modificationTime; | ||
| private long objectID; | ||
| private long updateID; | ||
| private Map<String, String> metadata; | ||
| private BucketEncryptionKeyInfo bekInfo; | ||
| private String sourceVolume; | ||
| private String sourceBucket; | ||
| private long usedBytes; | ||
| private long usedNamespace; | ||
| private long quotaInBytes; | ||
| private long quotaInNamespace; | ||
| private BucketLayout bucketLayout; | ||
| private long quotaInBytes = OzoneConsts.QUOTA_RESET; | ||
| private long quotaInNamespace = OzoneConsts.QUOTA_RESET; | ||
| private BucketLayout bucketLayout = BucketLayout.DEFAULT; | ||
| private String owner; | ||
| private DefaultReplicationConfig defaultReplicationConfig; | ||
|
|
||
| public Builder() { | ||
| //Default values | ||
| this.acls = new ArrayList<>(); | ||
| this.isVersionEnabled = false; | ||
| this.storageType = StorageType.DISK; | ||
| this.metadata = new HashMap<>(); | ||
| this.quotaInBytes = OzoneConsts.QUOTA_RESET; | ||
| this.quotaInNamespace = OzoneConsts.QUOTA_RESET; | ||
| this.bucketLayout = BucketLayout.DEFAULT; | ||
| } | ||
|
|
||
| private Builder(OmBucketInfo obj) { | ||
| super(obj); | ||
| } | ||
|
|
||
| public Builder setVolumeName(String volume) { | ||
|
|
@@ -448,7 +435,7 @@ public Builder addAcl(OzoneAcl ozoneAcl) { | |
| return this; | ||
| } | ||
|
|
||
| public Builder setIsVersionEnabled(Boolean versionFlag) { | ||
| public Builder setIsVersionEnabled(boolean versionFlag) { | ||
| this.isVersionEnabled = versionFlag; | ||
| return this; | ||
| } | ||
|
|
@@ -468,25 +455,27 @@ public Builder setModificationTime(long modifiedOn) { | |
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder setObjectID(long obId) { | ||
| this.objectID = obId; | ||
| super.setObjectID(obId); | ||
|
Comment on lines
459
to
+460
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder setUpdateID(long id) { | ||
| this.updateID = id; | ||
| super.setUpdateID(id); | ||
|
Comment on lines
465
to
+466
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder addMetadata(String key, String value) { | ||
| metadata.put(key, value); | ||
| super.addMetadata(key, value); | ||
|
Comment on lines
471
to
+472
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder addAllMetadata(Map<String, String> additionalMetadata) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| if (additionalMetadata != null) { | ||
| metadata.putAll(additionalMetadata); | ||
| } | ||
| super.addAllMetadata(additionalMetadata); | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -556,7 +545,6 @@ public OmBucketInfo build() { | |
| Preconditions.checkNotNull(volumeName); | ||
| Preconditions.checkNotNull(bucketName); | ||
| Preconditions.checkNotNull(acls); | ||
| Preconditions.checkNotNull(isVersionEnabled); | ||
| Preconditions.checkNotNull(storageType); | ||
| return new OmBucketInfo(this); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,6 @@ | |
| import org.apache.hadoop.ozone.OzoneConsts; | ||
| import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DirectoryInfo; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -55,12 +54,9 @@ public static Codec<OmDirectoryInfo> getCodec() { | |
| private final List<OzoneAcl> acls; | ||
|
|
||
| public OmDirectoryInfo(Builder builder) { | ||
| super(builder); | ||
| this.name = builder.name; | ||
| this.acls = builder.acls; | ||
| setMetadata(builder.metadata); | ||
| setObjectID(builder.objectID); | ||
| setUpdateID(builder.updateID); | ||
| setParentObjectID(builder.parentObjectID); | ||
| this.creationTime = builder.creationTime; | ||
| this.modificationTime = builder.modificationTime; | ||
| } | ||
|
|
@@ -77,38 +73,34 @@ public static OmDirectoryInfo.Builder newBuilder() { | |
| /** | ||
| * Builder for Directory Info. | ||
| */ | ||
| public static class Builder { | ||
| private long parentObjectID; // pointer to parent directory | ||
|
|
||
| private long objectID; | ||
| private long updateID; | ||
|
|
||
| public static class Builder extends WithParentObjectId.Builder { | ||
| private String name; | ||
|
|
||
| private long creationTime; | ||
| private long modificationTime; | ||
|
|
||
| private final List<OzoneAcl> acls; | ||
| private final Map<String, String> metadata; | ||
|
|
||
| public Builder() { | ||
| //Default values | ||
| this.acls = new LinkedList<>(); | ||
| this.metadata = new HashMap<>(); | ||
| } | ||
|
|
||
| @Override | ||
| public Builder setParentObjectID(long parentObjectId) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| this.parentObjectID = parentObjectId; | ||
| super.setParentObjectID(parentObjectId); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder setObjectID(long objectId) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| this.objectID = objectId; | ||
| super.setObjectID(objectId); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder setUpdateID(long updateId) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| this.updateID = updateId; | ||
| super.setUpdateID(updateId); | ||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -141,15 +133,15 @@ public Builder addAcl(OzoneAcl ozoneAcl) { | |
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder addMetadata(String key, String value) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| metadata.put(key, value); | ||
| super.addMetadata(key, value); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public Builder addAllMetadata(Map<String, String> additionalMetadata) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| if (additionalMetadata != null) { | ||
| metadata.putAll(additionalMetadata); | ||
| } | ||
| super.addAllMetadata(additionalMetadata); | ||
| return this; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
@Override.