You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "jianghuazhu (via GitHub)" <gi...@apache.org> on 2023/12/28 16:31:29 UTC

[PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

jianghuazhu opened a new pull request, #5882:
URL: https://github.com/apache/ozone/pull/5882

   ## What changes were proposed in this pull request?
   Now, the SCM web ui does not show how much storage percentage is used by each DataNode node, the purpose of this PR is to make up for it.
   ![image](https://github.com/apache/ozone/assets/6416939/3e07fef5-d8df-4836-9e71-c468443e3d33)
   
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-9988
   
   ## How was this patch tested?
   The SCM web ui can display the storage percentage used by each DataNode node.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457426772


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");

Review Comment:
   Okay, I will update it.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1898279177

   @xBis7  @adoroszlai , do you have any new suggestions for this PR?
   If possible, help merge it into the master branch.
   In addition, I will submit some new features later, which are based on this PR.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457425228


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -141,6 +143,8 @@ public class SCMNodeManager implements NodeManager {
   private final String opeState = "OPSTATE";
   private final String comState = "COMSTATE";
   private final String lastHeartbeat = "LASTHEARTBEAT";
+  private final String usedSpacePercent = "USEDSPACEPERCENT";
+  private final String totalCapacity = "CAPACITY";

Review Comment:
   No, I don't think we need to wait.
   
   (However, I'd like to get HDDS-10157 fixed before merging anything else, since CI is failing in native check.)



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "whbing (via GitHub)" <gi...@apache.org>.
whbing commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1880945023

   How about also display `Capacity` and `ScmUsed` ? 
   similar HDFS UI like this ?
   <img width="604" alt="image" src="https://github.com/apache/ozone/assets/18388154/dadcce78-5e41-4ca7-ba84-58aa2c8d9fce">
   IMO, it's also best to have a sort function
   
   
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1879933981

   Can you help review this pr again, @xBis7 .
   Thanks.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457423253


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -141,6 +143,8 @@ public class SCMNodeManager implements NodeManager {
   private final String opeState = "OPSTATE";
   private final String comState = "COMSTATE";
   private final String lastHeartbeat = "LASTHEARTBEAT";
+  private final String usedSpacePercent = "USEDSPACEPERCENT";
+  private final String totalCapacity = "CAPACITY";

Review Comment:
   @adoroszlai , do we need to wait for HDDS-10152 to be resolved?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1890375114

   @jianghuazhu Sorry for not been clear. With `Total`, I was referring to the total used space. Can you rename that column back to `Capacity`?
   
   Otherwise, changes look good. After that change, I'll open up the PR Ci.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887414354

   As you can see now, the percentages shown in the Recon UI represent node disk usage, not just Ozone usage, which is an extension of Ozone.
   However, I believe that the storage usage shown by the SCM should be the data Used by the real Ozone datanodes, and there is no need to show 'Non Ozone Used' data.
   Therefore, we can use 'SCM Used Space Percent' in the SCM UI to indicate how much Ozone data is managed by the DataNode service. The data shown here should correspond to the storage capacity of the DataNode UI.
   ![image](https://github.com/apache/ozone/assets/6416939/c3519960-357c-4377-bed0-3472e9083093)
   
   @xBis7 , what do you think?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1900484377

   @adoroszlai , I've updated it.
   Can you help review again?
   ci: https://github.com/jianghuazhu/ozone/actions/runs/7583986252
   SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/dd2976d9-355f-4d8b-a93f-d8f519a41cd5)
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1900507185

   @dombizita would you like to take a look, too?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1883400946

   Thanks @xBis7  and @whbing .
   I've updated it.
   ci:
   https://github.com/jianghuazhu/ozone/actions/runs/7462830986
   New SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/dc655d92-d8d7-4c41-88f1-82eebf8decee)
   
   Newly added columns can be sorted.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887100382

   In our test cluster, each node is configured with 12 disks, and each disk stores Ozone data and HDFS data respectively. For example, one of the disk directories:
   `
   /data5:
   `
   `
   131G	./hadoopdata
   `
   `
   167G	./ozonedata
   `
   
   I understand that Non Ozone Used here refers to the storage capacity used by HDFS and the data used by other programs.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1890803454

   Thanks @xBis7 .
   I've updated it.
   Latest SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/c0093d2d-e809-4e9a-bba5-92bbd8c355f3)
   
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1886207637

   Can you help me take a look at this PR again, @xBis7 .
   Thanks.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1882992284

   > IMO, it's also best to have a sort function
   
   There is a sort function. I don't know if it works for every column though. That needs to be checked.
   
   > The DataNode UI already displays the total storage size and used size. Does it still need to be displayed in the SCM UI?
   What do you think, @xBis7 .
   
   It can be useful to have such information in one place, but if it's out of scope then it should be done as part of another jira. Tickets with narrow scope are easier for people to review. 
   
   > How about also display `Capacity` and `ScmUsed` ?
   
   `Capacity` seems related and can be part of this PR but `ScmUsed` doesn't.
   
   As long as the PR changes are within scope, I'm ok with them.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1898297356

   @jianghuazhu Let's wait to see if @adoroszlai has any comments. Otherwise, it can be merged.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457337062


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");

Review Comment:
   I'm not sure `"scmUsed"` and `"nonScmUsed"` are clear enough for users.  Also, the table header already says `"Used Space Percent"`.
   
   How about `"Ozone: ... , other: ..."`?



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1575,67 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used, long remaining) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, remaining, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  private static Stream<Arguments> calculateStoragePercentageScenarios() {
+    return Stream.of(
+        Arguments.of(600, 65, 500, 1, "600.0B", 10.83, 5.83),
+        Arguments.of(10000, 1000, 8800, 12, "117.2KB", 10.0, 2.0),
+        Arguments.of(100000000, 1000, 899999, 12, "1.1GB", 0.0, 99.1),
+        Arguments.of(10000, 1000, 0, 0, "0.0B", 0.0, 0.0),
+        Arguments.of(0, 0, 0, 0, "0.0B", 0.0, 0.0),
+        Arguments.of(1010, 547, 400, 5, "4.9KB", 54.16, 6.24)
+    );
+  }
+
+  @ParameterizedTest
+  @MethodSource("calculateStoragePercentageScenarios")
+  public void testCalculateStoragePercentage(long perCapacity,
+      long used, long remaining, int volumeCount, String totalCapacity,
+          double scmUsedPerc, double nonScmUsedPerc)
+          throws AuthenticationException, IOException {
+    OzoneConfiguration conf = getConf();
+    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
+        MILLISECONDS);
+    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
+      EventQueue eventQueue = (EventQueue) scm.getEventQueue();
+      LayoutVersionManager versionManager =
+          nodeManager.getLayoutVersionManager();
+      LayoutVersionProto layoutInfo = toLayoutVersionProto(
+          versionManager.getMetadataLayoutVersion(),
+          versionManager.getSoftwareLayoutVersion());
+      DatanodeDetails dn = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId = dn.getUuid();
+      List<StorageReportProto> reports = volumeCount > 0 ?
+          generateStorageReportProto(volumeCount, dnId, perCapacity,
+              used, remaining) : null;
+      nodeManager.register(dn, reports != null ?
+          HddsTestUtils.createNodeReport(reports, emptyList()) : null, null);
+      nodeManager.processHeartbeat(dn, layoutInfo);
+      eventQueue.processAll(8000L);
+      NodeStateManager nodeStateManager = nodeManager.getNodeStateManager();
+      List<DatanodeInfo> dataNodeInfoList = nodeStateManager.getAllNodes();
+      DatanodeInfo dni = dataNodeInfoList.get(0);
+      String capacityResult = nodeManager.calculateStorageCapacity(dni);
+      assertEquals(capacityResult, totalCapacity);

Review Comment:
   Please follow `assertEquals(expected, actual)` argument order.



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1575,67 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used, long remaining) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, remaining, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  private static Stream<Arguments> calculateStoragePercentageScenarios() {
+    return Stream.of(
+        Arguments.of(600, 65, 500, 1, "600.0B", 10.83, 5.83),
+        Arguments.of(10000, 1000, 8800, 12, "117.2KB", 10.0, 2.0),
+        Arguments.of(100000000, 1000, 899999, 12, "1.1GB", 0.0, 99.1),
+        Arguments.of(10000, 1000, 0, 0, "0.0B", 0.0, 0.0),
+        Arguments.of(0, 0, 0, 0, "0.0B", 0.0, 0.0),
+        Arguments.of(1010, 547, 400, 5, "4.9KB", 54.16, 6.24)
+    );
+  }
+
+  @ParameterizedTest
+  @MethodSource("calculateStoragePercentageScenarios")
+  public void testCalculateStoragePercentage(long perCapacity,
+      long used, long remaining, int volumeCount, String totalCapacity,
+          double scmUsedPerc, double nonScmUsedPerc)
+          throws AuthenticationException, IOException {
+    OzoneConfiguration conf = getConf();
+    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
+        MILLISECONDS);
+    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
+      EventQueue eventQueue = (EventQueue) scm.getEventQueue();
+      LayoutVersionManager versionManager =
+          nodeManager.getLayoutVersionManager();
+      LayoutVersionProto layoutInfo = toLayoutVersionProto(
+          versionManager.getMetadataLayoutVersion(),
+          versionManager.getSoftwareLayoutVersion());
+      DatanodeDetails dn = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId = dn.getUuid();
+      List<StorageReportProto> reports = volumeCount > 0 ?
+          generateStorageReportProto(volumeCount, dnId, perCapacity,
+              used, remaining) : null;
+      nodeManager.register(dn, reports != null ?
+          HddsTestUtils.createNodeReport(reports, emptyList()) : null, null);
+      nodeManager.processHeartbeat(dn, layoutInfo);
+      eventQueue.processAll(8000L);
+      NodeStateManager nodeStateManager = nodeManager.getNodeStateManager();
+      List<DatanodeInfo> dataNodeInfoList = nodeStateManager.getAllNodes();
+      DatanodeInfo dni = dataNodeInfoList.get(0);

Review Comment:
   If `calculate...` methods are changed as suggested, all we need here is:
   
   ```
         List<StorageReportProto> reports = volumeCount > 0 ?
             generateStorageReportProto(volumeCount, dnId, perCapacity,
                 used, remaining) : null;
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage capacity of the DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public String calculateStorageCapacity(DatanodeInfo dni) {
+    long capacityByte = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      for (StorageReportProto storageReport : storageReports) {
+        capacityByte += storageReport.getCapacity();
+      }
+    }
+
+    double ua = capacityByte;
+    StringBuilder unit = new StringBuilder("B");
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 1, "KB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "MB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "GB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "TB");
+    }
+
+    DecimalFormat decimalFormat = new DecimalFormat("#0.0");
+    decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+    double capacity = Double.valueOf(decimalFormat.format(ua));
+    return capacity + unit.toString();
+  }
+
+  /**
+   * Calculate the storage usage percentage of a DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public double[] calculateStoragePercentage(DatanodeInfo dni) {
+    double[] storagePercentage = new double[2];
+    double usedPercentage = 0;
+    double nonUsedPercentage = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      long capacity = 0;
+      long scmUsed = 0;
+      long remaining = 0;
+      for (StorageReportProto storageReport : storageReports) {
+        capacity += storageReport.getCapacity();
+        scmUsed += storageReport.getScmUsed();
+        remaining += storageReport.getRemaining();
+      }
+      long scmNonUsed = capacity - scmUsed - remaining;
+
+      DecimalFormat decimalFormat = new DecimalFormat("#0.00");
+      decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+
+      double usedPerc = ((double) scmUsed / capacity) * 100;
+      usedPerc = usedPerc > 100.0 ? 100.0 : usedPerc;
+      double nonUsedPerc = ((double) scmNonUsed / capacity) * 100;
+      nonUsedPerc = nonUsedPerc > 100.0 ? 100.0 : nonUsedPerc;
+      usedPercentage = Double.valueOf(decimalFormat.format(usedPerc));
+      nonUsedPercentage = Double.valueOf(decimalFormat.format(nonUsedPerc));

Review Comment:
   Here we format the value, then parse it as double.  The caller then simply concatenates them into the final text being displayed.  I think formatting may be lost this way.
   
   I think `calculateStoragePercentage()` should return the formatted `String` instead.
   
   If there are no reports, return `"N/A"`, since we have no information.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage capacity of the DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public String calculateStorageCapacity(DatanodeInfo dni) {

Review Comment:
   Both new calculate methods can be `static` and take `List<StorageReportProto>` as parameter instead of `DatanodeInfo`.
   
   This allows the test to be much simpler (see other comment on the test for details).



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -141,6 +143,8 @@ public class SCMNodeManager implements NodeManager {
   private final String opeState = "OPSTATE";
   private final String comState = "COMSTATE";
   private final String lastHeartbeat = "LASTHEARTBEAT";
+  private final String usedSpacePercent = "USEDSPACEPERCENT";
+  private final String totalCapacity = "CAPACITY";

Review Comment:
   These should be constants.  (The existing ones, too, but those are being fixed in HDDS-10152.)



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1444434398


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1572,83 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      long free = capacity - used;
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, free, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  @Test

Review Comment:
   Thank you for these suggestions.
   I will update later.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1446074048


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1116,37 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      double usedPec = calculateStoragePercentage(dni);
+      map.put(usedSpacePercent, usedPec + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage usage percentage of a DataNode node.
+   * @param dni DataNode node that needs to be calculated
+   * @return
+   */
+  public double calculateStoragePercentage(DatanodeInfo dni) {
+    double usedPec = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      long capacity = 0;
+      long scmUsed = 0;
+      for (StorageReportProto storageReport : storageReports) {
+        capacity = capacity + storageReport.getCapacity();
+        scmUsed = scmUsed + storageReport.getScmUsed();

Review Comment:
   This can be simplified
   
   ```suggestion
           capacity += storageReport.getCapacity();
           scmUsed += storageReport.getScmUsed();
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1448534677


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,78 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double usedPec = calculateStoragePercentage(dni);
+      map.put(usedSpacePercent, usedPec + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage capacity of the DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public String calculateStorageCapacity(DatanodeInfo dni) {
+    long capacityByte = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      for (StorageReportProto storageReport : storageReports) {
+        capacityByte += storageReport.getCapacity();
+      }
+    }
+
+    double ua = capacityByte;
+    String unit = "B";
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit = "KB";

Review Comment:
   Thanks to @xBis7  for your patient guidance.
   I will update later.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1448515900


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1575,102 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      long free = capacity - used;
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, free, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  private static Stream<Arguments> calculateStoragePercentageScenarios() {
+    return Stream.of(
+        Arguments.of(1000, 600, 10, 60),
+        Arguments.of(1000, 1000, 10, 100),
+        Arguments.of(1000, 1001, 10, 100),
+        Arguments.of(0, 0, 0, 0),
+        Arguments.of(1010, 547, 5, 54.16)
+    );
+  }
+
+  @ParameterizedTest
+  @MethodSource("calculateStoragePercentageScenarios")
+  public void testCalculateStoragePercentage(long capacity,
+      long used, int volumeCount, double targetUsedPerc)
+          throws AuthenticationException, IOException {
+    OzoneConfiguration conf = getConf();
+    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
+        MILLISECONDS);
+    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
+      EventQueue eventQueue = (EventQueue) scm.getEventQueue();
+      LayoutVersionManager versionManager =
+          nodeManager.getLayoutVersionManager();
+      LayoutVersionProto layoutInfo = toLayoutVersionProto(
+          versionManager.getMetadataLayoutVersion(),
+          versionManager.getSoftwareLayoutVersion());
+      DatanodeDetails dn = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId = dn.getUuid();
+      List<StorageReportProto> reports = volumeCount > 0 ?
+          generateStorageReportProto(volumeCount, dnId, capacity, used) : null;
+      nodeManager.register(dn, reports != null ?
+          HddsTestUtils.createNodeReport(reports, emptyList()) : null, null);
+      nodeManager.processHeartbeat(dn, layoutInfo);
+      eventQueue.processAll(8000L);
+      NodeStateManager nodeStateManager = nodeManager.getNodeStateManager();
+      List<DatanodeInfo> dataNodeInfoList = nodeStateManager.getAllNodes();
+      double usedPerc = nodeManager.calculateStoragePercentage(
+          dataNodeInfoList.get(0));
+      assertEquals(usedPerc, targetUsedPerc);
+    }
+  }
+
+  private static Stream<Arguments> calculateStorageCapacityScenarios() {
+    return Stream.of(
+        Arguments.of(600, 6, 1, "600.0B"),
+        Arguments.of(10000, 1000, 12, "117.2KB"),
+        Arguments.of(100000000, 1000, 12, "1.1GB"),
+        Arguments.of(10000, 1000, 0, "0.0B")
+    );
+  }
+
+  @ParameterizedTest
+  @MethodSource("calculateStorageCapacityScenarios")
+  public void testcalculateStorageCapacity(long capacity,
+      long used, int volumeCount, String totalCapacity)
+          throws AuthenticationException, IOException {
+    OzoneConfiguration conf = getConf();
+    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
+        MILLISECONDS);
+    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
+      EventQueue eventQueue = (EventQueue) scm.getEventQueue();
+      LayoutVersionManager versionManager =
+          nodeManager.getLayoutVersionManager();
+      LayoutVersionProto layoutInfo = toLayoutVersionProto(
+          versionManager.getMetadataLayoutVersion(),
+          versionManager.getSoftwareLayoutVersion());
+      DatanodeDetails dn = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId = dn.getUuid();
+      List<StorageReportProto> reports = volumeCount > 0 ?
+          generateStorageReportProto(volumeCount, dnId, capacity, used) : null;
+      nodeManager.register(dn, reports != null ?
+          HddsTestUtils.createNodeReport(reports, emptyList()) : null, null);
+      nodeManager.processHeartbeat(dn, layoutInfo);
+      eventQueue.processAll(8000L);
+      NodeStateManager nodeStateManager = nodeManager.getNodeStateManager();
+      List<DatanodeInfo> dataNodeInfoList = nodeStateManager.getAllNodes();

Review Comment:
   It looks like, from 
   ```
   EventQueue eventQueue = (EventQueue) scm.getEventQueue();
   ...
   ...
   List<DatanodeInfo> dataNodeInfoList = nodeStateManager.getAllNodes();
   ```
   up to this line, the setup is exactly the same for both methods.
   
   You can move this code to a method that returns the `datanodeInfoList` and reuse the method.
   
   Another approach would be to combine both tests in one.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,78 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double usedPec = calculateStoragePercentage(dni);
+      map.put(usedSpacePercent, usedPec + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage capacity of the DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public String calculateStorageCapacity(DatanodeInfo dni) {
+    long capacityByte = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      for (StorageReportProto storageReport : storageReports) {
+        capacityByte += storageReport.getCapacity();
+      }
+    }
+
+    double ua = capacityByte;
+    String unit = "B";
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit = "KB";

Review Comment:
   Strings in java, are immutable. That means that when you create a String variable, a new object is created and then the variable references that object. Every time you assign a new value to the String variable, a new object gets created and the variable's reference gets updated. The old object is left around until it gets picked up by the garbage collector.
   
   IMO, in this case it's better to do this kind of string manipulation, using a `StringBuilder`.
   
   Check these
   
   https://www.digitalocean.com/community/tutorials/string-vs-stringbuffer-vs-stringbuilder
   
   https://www.baeldung.com/java-string-performance



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1889086590

   I have an idea.
   In the SCM UI, the storage usage percentages of Ozone Used and Non Ozone Used are displayed respectively.
   New SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/ed0aec0e-5f87-4a1b-a645-1d831a73a4bd)
   
   Here’s an explanation of some key data:
   scmUsed:
   This refers to Ozone Used. Calculation formula = scmUsed / capacity, and the result value retains 2 decimal places.
   nonScmUsed:
   This refers to Non Ozone Used.
   Calculation method:
   `
   1.scmNonUsed = capacity - scmUsed - remaining
   `
   `
   2.nonScmUsed= scmNonUsed / capacity
   `
   In Recon UI, the method of calculating Non Ozone Used is the same as the method of calculating nonScmUsed.
   @xBis7  @adoroszlai , do you have any suggestions?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1886992660

   I found some problems.
   Recon UI:
   ![image](https://github.com/apache/ozone/assets/6416939/65fb1ecc-7229-40bc-a39e-762059b2130b)
   
   Here's an explanation of some important data:
   Ozone Used: 1.7TB
   Non Ozone Used: 1.6TB
   Remaining: 127.6 TB
   As can be seen here, the total storage capacity size is 130.9TB.
   
   In Recon UI, the calculation formula of percentage is used for storage: (1.7 + 1.6) / 130.9. However, the output result here does not retain decimal places, so the final result is 3%.
   
   SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/760ec8ff-7878-4e32-9052-554b93c0b662)
   
   In the SCM UI, the calculation formula for storage usage percentage is: 1.7 / 130.9. In the final output result, we retain 1 decimal place, so the final result is 1.3%. It should be pointed out that Non Ozone Used is not the actual storage capacity used by Ozone.
   @xBis7, what are your thoughts?
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887426720

   That's why I asked about capacity. Is it referring to the entire disk or just Ozone?


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1889210226

   @jianghuazhu The latest approach looks good. Displaying `Total` as well could be practical.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457423355


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");

Review Comment:
   Can you please clarify the question?
   
   My suggestion is to change the value displayed in table cells:
   
   ```diff
   -scmUsed: 12.34%, nonScmUsed: 1.23%
   +Ozone: 12.34%, other: 1.23%
   ```
   
   (`...` are just placeholders in my previous comment)



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1903643839

   Thanks @jianghuazhu for the patch, @dombizita, @xBis7 for the review.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1903640010

   Thanks @dombizita .


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1900505961

   Thanks @jianghuazhu for improving the patch.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1871328474

   ci: https://github.com/jianghuazhu/ozone/actions/runs/7348062465
   New web ui: 
   ![image](https://github.com/apache/ozone/assets/6416939/cde92264-8d02-4311-9047-affa58a8ab25)
   
   Can you help review this PR,  @adoroszlai  @hemantk-12 .
   Thanks.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1882943106

   Thanks @whbing .
   The DataNode UI already displays the total storage size and used size. Does it still need to be displayed in the SCM UI?
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1872926277

   Can you help review this PR, @aswinshakil  @fapifta  @szetszwo .
   Thanks.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457414097


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");
       nodes.put(hostName, map);
     }
     return nodes;
   }
 
+  /**
+   * Calculate the storage capacity of the DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public String calculateStorageCapacity(DatanodeInfo dni) {
+    long capacityByte = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      for (StorageReportProto storageReport : storageReports) {
+        capacityByte += storageReport.getCapacity();
+      }
+    }
+
+    double ua = capacityByte;
+    StringBuilder unit = new StringBuilder("B");
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 1, "KB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "MB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "GB");
+    }
+    if (ua > 1024) {
+      ua = ua / 1024;
+      unit.replace(0, 2, "TB");
+    }
+
+    DecimalFormat decimalFormat = new DecimalFormat("#0.0");
+    decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+    double capacity = Double.valueOf(decimalFormat.format(ua));
+    return capacity + unit.toString();
+  }
+
+  /**
+   * Calculate the storage usage percentage of a DataNode node.
+   * @param dni DataNode node that needs to be calculated.
+   * @return
+   */
+  public double[] calculateStoragePercentage(DatanodeInfo dni) {
+    double[] storagePercentage = new double[2];
+    double usedPercentage = 0;
+    double nonUsedPercentage = 0;
+    List<StorageReportProto> storageReports = dni.getStorageReports();
+    if (storageReports != null && !storageReports.isEmpty()) {
+      long capacity = 0;
+      long scmUsed = 0;
+      long remaining = 0;
+      for (StorageReportProto storageReport : storageReports) {
+        capacity += storageReport.getCapacity();
+        scmUsed += storageReport.getScmUsed();
+        remaining += storageReport.getRemaining();
+      }
+      long scmNonUsed = capacity - scmUsed - remaining;
+
+      DecimalFormat decimalFormat = new DecimalFormat("#0.00");
+      decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+
+      double usedPerc = ((double) scmUsed / capacity) * 100;
+      usedPerc = usedPerc > 100.0 ? 100.0 : usedPerc;
+      double nonUsedPerc = ((double) scmNonUsed / capacity) * 100;
+      nonUsedPerc = nonUsedPerc > 100.0 ? 100.0 : nonUsedPerc;
+      usedPercentage = Double.valueOf(decimalFormat.format(usedPerc));
+      nonUsedPercentage = Double.valueOf(decimalFormat.format(nonUsedPerc));

Review Comment:
   I will update soon.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887484418

   I think the percentage of storage usage here is relative to the entire disk.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1443507613


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1109,6 +1112,23 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      List<StorageReportProto> storageReports = dni.getStorageReports();
+      if (storageReports != null && !storageReports.isEmpty()) {
+        long capacity = 0;
+        long scmUsed = 0;
+        for (StorageReportProto storageReport : storageReports) {
+          capacity = capacity + storageReport.getCapacity();
+          scmUsed = scmUsed + storageReport.getScmUsed();
+        }
+        double percent = (double) scmUsed / capacity;
+        percent = percent > 100.0 ? 100.0 : percent;
+        DecimalFormat decimalFormat = new DecimalFormat("#0.0000");
+        decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+        double usedPec = Double.valueOf(decimalFormat.format(percent)) * 100;
+        map.put(usedPercent, usedPec + "%");
+      } else {
+        map.put(usedPercent, "0%");

Review Comment:
   @jianghuazhu Can you move the logic for calculating the percentage to a method so that it can be easily tested? Also if you can add a unit test.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1443609849


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1109,6 +1112,23 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      List<StorageReportProto> storageReports = dni.getStorageReports();
+      if (storageReports != null && !storageReports.isEmpty()) {
+        long capacity = 0;
+        long scmUsed = 0;
+        for (StorageReportProto storageReport : storageReports) {
+          capacity = capacity + storageReport.getCapacity();
+          scmUsed = scmUsed + storageReport.getScmUsed();
+        }
+        double percent = (double) scmUsed / capacity;
+        percent = percent > 100.0 ? 100.0 : percent;
+        DecimalFormat decimalFormat = new DecimalFormat("#0.0000");
+        decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
+        double usedPec = Double.valueOf(decimalFormat.format(percent)) * 100;
+        map.put(usedPercent, usedPec + "%");
+      } else {
+        map.put(usedPercent, "0%");

Review Comment:
   Thanks @xBis7  for the comment.
   I'll update soon.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1444358188


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1572,83 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      long free = capacity - used;
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, free, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  @Test

Review Comment:
   We can avoid repetition by parameterising the test. It can have only 1 dn and the parameters can be the `capacity` and `used` from the `generateStorageReportProto` and the expected result.
   
   Regarding parameterising the test, here is an example
   
   https://github.com/apache/ozone/blob/master/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java#L208-L251



##########
hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html:
##########
@@ -48,6 +48,8 @@ <h2>Node Status</h2>
         <tr>
             <th ng-click = "columnSort('hostname')" class="nodeStatusInfo"><span ng-class = "{'sorting' : (columnName != 'hostname'), 'sortasc' : (columnName == 'hostname' && !reverse),
                                         'sortdesc':(columnName == 'hostname' && !reverse)}">HostName</span></th>
+            <th ng-click = "columnSort('usedpercent')" class="nodeStatusInfo" ><span ng-class="{'sorting' : (columnName != 'usedpercent'), 'sortasc' : (columnName == 'usedpercent' && !reverse),
+                                        'sortdesc':(columnName == 'usedpercent' && !reverse)}">Used Percent</span></th>

Review Comment:
   Nit: Wouldn't it be more intuitive if we renamed it to `Used Space Percent` or `Used Space Percentage`? Or is it too long and it breaks the UI?



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java:
##########
@@ -1572,6 +1572,83 @@ public void testScmStatsFromNodeReport()
     }
   }
 
+  private List<StorageReportProto> generateStorageReportProto(
+      int volumeCount, UUID dnId, long capacity, long used) {
+    List<StorageReportProto> reports = new ArrayList<>(volumeCount);
+    boolean failed = true;
+    for (int x = 0; x < volumeCount; x++) {
+      long free = capacity - used;
+      String storagePath = testDir.getAbsolutePath() + "/" + dnId;
+      reports.add(HddsTestUtils
+          .createStorageReport(dnId, storagePath, capacity,
+              used, free, null, failed));
+      failed = !failed;
+    }
+    return reports;
+  }
+
+  @Test
+  public void testCalculateStoragePercentage()
+      throws IOException, AuthenticationException {
+    OzoneConfiguration conf = getConf();
+    conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 1000,
+        MILLISECONDS);
+    try (SCMNodeManager nodeManager = createNodeManager(conf)) {
+      EventQueue eventQueue = (EventQueue) scm.getEventQueue();
+      LayoutVersionManager versionManager =
+          nodeManager.getLayoutVersionManager();
+      LayoutVersionProto layoutInfo = toLayoutVersionProto(
+          versionManager.getMetadataLayoutVersion(),
+          versionManager.getSoftwareLayoutVersion());
+      // Generate the first DataNode
+      DatanodeDetails dn1 = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId1 = dn1.getUuid();
+      int volumeCount = 10;
+      List<StorageReportProto> reports1 = generateStorageReportProto(
+          volumeCount, dnId1, 1000, 600);
+      nodeManager.register(dn1, HddsTestUtils.createNodeReport(reports1,
+          emptyList()), null);
+      nodeManager.processHeartbeat(dn1, layoutInfo);
+      // Generate the 2nd DataNode
+      DatanodeDetails dn2 = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId2 = dn2.getUuid();
+      List<StorageReportProto> reports2 = generateStorageReportProto(
+          volumeCount, dnId2, 1000, 1000);
+      nodeManager.register(dn2, HddsTestUtils.createNodeReport(reports2,
+          emptyList()), null);
+      nodeManager.processHeartbeat(dn2, layoutInfo);
+      // Generate the 3rd DataNode
+      DatanodeDetails dn3 = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId3 = dn3.getUuid();
+      List<StorageReportProto> reports3 = generateStorageReportProto(
+          volumeCount, dnId3, 1000, 1001);
+      nodeManager.register(dn3, HddsTestUtils.createNodeReport(reports3,
+          emptyList()), null);
+      nodeManager.processHeartbeat(dn3, layoutInfo);
+      // Generate the 4th DataNode
+      DatanodeDetails dn4 = MockDatanodeDetails.randomDatanodeDetails();
+      UUID dnId4 = dn4.getUuid();
+      nodeManager.register(dn4, null, null);
+      nodeManager.processHeartbeat(dn4, layoutInfo);
+

Review Comment:
   Can you add a 5th dn with a decimal percentage?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887124391

   Thanks for testing it out. Capacity refers to the entire disk space, right? It's not just Ozone disk space. 
   
   If there is a lot of space from the total capacity, occupied by non Ozone files, and the SCM UI doesn't report it, then the  `Used Space Percentage` will be misleading.
   
   e.g. 
   * We have 100 TB of disk space 
   * Ozone takes up to 5TB 
   * Other non Ozone files take another 2TB
   
   In that scenario, you have 
   * 7% space used
   * SCM UI reports 5%?
   * You still don't have 95% available but only 93%
   
   Is there an easy way to include that number in the SCM UI? 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1887037519

   > It should be pointed out that Non Ozone Used is not the actual storage capacity used by Ozone.
   
   Where does `Non Ozone Used` come from? 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #5882:
URL: https://github.com/apache/ozone/pull/5882#discussion_r1457416873


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -1113,11 +1117,94 @@ public Map<String, Map<String, String>> getNodeStatusInfo() {
         map.put(httpsPort.getName().toString(),
                   httpsPort.getValue().toString());
       }
+      String capacity = calculateStorageCapacity(dni);
+      map.put(totalCapacity, capacity);
+      double[] storagePercentage = calculateStoragePercentage(dni);
+      double scmUsedPerc = storagePercentage[0];
+      double nonScmUsedPerc = storagePercentage[1];
+      map.put(usedSpacePercent,
+          "scmUsed: " + scmUsedPerc + "%, nonScmUsed: " + nonScmUsedPerc + "%");

Review Comment:
   Is there a definite way of expressing this?
   Then we display 'Ozone: ... , other: ...'?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #5882:
URL: https://github.com/apache/ozone/pull/5882#issuecomment-1890224188

   @xBis7 , I've updated.
   ci: https://github.com/jianghuazhu/ozone/actions/runs/7505648725
   New SCM UI:
   ![image](https://github.com/apache/ozone/assets/6416939/09249c62-9649-4b45-972c-71b77cb48e0f)


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-9988. SCM UI shows storage usage percentage [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai merged PR #5882:
URL: https://github.com/apache/ozone/pull/5882


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org