sreejasahithi commented on code in PR #9969:
URL: https://github.com/apache/ozone/pull/9969#discussion_r2979573442


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -685,9 +688,40 @@ public DiskBalancerInfo getDiskBalancerInfo() {
       bytesToMove = calculateBytesToMove(volumeUsages);
     }
 
-    return new DiskBalancerInfo(operationalState, threshold, bandwidthInMB,
+    DiskBalancerInfo info = new DiskBalancerInfo(operationalState, threshold, 
bandwidthInMB,
         parallelThread, stopAfterDiskEven, version, metrics.getSuccessCount(),
         metrics.getFailureCount(), bytesToMove, metrics.getSuccessBytes(), 
volumeDataDensity);
+    info.setIdealUsage(getIdealUsage(volumeUsages));
+    info.setVolumeInfo(buildVolumeReportProto(volumeUsages));
+    return info;
+  }
+
+  /**
+   * Build a list of VolumeInfoProto from a list of VolumeFixedUsage.
+   * VolumeInfoProto consists of information like StorageID,
+   * volume utilization and committed bytes to the client.

Review Comment:
   Javadoc refers to the wrong type, the type used is VolumeReportProto



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DiskBalancerReportSubcommand.java:
##########
@@ -121,20 +164,36 @@ protected String getActionName() {
 
   /**
    * Create a JSON result map for a report.
-   * 
+   *
    * @param report the DiskBalancer report proto
    * @return JSON result map
    */
-  private Map<String, Object> createReportResult(
-      HddsProtos.DatanodeDiskBalancerInfoProto report) {
+  private Map<String, Object> toJson(DatanodeDiskBalancerInfoProto report) {
     Map<String, Object> result = new LinkedHashMap<>();
-    // Format datanode string with hostname and IP address
-    String formattedDatanode = DiskBalancerSubCommandUtil.getDatanodeHostAndIp(
-        report.getNode());
-    result.put("datanode", formattedDatanode);
+    result.put("datanode", 
DiskBalancerSubCommandUtil.getDatanodeHostAndIp(report.getNode()));
     result.put("action", "report");
     result.put("status", "success");
     result.put("volumeDensity", report.getCurrentVolumeDensitySum());
+
+    if (report.hasIdealUsage()) {
+      result.put("idealUsage", report.getIdealUsage());
+    }
+
+    if (report.getVolumeInfoCount() > 0) {

Review Comment:
   Text output includes threshold and the computed range, but JSON only adds 
idealUsage (and per-volume rows).



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -685,9 +688,40 @@ public DiskBalancerInfo getDiskBalancerInfo() {
       bytesToMove = calculateBytesToMove(volumeUsages);
     }
 
-    return new DiskBalancerInfo(operationalState, threshold, bandwidthInMB,
+    DiskBalancerInfo info = new DiskBalancerInfo(operationalState, threshold, 
bandwidthInMB,
         parallelThread, stopAfterDiskEven, version, metrics.getSuccessCount(),
         metrics.getFailureCount(), bytesToMove, metrics.getSuccessBytes(), 
volumeDataDensity);
+    info.setIdealUsage(getIdealUsage(volumeUsages));
+    info.setVolumeInfo(buildVolumeReportProto(volumeUsages));
+    return info;
+  }
+
+  /**
+   * Build a list of VolumeInfoProto from a list of VolumeFixedUsage.
+   * VolumeInfoProto consists of information like StorageID,
+   * volume utilization and committed bytes to the client.
+   *
+   * @param volumeSet snapshot of VolumeFixedUsage which contains the usage 
information of each volume
+   * @return a list of VolumeReportProto which will be sent to clients for 
reporting volume status
+   * @throws IllegalArgumentException if volumeSet is null or empty
+   */
+  public static List<VolumeReportProto> 
buildVolumeReportProto(List<VolumeFixedUsage> volumeSet) {
+    if (volumeSet == null || volumeSet.isEmpty()) {
+      return Collections.emptyList();
+    }
+

Review Comment:
   This method does not throw any exception , please correct the javadoc



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