priyeshkaratha commented on code in PR #10426:
URL: https://github.com/apache/ozone/pull/10426#discussion_r3418035358


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/DataNodeMetricsService.java:
##########
@@ -301,27 +302,40 @@ private void resetState() {
     totalNodesFailed = 0;
   }
 
-  public DataNodeMetricsServiceResponse getCollectedMetrics(Integer limit) {
+  /**
+   * Returns either {@link DataNodeMetricsCompleteResponse} when collection is
+   * finished, or {@link DataNodeMetricsProgressResponse} otherwise.
+   */
+  public Object getCollectedMetrics(Integer limit) {
     startTask();
     if (currentStatus == MetricCollectionStatus.FINISHED) {
-      DataNodeMetricsServiceResponse.Builder dnMetricsBuilder = 
DataNodeMetricsServiceResponse.newBuilder();
-      dnMetricsBuilder
-          .setStatus(currentStatus)
-          .setTotalPendingDeletionSize(totalPendingDeletion)
-          .setTotalNodesQueried(totalNodesQueried)
-          .setTotalNodeQueryFailures(totalNodesFailed);
+      List<DatanodePendingDeletionMetrics> list =
+          (limit == null) ? pendingDeletionList :
+              pendingDeletionList.subList(0, Math.min(limit, 
pendingDeletionList.size()));
+      return new DataNodeMetricsCompleteResponse(
+          currentStatus,
+          totalNodesQueried,
+          totalNodesFailed,
+          totalPendingDeletion,
+          list);
+    }
 
-      if (null == limit) {
-        return 
dnMetricsBuilder.setPendingDeletion(pendingDeletionList).build();
-      } else {
-        return dnMetricsBuilder.setPendingDeletion(
-            pendingDeletionList.subList(0, Math.min(limit, 
pendingDeletionList.size())
-        )).build();
-      }
+    return new DataNodeMetricsProgressResponse(
+        currentStatus,
+        buildProgressMessage(currentStatus));
+  }
+
+  private static String buildProgressMessage(MetricCollectionStatus status) {
+    switch (status) {
+    case IN_PROGRESS:
+      return "Metrics collection task is currently running. Please wait for 
task to finish.";
+    case FAILED:

Review Comment:
   @ChenSammi  Currently, the UI only checks whether the operation status is 
FINISHED. If the status is anything other than FINISHED, the UI continues 
polling, which means it will also retry in cases where the operation has FAILED.
   
   At the moment, we are not propagating the exact failure reason back to the 
UI, as supporting that would require additional handling on both the backend 
and UI sides. I can address this enhancement as part of a separate JIRA in next 
phase.



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