This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 6e611721c37 HDDS-17753. Replace Pair with domain objects in
ozone-common and ozone-client (#12047)
6e611721c37 is described below
commit 6e611721c3770533f5dd7d96f2f10dc3cd0fce4d
Author: Navink <[email protected]>
AuthorDate: Sun Nov 15 00:36:48 2026 +0530
HDDS-17753. Replace Pair with domain objects in ozone-common and
ozone-client (#12047)
---
.../apache/hadoop/ozone/client/OzoneBucket.java | 64 +++++++++++++---------
.../hadoop/ozone/client/OzoneClientUtils.java | 37 +++++++++++--
.../ozone/client/OzoneLifecycleConfiguration.java | 8 +--
.../apache/hadoop/ozone/om/helpers/OmKeyInfo.java | 33 +++++++----
.../apache/hadoop/ozone/om/helpers/OmLCFilter.java | 26 ++++++++-
.../hadoop/ozone/om/helpers/RepeatedOmKeyInfo.java | 30 ++++++++--
.../apache/hadoop/ozone/om/helpers/OMLCUtils.java | 4 +-
.../hadoop/ozone/om/helpers/TestOmLCFilter.java | 16 +++---
.../hadoop/ozone/om/helpers/TestOmLCRule.java | 8 +--
.../om/helpers/TestOmLifeCycleConfiguration.java | 4 +-
.../hadoop/ozone/om/service/QuotaRepairTask.java | 2 +-
.../ozone/recon/api/ReconGlobalMetricsService.java | 2 +-
.../recon/tasks/DeletedKeysInsightHandler.java | 20 +++----
.../ozone/recon/tasks/TestOmTableInsightTask.java | 9 ++-
14 files changed, 177 insertions(+), 86 deletions(-)
diff --git
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
index 0898a2fc763..054f853a4cb 100644
---
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
+++
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneBucket.java
@@ -35,8 +35,6 @@
import java.util.Stack;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
import org.apache.hadoop.hdds.client.OzoneQuota;
import org.apache.hadoop.hdds.client.ReplicationConfig;
@@ -1834,7 +1832,7 @@ private static OzoneKey toOzoneKey(OzoneFileStatusLight
status) {
*/
private class KeyIteratorWithFSO extends KeyIterator {
- private Stack<Pair<String, String>> stack;
+ private Stack<KeyPrefixAndStartKey> stack;
private String removeStartKey = "";
/**
@@ -1863,13 +1861,12 @@ private class KeyIteratorWithFSO extends KeyIterator {
* @param seekPaths list of seek paths between keyPrefix and startKey
*/
private void getSeekPathsBetweenKeyPrefixAndStartKey(String keyPrefix,
- String startKey, List<Pair<String, String>> seekPaths) {
+ String startKey, List<KeyPrefixAndStartKey> seekPaths) {
String parentStartKeyPath = OzoneFSUtils.getParentDir(startKey);
-
if (StringUtils.isNotBlank(startKey)) {
if (StringUtils.compare(parentStartKeyPath, keyPrefix) >= 0) {
- seekPaths.add(new ImmutablePair<>(parentStartKeyPath, startKey));
+ seekPaths.add(new KeyPrefixAndStartKey(parentStartKeyPath,
startKey));
// recursively fetch all the sub-paths between keyPrefix and prevKey
getSeekPathsBetweenKeyPrefixAndStartKey(keyPrefix,
parentStartKeyPath,
@@ -1877,7 +1874,7 @@ private void
getSeekPathsBetweenKeyPrefixAndStartKey(String keyPrefix,
} else if (StringUtils.compare(startKey, keyPrefix) >= 0) {
// Both keyPrefix and startKey reached at the same level.
// Adds partial keyPrefix and startKey for seek.
- seekPaths.add(new ImmutablePair<>(keyPrefix, startKey));
+ seekPaths.add(new KeyPrefixAndStartKey(keyPrefix, startKey));
}
}
}
@@ -1912,9 +1909,8 @@ List<OzoneKey> getNextListOfKeys(String prevKey) throws
IOException {
// seek pointer to next level(depth) in FS tree.
// case: startKey is non-empty
while (!stack.isEmpty()) {
- Pair<String, String> keyPrefixPath = stack.pop();
- if (getChildrenKeys(keyPrefixPath.getLeft(), keyPrefixPath.getRight(),
- keysResultList)) {
+ KeyPrefixAndStartKey keyPrefixPath = stack.pop();
+ if (getChildrenKeys(keyPrefixPath.getKeyPrefix(),
keyPrefixPath.getStartKey(), keysResultList)) {
// reached limit batch size.
break;
}
@@ -1944,9 +1940,8 @@ List<OzoneKey> getNextShallowListOfKeys(String prevKey)
} else {
// Case: startKey is non-empty
while (!stack.isEmpty()) {
- Pair<String, String> keyPrefixPath = stack.pop();
- getChildrenKeys(keyPrefixPath.getLeft(), keyPrefixPath.getRight(),
- firstKeyResult);
+ KeyPrefixAndStartKey keyPrefixPath = stack.pop();
+ getChildrenKeys(keyPrefixPath.getKeyPrefix(),
keyPrefixPath.getStartKey(), firstKeyResult);
if (!firstKeyResult.isEmpty()) {
break;
}
@@ -2041,7 +2036,7 @@ private boolean prepareStack(String prevKey) throws
IOException {
// |-------------------------------------|
// bottom | < a1, a1/b2 > |
// --------------------------------------|
- List<Pair<String, String>> seekPaths = new ArrayList<>();
+ List<KeyPrefixAndStartKey> seekPaths = new ArrayList<>();
if (StringUtils.isNotBlank(getKeyPrefix())) {
// If the prev key is a dir then seek its sub-paths
@@ -2057,7 +2052,7 @@ private boolean prepareStack(String prevKey) throws
IOException {
// 2. Push elements in reverse order so that the FS tree traversal
// will occur in left-to-right fashion[Depth-First Search]
for (int index = seekPaths.size() - 1; index >= 0; index--) {
- Pair<String, String> seekDirPath = seekPaths.get(index);
+ KeyPrefixAndStartKey seekDirPath = seekPaths.get(index);
stack.push(seekDirPath);
}
} else if (StringUtils.isNotBlank(getKeyPrefix())) {
@@ -2065,7 +2060,7 @@ private boolean prepareStack(String prevKey) throws
IOException {
// Case-1 - compare: keyPrefix="a1/b2", startKey="a1/b123Invalid"
or "a0/b123Invalid"
// Since startKey is lexographically behind keyPrefix,
// the seek precedence goes to keyPrefix.
- stack.push(new ImmutablePair<>(getKeyPrefix(), ""));
+ stack.push(new KeyPrefixAndStartKey(getKeyPrefix(), ""));
} else if (!OzoneFSUtils.isAncestorPath(getKeyPrefix(), prevKey)) {
// Case-2 - sibling: keyPrefix="a1/b2", startKey="a2/b1"
// Skip traversing, if the startKey is not a sibling.
@@ -2095,15 +2090,12 @@ private boolean keyPrefixExist() throws IOException {
return keyPrefixStatus != null;
}
- private void addPrevDirectoryToSeekPath(String prevKey,
- List<Pair<String, String>> seekPaths)
- throws IOException {
+ private void addPrevDirectoryToSeekPath(String prevKey,
List<KeyPrefixAndStartKey> seekPaths) throws IOException {
try {
- OzoneFileStatus prevStatus =
- proxy.getOzoneFileStatus(volumeName, name, prevKey);
+ OzoneFileStatus prevStatus = proxy.getOzoneFileStatus(volumeName,
name, prevKey);
if (prevStatus != null) {
if (prevStatus.isDirectory()) {
- seekPaths.add(new ImmutablePair<>(prevKey, ""));
+ seekPaths.add(new KeyPrefixAndStartKey(prevKey, ""));
}
}
} catch (OMException ome) {
@@ -2193,17 +2185,17 @@ private boolean getChildrenKeys(String keyPrefix,
String startKey,
if (status.isDirectory()) {
// Adding in-progress keyPath back to the stack to make sure
// all the siblings will be fetched.
- stack.push(new ImmutablePair<>(keyPrefix, keyInfo.getKeyName()));
+ stack.push(new KeyPrefixAndStartKey(keyPrefix,
keyInfo.getKeyName()));
// Adding current directory to the stack, so that this dir will be
// the top element. Moving seek pointer to fetch sub-paths
- stack.push(new ImmutablePair<>(keyInfo.getKeyName(), ""));
+ stack.push(new KeyPrefixAndStartKey(keyInfo.getKeyName(), ""));
// Return it so that the next iteration will be
// started using the stacked items.
return true;
} else if (indx == statuses.size() - 1) {
// The last element is a FILE and reaches the listCacheSize.
// Now, sets next seek key to this element
- stack.push(new ImmutablePair<>(keyPrefix, keyInfo.getKeyName()));
+ stack.push(new KeyPrefixAndStartKey(keyPrefix,
keyInfo.getKeyName()));
// Return it so that the next iteration will be
// started using the stacked items.
return true;
@@ -2315,4 +2307,26 @@ public BucketLayout getBucketLayout() {
public ReplicationConfig getReplicationConfig() {
return this.defaultReplication;
}
+
+ /**
+ * A key prefix paired with the start key to seek from under it,
+ * used as a pending directory listing position by the FSO key iterator.
+ */
+ private static final class KeyPrefixAndStartKey {
+ private final String keyPrefix;
+ private final String startKey;
+
+ private KeyPrefixAndStartKey(String keyPrefix, String startKey) {
+ this.keyPrefix = keyPrefix;
+ this.startKey = startKey;
+ }
+
+ private String getKeyPrefix() {
+ return keyPrefix;
+ }
+
+ private String getStartKey() {
+ return startKey;
+ }
+ }
}
diff --git
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
index 47a13a04722..8fcdbbbbf14 100644
---
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
+++
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneClientUtils.java
@@ -28,7 +28,6 @@
import java.io.IOException;
import java.util.Objects;
import java.util.Set;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.FileChecksum;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationFactor;
@@ -61,11 +60,9 @@ private OzoneClientUtils() {
public static BucketLayout resolveLinkBucketLayout(OzoneBucket bucket,
ObjectStore objectStore,
- Set<Pair<String,
- String>> visited)
- throws IOException {
+ Set<VolumeBucket>
visited) throws IOException {
if (bucket.isLink()) {
- if (!visited.add(Pair.of(bucket.getVolumeName(),
+ if (!visited.add(new VolumeBucket(bucket.getVolumeName(),
bucket.getName()))) {
throw new OMException("Detected loop in bucket links. Bucket name: " +
bucket.getName() + ", Volume name: " + bucket.getVolumeName(),
@@ -294,4 +291,34 @@ public static void deleteSnapshot(ObjectStore objectStore,
exception.getMessage());
}
}
+
+ /**
+ * A volume name paired with a bucket name, used to track the visited
buckets when detecting loops in bucket links.
+ */
+ public static final class VolumeBucket {
+ private final String volume;
+ private final String bucket;
+
+ public VolumeBucket(String volume, String bucket) {
+ this.volume = volume;
+ this.bucket = bucket;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ VolumeBucket that = (VolumeBucket) o;
+ return Objects.equals(volume, that.volume) && Objects.equals(bucket,
that.bucket);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(volume, bucket);
+ }
+ }
}
diff --git
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneLifecycleConfiguration.java
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneLifecycleConfiguration.java
index a325f3820d0..f3562fb64ec 100644
---
a/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneLifecycleConfiguration.java
+++
b/hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneLifecycleConfiguration.java
@@ -20,7 +20,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.ozone.om.helpers.OmLCFilter.Tag;
import org.apache.hadoop.ozone.om.helpers.OmLCRule;
import org.apache.hadoop.ozone.om.helpers.OmLifecycleConfiguration;
@@ -104,10 +104,10 @@ public String getPrefix() {
*/
public static final class OzoneLCFilter {
private final String prefix;
- private final Pair<String, String> tag;
+ private final Tag tag;
private final LifecycleAndOperator andOperator;
- public OzoneLCFilter(String prefix, Pair<String, String> tag,
+ public OzoneLCFilter(String prefix, Tag tag,
LifecycleAndOperator andOperator) {
this.prefix = prefix;
this.tag = tag;
@@ -118,7 +118,7 @@ public String getPrefix() {
return prefix;
}
- public Pair<String, String> getTag() {
+ public Tag getTag() {
return tag;
}
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
index dafb7a66989..bfecac4c0fe 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
@@ -29,7 +29,6 @@
import java.util.Objects;
import java.util.function.Consumer;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.FileChecksum;
import org.apache.hadoop.fs.FileEncryptionInfo;
import org.apache.hadoop.hdds.client.ContainerBlockID;
@@ -342,10 +341,9 @@ public List<OmKeyLocationInfo> updateLocationInfoList(
updatedBlockLocations = locationInfoList;
uncommittedBlocks = new ArrayList<>();
} else {
- Pair<List<OmKeyLocationInfo>, List<OmKeyLocationInfo>> verifiedResult =
- verifyAndGetKeyLocations(locationInfoList, keyLocationInfoGroup);
- updatedBlockLocations = verifiedResult.getLeft();
- uncommittedBlocks = verifiedResult.getRight();
+ VerifiedLocations verifiedResult =
verifyAndGetKeyLocations(locationInfoList, keyLocationInfoGroup);
+ updatedBlockLocations = verifiedResult.updated;
+ uncommittedBlocks = verifiedResult.uncommitted;
}
keyLocationInfoGroup.removeBlocks(latestVersion);
@@ -363,12 +361,11 @@ public List<OmKeyLocationInfo> updateLocationInfoList(
*
* @param locationInfoList committed KeyLocationInfos
* @param keyLocationInfoGroup allocated KeyLocationInfoGroup
- * @return Pair of updatedOmKeyLocationInfo and uncommittedOmKeyLocationInfo
+ * @return updatedOmKeyLocationInfo and uncommittedOmKeyLocationInfo
*/
- private Pair<List<OmKeyLocationInfo>, List<OmKeyLocationInfo>>
- verifyAndGetKeyLocations(
- List<OmKeyLocationInfo> locationInfoList,
- OmKeyLocationInfoGroup keyLocationInfoGroup) {
+ private VerifiedLocations verifyAndGetKeyLocations(
+ List<OmKeyLocationInfo> locationInfoList,
+ OmKeyLocationInfoGroup keyLocationInfoGroup) {
// Only check ContainerBlockID here to avoid the mismatch of the pipeline
// field and BcsId in the OmKeyLocationInfo, as the OmKeyInfoCodec ignores
// the pipeline field by default and bcsId would be updated in Ratis mode.
@@ -399,7 +396,7 @@ public List<OmKeyLocationInfo> updateLocationInfoList(
}
List<OmKeyLocationInfo> uncommittedLocationInfos = new ArrayList<>(
allocatedBlockLocations.values());
- return Pair.of(updatedBlockLocations, uncommittedLocationInfos);
+ return new VerifiedLocations(updatedBlockLocations,
uncommittedLocationInfos);
}
/**
@@ -1103,4 +1100,18 @@ public static boolean isKeyEmpty(@Nullable OmKeyInfo
keyInfo) {
}
return !keyInfo.hasBlocks();
}
+
+ /**
+ * The committed (updated) block locations of a key paired with its
allocated-but-uncommitted block locations,
+ * used as the result of verifying the locations sent by a commit request.
+ */
+ private static final class VerifiedLocations {
+ private final List<OmKeyLocationInfo> updated;
+ private final List<OmKeyLocationInfo> uncommitted;
+
+ private VerifiedLocations(List<OmKeyLocationInfo> updated,
List<OmKeyLocationInfo> uncommitted) {
+ this.updated = updated;
+ this.uncommitted = uncommitted;
+ }
+ }
}
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCFilter.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCFilter.java
index 387c4b24df1..b06ffd67a96 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCFilter.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLCFilter.java
@@ -25,7 +25,6 @@
import jakarta.annotation.Nullable;
import java.util.Collections;
import net.jcip.annotations.Immutable;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleFilter;
@@ -114,9 +113,9 @@ public String getPrefix() {
}
@Nullable
- public Pair<String, String> getTag() {
+ public Tag getTag() {
if (hasTag()) {
- return Pair.of(tagKey, tagValue);
+ return new Tag(tagKey, tagValue);
}
return null;
}
@@ -232,4 +231,25 @@ public OmLCFilter build() {
return new OmLCFilter(this);
}
}
+
+ /**
+ * A tag key paired with its tag value, used as the tag condition of a
lifecycle rule filter.
+ */
+ public static final class Tag {
+ private final String key;
+ private final String value;
+
+ public Tag(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
}
diff --git
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/RepeatedOmKeyInfo.java
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/RepeatedOmKeyInfo.java
index e8fa2f8f613..3658603aa98 100644
---
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/RepeatedOmKeyInfo.java
+++
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/RepeatedOmKeyInfo.java
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.hadoop.hdds.utils.db.Codec;
import org.apache.hadoop.hdds.utils.db.CopyObject;
import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
@@ -111,10 +110,9 @@ public List<OmKeyInfo> getOmKeyInfoList() {
}
/**
- * Returns a pair of long values representing the unreplicated size and
- * replicated size of all the keys in the list.
+ * Returns the unreplicated size and replicated size of all the keys in the
list.
*/
- public ImmutablePair<Long, Long> getTotalSize() {
+ public TotalSize getTotalSize() {
long replicatedSize = 0;
long unreplicatedSize = 0;
@@ -124,7 +122,7 @@ public ImmutablePair<Long, Long> getTotalSize() {
}
unreplicatedSize += omKeyInfo.getDataSize();
}
- return new ImmutablePair<>(unreplicatedSize, replicatedSize);
+ return new TotalSize(unreplicatedSize, replicatedSize);
}
// HDDS-7041. Return a new ArrayList to avoid ConcurrentModifyException
@@ -210,4 +208,26 @@ public RepeatedOmKeyInfo build() {
public RepeatedOmKeyInfo copyObject() {
return new RepeatedOmKeyInfo(new ArrayList<>(omKeyInfoList), bucketId);
}
+
+ /**
+ * The unreplicated size of all the keys paired with their replicated size,
+ * used to account for the space held by keys pending deletion.
+ */
+ public static final class TotalSize {
+ private final long unreplicatedSize;
+ private final long replicatedSize;
+
+ public TotalSize(long unreplicatedSize, long replicatedSize) {
+ this.unreplicatedSize = unreplicatedSize;
+ this.replicatedSize = replicatedSize;
+ }
+
+ public long getUnreplicatedSize() {
+ return unreplicatedSize;
+ }
+
+ public long getReplicatedSize() {
+ return replicatedSize;
+ }
+ }
}
diff --git
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/OMLCUtils.java
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/OMLCUtils.java
index 2fa3ce32216..c487f1a0304 100644
---
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/OMLCUtils.java
+++
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/OMLCUtils.java
@@ -27,8 +27,8 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.OmLCFilter.Tag;
import org.junit.jupiter.api.function.Executable;
/**
@@ -107,7 +107,7 @@ public static OmLCRule.Builder getOmLCRuleBuilder(String
id, String prefix, bool
return rBuilder;
}
- public static OmLCFilter.Builder getOmLCFilterBuilder(String filterPrefix,
Pair<String, String> filterTag,
+ public static OmLCFilter.Builder getOmLCFilterBuilder(String filterPrefix,
Tag filterTag,
OmLifecycleRuleAndOperator
andOperator) {
OmLCFilter.Builder lcfBuilder = new OmLCFilter.Builder()
.setPrefix(filterPrefix)
diff --git
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCFilter.java
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCFilter.java
index 75f693d8461..34054874901 100644
---
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCFilter.java
+++
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCFilter.java
@@ -31,9 +31,9 @@
import java.util.Collections;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.OmLCFilter.Tag;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleFilter;
import org.junit.jupiter.api.Test;
@@ -59,7 +59,7 @@ public void testValidFilter() throws OMException {
OmLCFilter lcFilter1 = getOmLCFilterBuilder("prefix", null, null).build();
assertDoesNotThrow(() -> lcFilter1.valid(BucketLayout.DEFAULT));
- OmLCFilter lcFilter2 = getOmLCFilterBuilder(null, Pair.of("key", "value"),
null).build();
+ OmLCFilter lcFilter2 = getOmLCFilterBuilder(null, new Tag("key", "value"),
null).build();
assertDoesNotThrow(() -> lcFilter2.valid(BucketLayout.DEFAULT));
OmLCFilter lcFilter3 = getOmLCFilterBuilder(null, null,
VALID_OM_LC_AND_OPERATOR).build();
@@ -74,11 +74,11 @@ public void testValidFilter() throws OMException {
@Test
public void testInValidFilter() {
- OmLCFilter.Builder lcFilter1 = getOmLCFilterBuilder("prefix",
Pair.of("key", "value"), VALID_OM_LC_AND_OPERATOR);
+ OmLCFilter.Builder lcFilter1 = getOmLCFilterBuilder("prefix", new
Tag("key", "value"), VALID_OM_LC_AND_OPERATOR);
assertOMException(() -> lcFilter1.build().valid(BucketLayout.DEFAULT),
INVALID_REQUEST,
"Only one of 'Prefix', 'Tag', or 'AndOperator' should be specified");
- OmLCFilter.Builder lcFilter2 = getOmLCFilterBuilder("prefix",
Pair.of("key", "value"), null);
+ OmLCFilter.Builder lcFilter2 = getOmLCFilterBuilder("prefix", new
Tag("key", "value"), null);
assertOMException(() -> lcFilter2.build().valid(BucketLayout.DEFAULT),
INVALID_REQUEST,
"Only one of 'Prefix', 'Tag', or 'AndOperator' should be specified");
@@ -86,7 +86,7 @@ public void testInValidFilter() {
assertOMException(() -> lcFilter3.build().valid(BucketLayout.DEFAULT),
INVALID_REQUEST,
"Only one of 'Prefix', 'Tag', or 'AndOperator' should be specified");
- OmLCFilter.Builder lcFilter4 = getOmLCFilterBuilder(null, Pair.of("key",
"value"), VALID_OM_LC_AND_OPERATOR);
+ OmLCFilter.Builder lcFilter4 = getOmLCFilterBuilder(null, new Tag("key",
"value"), VALID_OM_LC_AND_OPERATOR);
assertOMException(() -> lcFilter4.build().valid(BucketLayout.DEFAULT),
INVALID_REQUEST,
"Only one of 'Prefix', 'Tag', or 'AndOperator' should be specified");
@@ -107,13 +107,13 @@ public void testFilterValidation() {
// 3. Tag key too long
String longKey = RandomStringUtils.randomAlphanumeric(129);
- OmLCFilter.Builder longKeyFilter = getOmLCFilterBuilder(null,
Pair.of(longKey, "value"), null);
+ OmLCFilter.Builder longKeyFilter = getOmLCFilterBuilder(null, new
Tag(longKey, "value"), null);
assertOMException(() -> longKeyFilter.build().valid(BucketLayout.DEFAULT),
INVALID_REQUEST,
"A Tag's Key must be a length between 1 and 128");
// 4. Tag value too long
String longValue = RandomStringUtils.randomAlphanumeric(257);
- OmLCFilter.Builder longValueFilter = getOmLCFilterBuilder(null,
Pair.of("key", longValue), null);
+ OmLCFilter.Builder longValueFilter = getOmLCFilterBuilder(null, new
Tag("key", longValue), null);
assertOMException(() ->
longValueFilter.build().valid(BucketLayout.DEFAULT), INVALID_REQUEST,
"A Tag's Value must be a length between 0 and 256");
}
@@ -129,7 +129,7 @@ public void testProtobufConversion() throws OMException {
assertNull(filterFromProto1.getAndOperator());
// Only tag
- OmLCFilter filter2 = getOmLCFilterBuilder(null, Pair.of("key", "value"),
null).build();
+ OmLCFilter filter2 = getOmLCFilterBuilder(null, new Tag("key", "value"),
null).build();
LifecycleFilter proto2 = filter2.getProtobuf();
OmLCFilter filterFromProto2 = OmLCFilter.getFromProtobuf(proto2,
BucketLayout.DEFAULT);
assertNull(filterFromProto2.getPrefix());
diff --git
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCRule.java
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCRule.java
index 8b39e6b7aac..bef6cae4d82 100644
---
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCRule.java
+++
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLCRule.java
@@ -35,9 +35,9 @@
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.OmLCFilter.Tag;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleRule;
import org.junit.jupiter.api.Test;
@@ -183,7 +183,7 @@ public void testRuleWithAndOperatorFilter() throws
OMException {
@Test
public void testRuleWithTagFilter() throws OMException {
long currentTime = System.currentTimeMillis();
- OmLCFilter filter = getOmLCFilterBuilder(null, Pair.of("app", "hadoop"),
null).build();
+ OmLCFilter filter = getOmLCFilterBuilder(null, new Tag("app", "hadoop"),
null).build();
OmLCRule.Builder builder = new OmLCRule.Builder()
.setId("tag-filter-rule")
@@ -256,7 +256,7 @@ public void testTagValidation() throws OMException {
// Case 1: Tag key too long
String longKey =
RandomStringUtils.randomAlphanumeric(OmLifecycleUtils.MAX_TAG_KEY_LENGTH + 1);
- OmLCFilter filterKeyTooLong = getOmLCFilterBuilder(null, Pair.of(longKey,
"value"), null).build();
+ OmLCFilter filterKeyTooLong = getOmLCFilterBuilder(null, new Tag(longKey,
"value"), null).build();
OmLCRule.Builder r1 = new OmLCRule.Builder()
.setId("long-tag-key")
.setEnabled(true)
@@ -267,7 +267,7 @@ public void testTagValidation() throws OMException {
// Case 2: Tag value too long
String longValue =
RandomStringUtils.randomAlphanumeric(OmLifecycleUtils.MAX_TAG_VALUE_LENGTH + 1);
- OmLCFilter filterValueTooLong = getOmLCFilterBuilder(null, Pair.of("key",
longValue), null).build();
+ OmLCFilter filterValueTooLong = getOmLCFilterBuilder(null, new Tag("key",
longValue), null).build();
OmLCRule.Builder r2 = new OmLCRule.Builder()
.setId("long-tag-value")
.setEnabled(true)
diff --git
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLifeCycleConfiguration.java
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLifeCycleConfiguration.java
index b3e5fe551c0..4a04c9d2ca4 100644
---
a/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLifeCycleConfiguration.java
+++
b/hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmLifeCycleConfiguration.java
@@ -35,8 +35,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.ozone.om.exceptions.OMException;
+import org.apache.hadoop.ozone.om.helpers.OmLCFilter.Tag;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.LifecycleConfiguration;
import org.junit.jupiter.api.Test;
@@ -157,7 +157,7 @@ public void testComplexLifecycleConfiguration() throws
OMException {
rules.add(new OmLCRule.Builder()
.setId("rule2")
.setEnabled(true)
- .setFilter(getOmLCFilterBuilder(null, Pair.of("temporary", "true"),
null).build())
+ .setFilter(getOmLCFilterBuilder(null, new Tag("temporary", "true"),
null).build())
.setAction(new OmLCExpiration.Builder()
.setDate(getFutureDateString(100))
.build())
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/QuotaRepairTask.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/QuotaRepairTask.java
index 10c9a4ca864..a0fbf33b189 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/QuotaRepairTask.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/QuotaRepairTask.java
@@ -567,7 +567,7 @@ private static void countDeletedKey(
if (usage == null) {
return;
}
- usage.incrSpace(val.getTotalSize().getRight());
+ usage.incrSpace(val.getTotalSize().getReplicatedSize());
usage.incrNamespace(val.getOmKeyInfoList().size());
}
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ReconGlobalMetricsService.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ReconGlobalMetricsService.java
index c1f32b13cd6..2a8261302b3 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ReconGlobalMetricsService.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ReconGlobalMetricsService.java
@@ -238,7 +238,7 @@ public List<BucketPendingDeletion>
getBucketPendingDeletion(int limit) throws IO
continue;
}
getOrCreateBucketEntry(buckets,
repeatedOmKeyInfo.getOmKeyInfoList().get(0)).addKeys(
- repeatedOmKeyInfo.getOmKeyInfoList().size(),
repeatedOmKeyInfo.getTotalSize().getRight());
+ repeatedOmKeyInfo.getOmKeyInfoList().size(),
repeatedOmKeyInfo.getTotalSize().getReplicatedSize());
}
}
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/DeletedKeysInsightHandler.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/DeletedKeysInsightHandler.java
index 825eca8c19d..1766b634f4e 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/DeletedKeysInsightHandler.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/DeletedKeysInsightHandler.java
@@ -19,12 +19,12 @@
import java.io.IOException;
import java.util.Map;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
import org.apache.hadoop.hdds.utils.db.Table;
import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo.TotalSize;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,11 +53,11 @@ public void handlePutEvent(OMDBUpdateEvent<String, Object>
event,
(RepeatedOmKeyInfo) event.getValue();
objectCountMap.computeIfPresent(getTableCountKeyFromTable(tableName),
(k, count) -> count + repeatedOmKeyInfo.getOmKeyInfoList().size());
- Pair<Long, Long> result = repeatedOmKeyInfo.getTotalSize();
+ TotalSize result = repeatedOmKeyInfo.getTotalSize();
unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
- (k, size) -> size + result.getLeft());
+ (k, size) -> size + result.getUnreplicatedSize());
replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
- (k, size) -> size + result.getRight());
+ (k, size) -> size + result.getReplicatedSize());
} else {
LOG.warn("Put event does not have the Key Info for {}.",
event.getKey());
@@ -81,11 +81,11 @@ public void handleDeleteEvent(OMDBUpdateEvent<String,
Object> event,
(RepeatedOmKeyInfo) event.getValue();
objectCountMap.computeIfPresent(getTableCountKeyFromTable(tableName),
(k, count) ->
count > 0 ? count - repeatedOmKeyInfo.getOmKeyInfoList().size() :
0L);
- Pair<Long, Long> result = repeatedOmKeyInfo.getTotalSize();
+ TotalSize result = repeatedOmKeyInfo.getTotalSize();
unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
- (k, size) -> size > result.getLeft() ? size - result.getLeft() : 0L);
+ (k, size) -> size > result.getUnreplicatedSize() ? size -
result.getUnreplicatedSize() : 0L);
replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
- (k, size) -> size > result.getRight() ? size - result.getRight() :
+ (k, size) -> size > result.getReplicatedSize() ? size -
result.getReplicatedSize() :
0L);
} else {
LOG.warn("Delete event does not have the Key Info for {}.",
@@ -125,9 +125,9 @@ public Triple<Long, Long, Long> getTableSizeAndCount(String
tableName,
Table.KeyValue<String, RepeatedOmKeyInfo> kv = iterator.next();
if (kv != null && kv.getValue() != null) {
RepeatedOmKeyInfo repeatedOmKeyInfo = kv.getValue();
- Pair<Long, Long> result = repeatedOmKeyInfo.getTotalSize();
- unReplicatedSize += result.getLeft();
- replicatedSize += result.getRight();
+ TotalSize result = repeatedOmKeyInfo.getTotalSize();
+ unReplicatedSize += result.getUnreplicatedSize();
+ replicatedSize += result.getReplicatedSize();
count += repeatedOmKeyInfo.getOmKeyInfoList().size();
}
}
diff --git
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java
index ed9d8c9665e..dfe08dcc618 100644
---
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java
+++
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java
@@ -52,7 +52,6 @@
import java.util.Collections;
import java.util.List;
import java.util.UUID;
-import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.client.StandaloneReplicationConfig;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
@@ -71,6 +70,7 @@
import org.apache.hadoop.ozone.om.helpers.OmMultipartPartKey;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo.TotalSize;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyInfo;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo;
import org.apache.hadoop.ozone.recon.ReconTestInjector;
@@ -387,7 +387,7 @@ public void testReprocessForCount() throws Exception {
RepeatedOmKeyInfo deletedKeyInfo = mock(RepeatedOmKeyInfo.class);
// Use different unreplicated and replicated sizes to verify that
// reprocessing assigns each value to the correct size metric.
- when(deletedKeyInfo.getTotalSize()).thenReturn(ImmutablePair.of(100L,
300L));
+ when(deletedKeyInfo.getTotalSize()).thenReturn(new TotalSize(100L, 300L));
when(deletedKeyInfo.getOmKeyInfoList()).thenReturn(Arrays.asList(mock(OmKeyInfo.class)));
Table.KeyValue deletedKv = mock(Table.KeyValue.class);
@@ -412,7 +412,7 @@ public void testReprocessForCount() throws Exception {
if (tableName.equals(DELETED_TABLE)) {
RepeatedOmKeyInfo keyInfo = mock(RepeatedOmKeyInfo.class);
- when(keyInfo.getTotalSize()).thenReturn(ImmutablePair.of(100L, 100L));
+ when(keyInfo.getTotalSize()).thenReturn(new TotalSize(100L, 100L));
when(keyInfo.getOmKeyInfoList()).thenReturn(
Arrays.asList(mock(OmKeyInfo.class)));
when(mockKeyValue.getValue()).thenReturn(keyInfo);
@@ -659,8 +659,7 @@ public void testProcessForOpenKeyTableAndOpenFileTable() {
@Test
public void testProcessForDeletedTable() {
// Prepare mock data size
- ImmutablePair<Long, Long> sizeToBeReturned =
- new ImmutablePair<>(1000L, 3000L);
+ TotalSize sizeToBeReturned = new TotalSize(1000L, 3000L);
ArrayList<OmKeyInfo> omKeyInfoList = new ArrayList<>();
// Add 5 OmKeyInfo objects to the list
for (long i = 0; i < 5; i++) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]