コード例 #1
0
 /**
  * Given the DiskUsage for a node and the size of the shard, return the percentage of free disk if
  * the shard were to be allocated to the node.
  *
  * @param usage A DiskUsage for the node to have space computed for
  * @param shardSize Size in bytes of the shard
  * @return Percentage of free space after the shard is assigned to the node
  */
 public double freeDiskPercentageAfterShardAssigned(DiskUsage usage, Long shardSize) {
   shardSize = (shardSize == null) ? 0 : shardSize;
   DiskUsage newUsage =
       new DiskUsage(
           usage.getNodeId(),
           usage.getNodeName(),
           usage.getPath(),
           usage.getTotalBytes(),
           usage.getFreeBytes() - shardSize);
   return newUsage.getFreeDiskAsPercentage();
 }