FMX commented on code in PR #2071:
URL: 
https://github.com/apache/incubator-celeborn/pull/2071#discussion_r1384511750


##########
common/src/main/scala/org/apache/celeborn/common/util/DiskUtils.scala:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.common.util
+
+import java.nio.file.{Files, Paths}
+
+import org.apache.celeborn.common.meta.DiskInfo
+
+/**
+ * Disk utilities provide detail of disk info including disk statistics etc.
+ */
+object DiskUtils {
+
+  /**
+   * Gets the minimum usable size for each disk, which size is the max space 
between the reserved space
+   * and the space calculate via reserved ratio.
+   *
+   * @param diskInfo The reserved disk info.
+   * @param diskReserveSize The reserved space for each disk.
+   * @param diskReserveRatio The reserved ratio for each disk.
+   * @return the minimum usable space.
+   */
+  def getMinimumUsableSize(
+      diskInfo: DiskInfo,
+      diskReserveSize: Long,
+      diskReserveRatio: Option[Double]): Long = {
+    var minimumUsableSize = diskReserveSize
+    if (diskReserveRatio.isDefined) {
+      try {
+        val totalSpace = 
Files.getFileStore(Paths.get(diskInfo.mountPoint)).getTotalSpace
+        minimumUsableSize =

Review Comment:
   MinimumUsableSize should be totalSpace - (BigDecimal(totalSpace * 
diskReserveRatio.get).longValue.max(minimumUsableSize)).
   
   Reserve size means a disk space that a disk should not be used. Just like 
the `dfs.datanode.du.reserved`.



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

Reply via email to