You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "mkuchenbecker (via GitHub)" <gi...@apache.org> on 2023/02/22 19:02:26 UTC

[GitHub] [hadoop] mkuchenbecker commented on a diff in pull request #5397: HDFS-16917 Add transfer rate quantile metrics for DataNode reads

mkuchenbecker commented on code in PR #5397:
URL: https://github.com/apache/hadoop/pull/5397#discussion_r1114833478


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java:
##########
@@ -1936,4 +1936,20 @@ public static boolean isParentEntry(final String path, final String parent) {
     return path.charAt(parent.length()) == Path.SEPARATOR_CHAR
         || parent.equals(Path.SEPARATOR);
   }
+
+  /**
+   * Calculate the transfer rate in megabytes/second. Return -1 for any negative input.
+   * @param bytes bytes
+   * @param durationMS duration in milliseconds
+   * @return the number of megabytes/second of the transfer rate
+  */
+  public static long transferRateMBs(long bytes, long durationMS) {
+    if (bytes < 0 || durationMS < 0) {
+      return -1;
+    }
+    if (durationMS == 0) {
+      durationMS = 1;
+    }
+    return bytes / (1024 * 1024) * 1000 / durationMS;

Review Comment:
   I would make this bytes per second and let the consumer do the conversion. 



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

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


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