diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java index f5ed8ff2055..b4777c7a016 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java @@ -755,15 +755,15 @@ public static String normalizeKey(String keyName, * @param path The path string to be normalized. * @return The normalized path string. */ - public static String normalizePathUptilBucket(String path) { + public static String normalizePathUptoBucket(String path) { if (path == null || path.isEmpty()) { - return "/"; // Handle empty path + return OM_KEY_PREFIX; // Handle empty path } // Remove leading slashes path = path.replaceAll("^/*", ""); - String[] segments = path.split("/", -1); + String[] segments = path.split(OM_KEY_PREFIX, -1); String volumeName = segments[0]; String bucketName = segments.length > 1 ? segments[1] : ""; @@ -771,13 +771,14 @@ public static String normalizePathUptilBucket(String path) { // Combine volume and bucket. StringBuilder normalizedPath = new StringBuilder(volumeName); if (!bucketName.isEmpty()) { - normalizedPath.append("/").append(bucketName); + normalizedPath.append(OM_KEY_PREFIX).append(bucketName); } // Add remaining segments as the key if (segments.length > 2) { - normalizedPath.append("/").append( - String.join("/", Arrays.copyOfRange(segments, 2, segments.length))); + normalizedPath.append(OM_KEY_PREFIX).append( + String.join(OM_KEY_PREFIX, + Arrays.copyOfRange(segments, 2, segments.length))); } return normalizedPath.toString(); diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java index 93c91c8e1d8..4f9e68ddff9 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/EntityHandler.java @@ -312,7 +312,7 @@ public static String[] parseObjectStorePath(String path) { * * This method adjusts the path according to the bucket layout. * For {OBJECT_STORE Layout}, it normalizes the path up to the bucket level - * using OmUtils.normalizePathUptilBucket. For other layouts, it + * using OmUtils.normalizePathUptoBucket. For other layouts, it * normalizes the entire path, including the key, using * OmUtils.normalizeKey, and does not preserve any trailing slashes. * The normalized path will always be prefixed with OM_KEY_PREFIX to ensure it @@ -324,7 +324,7 @@ public static String[] parseObjectStorePath(String path) { */ private static String normalizePath(String path, BucketLayout bucketLayout) { if (bucketLayout == BucketLayout.OBJECT_STORE) { - return OM_KEY_PREFIX + OmUtils.normalizePathUptilBucket(path); + return OM_KEY_PREFIX + OmUtils.normalizePathUptoBucket(path); } return OM_KEY_PREFIX + OmUtils.normalizeKey(path, false); } diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskWithLegacy.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskWithLegacy.java index 57294e7f0a8..4555b976ffe 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskWithLegacy.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTaskWithLegacy.java @@ -160,7 +160,7 @@ private void processWithFileSystemLayout(OmKeyInfo updatedKeyInfo, break; default: - LOG.debug("Skipping DB update event fir Key: {}", action); + LOG.debug("Skipping DB update event for Key: {}", action); } } else { OmDirectoryInfo updatedDirectoryInfo = new OmDirectoryInfo.Builder() diff --git a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestNSSummaryEndpointWithOBSAndLegacy.java b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestNSSummaryEndpointWithOBSAndLegacy.java index f0696127cdc..8d8299aefc1 100644 --- a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestNSSummaryEndpointWithOBSAndLegacy.java +++ b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestNSSummaryEndpointWithOBSAndLegacy.java @@ -878,30 +878,30 @@ public void checkFileSizeDist(String path, int bin0, } @Test - public void testNormalizePathUptilBucket() { + public void testNormalizePathUptoBucket() { // Test null or empty path - assertEquals("/", OmUtils.normalizePathUptilBucket(null)); - assertEquals("/", OmUtils.normalizePathUptilBucket("")); + assertEquals("/", OmUtils.normalizePathUptoBucket(null)); + assertEquals("/", OmUtils.normalizePathUptoBucket("")); // Test path with leading slashes assertEquals("volume1/bucket1/key1/key2", - OmUtils.normalizePathUptilBucket("///volume1/bucket1/key1/key2")); + OmUtils.normalizePathUptoBucket("///volume1/bucket1/key1/key2")); // Test volume and bucket names assertEquals("volume1/bucket1", - OmUtils.normalizePathUptilBucket("volume1/bucket1")); + OmUtils.normalizePathUptoBucket("volume1/bucket1")); // Test with additional segments assertEquals("volume1/bucket1/key1/key2", - OmUtils.normalizePathUptilBucket("volume1/bucket1/key1/key2")); + OmUtils.normalizePathUptoBucket("volume1/bucket1/key1/key2")); // Test path with multiple slashes in key names. assertEquals("volume1/bucket1/key1//key2", - OmUtils.normalizePathUptilBucket("volume1/bucket1/key1//key2")); + OmUtils.normalizePathUptoBucket("volume1/bucket1/key1//key2")); // Test path with volume, bucket, and special characters in keys assertEquals("volume/bucket/key$%#1/./////////key$%#2", - OmUtils.normalizePathUptilBucket("volume/bucket/key$%#1/./////////key$%#2")); + OmUtils.normalizePathUptoBucket("volume/bucket/key$%#1/./////////key$%#2")); }