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 8431e6133d6 HDDS-16357. Recon fileCount API does not normalize the
fileSize query parameter (#11174)
8431e6133d6 is described below
commit 8431e6133d6e964a8c37c1ae889f81c604ae9078
Author: Henry Chen <[email protected]>
AuthorDate: Thu Sep 24 20:20:28 2026 +0800
HDDS-16357. Recon fileCount API does not normalize the fileSize query
parameter (#11174)
---
.../apache/hadoop/ozone/recon/api/UtilizationEndpoint.java | 7 ++++---
.../org/apache/hadoop/ozone/recon/api/TestEndpoints.java | 12 +++++++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java
index 5800f003205..b87d88cb255 100644
---
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java
+++
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/UtilizationEndpoint.java
@@ -89,14 +89,15 @@ public Response getFileCounts(
Table<FileSizeCountKey, Long> fileCountTable =
reconFileMetadataManager.getFileCountTable();
if (volume != null && bucket != null && fileSize > 0) {
- // Query for specific volume, bucket, and file size
- FileSizeCountKey key = new FileSizeCountKey(volume, bucket, fileSize);
+ // Counts are stored per file size bin, so map the requested size to
its bin upper bound.
+ long fileSizeUpperBound = ReconUtils.getFileSizeUpperBound(fileSize);
+ FileSizeCountKey key = new FileSizeCountKey(volume, bucket,
fileSizeUpperBound);
Long count = fileCountTable.get(key);
if (count != null && count > 0) {
FileCountBySize record = new FileCountBySize();
record.setVolume(volume);
record.setBucket(bucket);
- record.setFileSize(fileSize);
+ record.setFileSize(fileSizeUpperBound);
record.setCount(count);
resultSet.add(record);
}
diff --git
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
index f12f20c13f2..380ebff0700 100644
---
a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
+++
b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
@@ -995,7 +995,17 @@ private void verifyFileCountQueries() {
assertTrue(o.getVolume().equals("vol1") && o.getBucket().equals("bucket1")
&&
o.getFileSize() == 131072);
- // Test for non-existent fileSize.
+ // Test for a fileSize that is not a bin boundary. It is mapped to bin
131072.
+ response = utilizationEndpoint.getFileCounts("vol1", "bucket1", 100000);
+ resultSet = (List<FileCountBySize>) response.getEntity();
+ assertEquals(1, resultSet.size());
+ o = resultSet.get(0);
+ assertEquals("vol1", o.getVolume());
+ assertEquals("bucket1", o.getBucket());
+ assertEquals(131072L, o.getFileSize());
+ assertEquals(2L, o.getCount());
+
+ // Test for a fileSize that is mapped to an empty bin.
response = utilizationEndpoint.getFileCounts("vol1", "bucket1", 1310725);
resultSet = (List<FileCountBySize>) response.getEntity();
assertEquals(0, resultSet.size());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]