adoroszlai commented on code in PR #5941:
URL: https://github.com/apache/ozone/pull/5941#discussion_r1468486914
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/OMRequestTestUtils.java:
##########
@@ -1623,4 +1625,55 @@ public static OMRequest
createRequestWithS3Credentials(String accessId,
.build();
}
+ /**
+ * Add key entry to PrefixTable.
+ * @throws Exception
+ */
+ public static void addPrefixToTable(String volumeName, String bucketName,
String prefixName, long trxnLogIndex,
+ OMMetadataManager omMetadataManager) throws Exception {
+
+ OmPrefixInfo omPrefixInfo = createOmPrefixInfo(volumeName, bucketName,
+ prefixName, trxnLogIndex);
+
+ addPrefixToTable(false, omPrefixInfo, trxnLogIndex,
+ omMetadataManager);
+ }
+
+ /**
+ * Add key entry to PrefixTable.
+ * @throws Exception
+ */
+ public static void addPrefixToTable(boolean addToCache, OmPrefixInfo
omPrefixInfo, long trxnLogIndex,
+ OMMetadataManager omMetadataManager) throws Exception {
+ String prefixName = omPrefixInfo.getName();
+
+ if (addToCache) {
+ omMetadataManager.getPrefixTable()
+ .addCacheEntry(new CacheKey<>(omPrefixInfo.getName()),
+ new CacheValue<>(Optional.of(omPrefixInfo), trxnLogIndex));
Review Comment:
nit: avoid the deprecated constructor with `Optional`, use the factory
method:
```suggestion
CacheValue.get(trxnLogIndex, omPrefixInfo));
```
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/OMRequestTestUtils.java:
##########
@@ -1623,4 +1625,55 @@ public static OMRequest
createRequestWithS3Credentials(String accessId,
.build();
}
+ /**
+ * Add key entry to PrefixTable.
+ * @throws Exception
+ */
+ public static void addPrefixToTable(String volumeName, String bucketName,
String prefixName, long trxnLogIndex,
+ OMMetadataManager omMetadataManager) throws Exception {
+
+ OmPrefixInfo omPrefixInfo = createOmPrefixInfo(volumeName, bucketName,
+ prefixName, trxnLogIndex);
+
+ addPrefixToTable(false, omPrefixInfo, trxnLogIndex,
+ omMetadataManager);
+ }
+
+ /**
+ * Add key entry to PrefixTable.
+ * @throws Exception
+ */
+ public static void addPrefixToTable(boolean addToCache, OmPrefixInfo
omPrefixInfo, long trxnLogIndex,
+ OMMetadataManager omMetadataManager) throws Exception {
+ String prefixName = omPrefixInfo.getName();
+
+ if (addToCache) {
+ omMetadataManager.getPrefixTable()
+ .addCacheEntry(new CacheKey<>(omPrefixInfo.getName()),
+ new CacheValue<>(Optional.of(omPrefixInfo), trxnLogIndex));
+ }
+ omMetadataManager.getPrefixTable().put(prefixName, omPrefixInfo);
+ }
+
+ /**
+ * Create OmPrefixInfo.
+ */
+ @SuppressWarnings("parameterNumber")
Review Comment:
nit: I guess suppression is unnecessary with only 4 parameters
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/OMRequestTestUtils.java:
##########
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.UUID;
+import com.google.common.base.Optional;
Review Comment:
becomes unused
```suggestion
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]