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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/DataNodeMetricsService.java:
##########
@@ -301,27 +299,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, failedMessage));
+  }
+
+  private static String buildProgressMessage(MetricCollectionStatus status, 
String failedMessage) {
+    switch (status) {
+    case IN_PROGRESS:

Review Comment:
   Nit: I think checkstyle expects `case` to be indented inside instead of the 
same level.



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