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 9539b07b3c8 HDDS-16375. Apply fileSize filter independently in Recon
fileCount endpoint (#11203)
9539b07b3c8 is described below
commit 9539b07b3c805f7a534e8e417ec612347ebc538c
Author: Mahesh kumar Gaddam <[email protected]>
AuthorDate: Thu Sep 24 05:04:19 2026 -0500
HDDS-16375. Apply fileSize filter independently in Recon fileCount endpoint
(#11203)
---
.../ozone/recon/api/UtilizationEndpoint.java | 5 +++-
.../hadoop/ozone/recon/api/TestEndpoints.java | 35 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
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 5a19890d3dc..5800f003205 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
@@ -116,7 +116,10 @@ public Response getFileCounts(
if (bucket != null && !bucket.equals(key.getBucket())) {
matches = false;
}
-
+ if (fileSize > 0 && fileSize != key.getFileSizeUpperBound()) {
+ matches = false;
+ }
+
if (matches && count != null && count > 0) {
FileCountBySize record = new FileCountBySize();
record.setVolume(key.getVolume());
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 b7d2f4bf71a..f12f20c13f2 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
@@ -915,6 +915,15 @@ public void testGetFileCounts() throws Exception {
assertEquals(2L, rocksCount3.longValue(), "Expected RocksDB bin 1024 to
have count 2 for vol2/bucket1");
// --- Now test the query endpoints of the utilization service ---
+ verifyFileCountQueries();
+ }
+
+ /**
+ * Verify the filtering behaviour of the fileCount endpoint against the
+ * bins written by {@link #testGetFileCounts()}: vol1/bucket1:1024,
+ * vol1/bucket1:131072 and vol2/bucket1:1024, each with count 2.
+ */
+ private void verifyFileCountQueries() {
Response response = utilizationEndpoint.getFileCounts(null, null, 0);
List<FileCountBySize> resultSet =
(List<FileCountBySize>) response.getEntity();
@@ -952,6 +961,32 @@ public void testGetFileCounts() throws Exception {
resultSet = (List<FileCountBySize>) response.getEntity();
assertEquals(0, resultSet.size());
+ // Test for "fileSize" query param on its own.
+ response = utilizationEndpoint.getFileCounts(null, null, 131072);
+ resultSet = (List<FileCountBySize>) response.getEntity();
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.stream().allMatch(o -> o.getVolume().equals("vol1") &&
+ o.getBucket().equals("bucket1") && o.getFileSize() == 131072L));
+
+ // Test for "volume" + "fileSize" query params, without bucket.
+ response = utilizationEndpoint.getFileCounts("vol1", null, 131072);
+ resultSet = (List<FileCountBySize>) response.getEntity();
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.stream().allMatch(o -> o.getVolume().equals("vol1") &&
+ o.getFileSize() == 131072L));
+
+ // Test for "bucket" + "fileSize" query params, without volume.
+ response = utilizationEndpoint.getFileCounts(null, "bucket1", 1024);
+ resultSet = (List<FileCountBySize>) response.getEntity();
+ assertEquals(2, resultSet.size());
+ assertTrue(resultSet.stream().allMatch(o ->
o.getBucket().equals("bucket1") &&
+ o.getFileSize() == 1024L));
+
+ // Test for a fileSize that is not a bin upper bound, without volume and
bucket.
+ response = utilizationEndpoint.getFileCounts(null, null, 1310725);
+ resultSet = (List<FileCountBySize>) response.getEntity();
+ assertEquals(0, resultSet.size());
+
// Test for "volume" + "bucket" + "fileSize" query params.
response = utilizationEndpoint.getFileCounts("vol1", "bucket1", 131072);
resultSet = (List<FileCountBySize>) response.getEntity();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]