devmadhuu commented on code in PR #10177:
URL: https://github.com/apache/ozone/pull/10177#discussion_r3208265982


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/StorageDistributionEndpoint.java:
##########
@@ -215,10 +224,22 @@ public Response downloadDataNodeStorageDistribution() {
             v -> v.getReport() != null ? v.getReport().getCommitted() : -1,
             v -> v.getReport() != null ? v.getReport().getReserved() : -1,
             v -> v.getReport() != null ? v.getReport().getMinimumFreeSpace() : 
-1,
-            v -> v.getReport() != null ? v.getMetric().getPendingBlockSize() : 
-1
+            v -> v.getMetric() != null ? v.getMetric().getPendingBlockSize() : 
-1
         );
 
-    return 
ReconUtils.downloadCsv("datanode_storage_and_pending_deletion_stats.csv", 
headers, data, columns);
+    String timestamp = LocalDateTime.now().format(TIMESTAMP_FORMATTER);
+    // Retrieve clusterId from ReconContext
+    String clusterID = "UnknownCluster";

Review Comment:
   use same variable name as `clusterId` as defined in `reconContext`.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/StorageDistributionEndpoint.java:
##########
@@ -215,10 +224,22 @@ public Response downloadDataNodeStorageDistribution() {
             v -> v.getReport() != null ? v.getReport().getCommitted() : -1,
             v -> v.getReport() != null ? v.getReport().getReserved() : -1,
             v -> v.getReport() != null ? v.getReport().getMinimumFreeSpace() : 
-1,
-            v -> v.getReport() != null ? v.getMetric().getPendingBlockSize() : 
-1
+            v -> v.getMetric() != null ? v.getMetric().getPendingBlockSize() : 
-1
         );
 
-    return 
ReconUtils.downloadCsv("datanode_storage_and_pending_deletion_stats.csv", 
headers, data, columns);
+    String timestamp = LocalDateTime.now().format(TIMESTAMP_FORMATTER);
+    // Retrieve clusterId from ReconContext
+    String clusterID = "UnknownCluster";
+    try {

Review Comment:
   No need of try-catch block here, code will never throw any exception.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/StorageDistributionEndpoint.java:
##########
@@ -215,10 +224,22 @@ public Response downloadDataNodeStorageDistribution() {
             v -> v.getReport() != null ? v.getReport().getCommitted() : -1,
             v -> v.getReport() != null ? v.getReport().getReserved() : -1,
             v -> v.getReport() != null ? v.getReport().getMinimumFreeSpace() : 
-1,
-            v -> v.getReport() != null ? v.getMetric().getPendingBlockSize() : 
-1
+            v -> v.getMetric() != null ? v.getMetric().getPendingBlockSize() : 
-1
         );
 
-    return 
ReconUtils.downloadCsv("datanode_storage_and_pending_deletion_stats.csv", 
headers, data, columns);
+    String timestamp = LocalDateTime.now().format(TIMESTAMP_FORMATTER);

Review Comment:
   So the timestamp in the filename is taken from the  server timezone , in 
production systems, this could be UTC , but user downloading it could be in his 
local timezone ? The `yyyyMMdd_HHmm` format gives no timezone indication. Using 
`LocalDateTime.now(ZoneOffset.UTC) `and documenting it as UTC (or appending Z 
to the format) would remove ambiguity.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/StorageDistributionEndpoint.java:
##########


Review Comment:
   Update this javadoc.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/StorageDistributionEndpoint.java:
##########
@@ -215,10 +224,22 @@ public Response downloadDataNodeStorageDistribution() {
             v -> v.getReport() != null ? v.getReport().getCommitted() : -1,
             v -> v.getReport() != null ? v.getReport().getReserved() : -1,
             v -> v.getReport() != null ? v.getReport().getMinimumFreeSpace() : 
-1,
-            v -> v.getReport() != null ? v.getMetric().getPendingBlockSize() : 
-1
+            v -> v.getMetric() != null ? v.getMetric().getPendingBlockSize() : 
-1
         );
 
-    return 
ReconUtils.downloadCsv("datanode_storage_and_pending_deletion_stats.csv", 
headers, data, columns);
+    String timestamp = LocalDateTime.now().format(TIMESTAMP_FORMATTER);
+    // Retrieve clusterId from ReconContext
+    String clusterID = "UnknownCluster";
+    try {
+      if (reconContext != null && 
StringUtils.isNotBlank(reconContext.getClusterId())) {

Review Comment:
   2 things:
   1. reconContext can never be null.
   2. Even if it could be null, then no need to check it explicitly because 
`StringUtils.isNotBlank` do null check internally anyways.



-- 
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]

Reply via email to