ArafatKhan2198 commented on code in PR #4182:
URL: https://github.com/apache/ozone/pull/4182#discussion_r1137229563
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -397,7 +419,81 @@ private List<ContainerBlockMetadata> getBlocks(
return blockIds;
}
- private BucketLayout getBucketLayout() {
- return BucketLayout.DEFAULT;
+ /**
+ * Builds an object path for a file system optimized bucket.
+ *
+ * @param prevKeyPrefix the previous key prefix of the object path
+ * @return the object path for the file system optimized bucket
+ * @throws IOException if an IO error occurs
+ */
+ private String buildObjectPathForFileSystemBucket(String prevKeyPrefix)
+ throws IOException {
+ if (StringUtils.isEmpty(prevKeyPrefix)) {
+ return "";
+ }
+ // Normalize the path to remove duplicate slashes & make it easier to
parse.
+ String normalizedPath = normalizePath(prevKeyPrefix);
+ String[] names = parseRequestPath(normalizedPath);
+
+ if (names.length < 3) {
+ LOG.error("Invalid path: {} path should contain a directory",
+ prevKeyPrefix);
+ return prevKeyPrefix;
+ }
+ // Extract the volume, bucket, and key names from the path.
+ String volumeName = names[0];
+ String bucketName = names[1];
+ String keyName = names[names.length - 1];
+
+ // Get the bucket handler for the given volume and bucket.
+ BucketHandler handler =
+ getBucketHandler(reconNamespaceSummaryManager, omMetadataManager,
+ reconSCM, volumeName, bucketName);
+
+ // Only keyPaths for FSO bucket need to be converted to
+ // their respective objectId's
+ if (handler.getBucketLayout() != BucketLayout.FILE_SYSTEM_OPTIMIZED) {
+ return prevKeyPrefix;
+ }
+
+ // Get the object IDs for the bucket, volume, and parent directory.
+ long bucketId, volumeId, parentId;
+ bucketId = handler.getBucketObjectId(names);
+ volumeId = handler.getVolumeObjectId(names);
+ parentId = handler.getDirObjectId(names, names.length - 1);
+
+ // Build the object path by concatenating the object IDs with the key name.
+ StringBuilder objectPathBuilder = new StringBuilder();
+ objectPathBuilder.append(OM_KEY_PREFIX).append(volumeId)
+ .append(OM_KEY_PREFIX).append(bucketId)
+ .append(OM_KEY_PREFIX).append(parentId)
+ .append(OM_KEY_PREFIX).append(keyName);
+
+ return objectPathBuilder.toString();
}
+
+ /**
+ * Normalizes a key path by adding the OM_KEY_PREFIX at the beginning
+ * and removing duplicate slashes.
+ *
+ * @param path the key path
+ * @return the normalized key path
+ */
+ public static String normalizePath(String path) {
+ return OM_KEY_PREFIX + OmUtils.normalizeKey(path, false);
Review Comment:
The `normalizePath()` method was added to ensure that the user provides the
correct input for fso. However, it's important for users to know what input
they're giving, and randomly changing their input is not a good practice.
Therefore, I have removed the normalizePath() method as it is irrelevant to
what `parseRequestPath()` does.
--
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]