Repository navigation
HDDS-4053. Volume space: add quotaUsageInBytes and update it when write and delete key. #1296
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.concurrent.atomic.LongAdder; | ||
|
|
||
| import org.apache.hadoop.ozone.OzoneAcl; | ||
| import org.apache.hadoop.ozone.OzoneConsts; | ||
|
|
@@ -46,6 +47,7 @@ public final class OmVolumeArgs extends WithObjectID implements Auditable { | |
| private long quotaInBytes; | ||
| private long quotaInCounts; | ||
| private final OmOzoneAclMap aclMap; | ||
| private final LongAdder usedBytes = new LongAdder(); | ||
|
|
||
| /** | ||
| * Private constructor, constructed via builder. | ||
|
|
@@ -55,6 +57,7 @@ public final class OmVolumeArgs extends WithObjectID implements Auditable { | |
| * @param quotaInBytes - Volume Quota in bytes. | ||
| * @param quotaInCounts - Volume Quota in counts. | ||
| * @param metadata - metadata map for custom key/value data. | ||
| * @param usedBytes - Volume Quota Usage in bytes. | ||
| * @param aclMap - User to access rights map. | ||
| * @param creationTime - Volume creation time. | ||
| * @param objectID - ID of this object. | ||
|
|
@@ -65,14 +68,15 @@ public final class OmVolumeArgs extends WithObjectID implements Auditable { | |
| "builder."}) | ||
| private OmVolumeArgs(String adminName, String ownerName, String volume, | ||
| long quotaInBytes, long quotaInCounts, Map<String, String> metadata, | ||
| OmOzoneAclMap aclMap, long creationTime, long modificationTime, | ||
| long objectID, long updateID) { | ||
| long usedBytes, OmOzoneAclMap aclMap, long creationTime, | ||
| long modificationTime, long objectID, long updateID) { | ||
| this.adminName = adminName; | ||
| this.ownerName = ownerName; | ||
| this.volume = volume; | ||
| this.quotaInBytes = quotaInBytes; | ||
| this.quotaInCounts = quotaInCounts; | ||
| this.metadata = metadata; | ||
| this.usedBytes.add(usedBytes); | ||
| this.aclMap = aclMap; | ||
| this.creationTime = creationTime; | ||
| this.modificationTime = modificationTime; | ||
|
|
@@ -172,6 +176,11 @@ public long getQuotaInCounts() { | |
| public OmOzoneAclMap getAclMap() { | ||
| return aclMap; | ||
| } | ||
|
|
||
| public LongAdder getUsedBytes() { | ||
| return usedBytes; | ||
| } | ||
|
|
||
| /** | ||
| * Returns new builder class that builds a OmVolumeArgs. | ||
| * | ||
|
|
@@ -195,6 +204,8 @@ public Map<String, String> toAuditMap() { | |
| String.valueOf(this.quotaInCounts)); | ||
| auditMap.put(OzoneConsts.OBJECT_ID, String.valueOf(this.getObjectID())); | ||
| auditMap.put(OzoneConsts.UPDATE_ID, String.valueOf(this.getUpdateID())); | ||
| auditMap.put(OzoneConsts.USED_BYTES, | ||
| String.valueOf(this.usedBytes)); | ||
| return auditMap; | ||
| } | ||
|
|
||
|
|
@@ -230,6 +241,7 @@ public static class Builder { | |
| private OmOzoneAclMap aclMap; | ||
| private long objectID; | ||
| private long updateID; | ||
| private long usedBytes; | ||
|
|
||
| /** | ||
| * Sets the Object ID for this Object. | ||
|
|
@@ -307,6 +319,11 @@ public Builder addAllMetadata(Map<String, String> additionalMetaData) { | |
| return this; | ||
| } | ||
|
|
||
| public Builder setUsedBytes(long quotaUsage) { | ||
| this.usedBytes = quotaUsage; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder addOzoneAcls(OzoneAclInfo acl) throws IOException { | ||
| aclMap.addAcl(acl); | ||
| return this; | ||
|
|
@@ -321,8 +338,8 @@ public OmVolumeArgs build() { | |
| Preconditions.checkNotNull(ownerName); | ||
| Preconditions.checkNotNull(volume); | ||
| return new OmVolumeArgs(adminName, ownerName, volume, quotaInBytes, | ||
| quotaInCounts, metadata, aclMap, creationTime, modificationTime, | ||
| objectID, updateID); | ||
| quotaInCounts, metadata, usedBytes, aclMap, creationTime, | ||
| modificationTime, objectID, updateID); | ||
| } | ||
|
|
||
| } | ||
|
|
@@ -342,6 +359,7 @@ public VolumeInfo getProtobuf() { | |
| .setModificationTime(modificationTime) | ||
| .setObjectID(objectID) | ||
| .setUpdateID(updateID) | ||
| .setUsedBytes(usedBytes.sum()) | ||
| .build(); | ||
| } | ||
|
|
||
|
|
@@ -356,6 +374,7 @@ public static OmVolumeArgs getFromProtobuf(VolumeInfo volInfo) | |
| volInfo.getQuotaInBytes(), | ||
| volInfo.getQuotaInCounts(), | ||
| KeyValueUtil.getFromProtobuf(volInfo.getMetadataList()), | ||
| volInfo.getUsedBytes(), | ||
| aclMap, | ||
| volInfo.getCreationTime(), | ||
| volInfo.getModificationTime(), | ||
|
|
@@ -370,7 +389,8 @@ public String getObjectInfo() { | |
| ", admin='" + adminName + '\'' + | ||
| ", owner='" + ownerName + '\'' + | ||
| ", creationTime='" + creationTime + '\'' + | ||
| ", quota='" + quotaInBytes + '\'' + | ||
| ", quotaInBytes='" + quotaInBytes + '\'' + | ||
| ", usedBytes='" + usedBytes.sum() + '\'' + | ||
| '}'; | ||
| } | ||
|
|
||
|
|
@@ -386,7 +406,7 @@ public OmVolumeArgs copyObject() { | |
| OmOzoneAclMap cloneAclMap = aclMap.copyObject(); | ||
|
|
||
| return new OmVolumeArgs(adminName, ownerName, volume, quotaInBytes, | ||
| quotaInCounts, cloneMetadata, cloneAclMap, creationTime, | ||
| modificationTime, objectID, updateID); | ||
| quotaInCounts, cloneMetadata, usedBytes.sum(), cloneAclMap, | ||
| creationTime, modificationTime, objectID, 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. Should getObjectInfo also be changed? |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.