{"record":{"id":"12c604c403b64ca8","repo":"apache/hadoop","slug":"capacity-ratio-is-not-between-0-to-1","errorCode":null,"errorMessage":"Capacity ratio{} is not between 0 to 1: {}","messagePattern":"Capacity ratio(.+?) is not between 0 to 1: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java","lineNumber":182,"sourceCode":"   * @throws SecurityException when format is incorrect or ratio is not\n   *         between 0 - 1.\n   */\n  public static Map<URI, Double> parseCapacityRatio(String capacityRatioConf)\n      throws SecurityException {\n    Map<URI, Double> result = new HashMap<>();\n    capacityRatioConf = capacityRatioConf.replaceAll(\"\\\\s\", \"\");\n    if (capacityRatioConf.isEmpty()) {\n      return result;\n    }\n    String[] capacityRatios = capacityRatioConf.split(\",\");\n    for (String ratio : capacityRatios) {\n      Matcher matcher = CAPACITY_RATIO_REGEX.matcher(ratio);\n      if (matcher.matches()) {\n        String capacityString = matcher.group(1).trim();\n        String location = matcher.group(2).trim();\n        double capacityRatio = Double.parseDouble(capacityString);\n        if (capacityRatio > 1 || capacityRatio < 0) {\n          throw new IllegalArgumentException(\"Capacity ratio\" + capacityRatio\n              + \" is not between 0 to 1: \" + ratio);\n        }\n        result.put(new Path(location).toUri(), capacityRatio);\n      } else {\n        throw new IllegalArgumentException(\n            \"Capacity ratio config is not with correct format: \"\n                + capacityRatioConf\n        );\n      }\n    }\n    return result;\n  }\n\n  @Override\n  public String toString() {\n    return \"[\" + storageType + \"]\" + baseURI.normalize();\n  }\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java#L164-L200","documentation":"StorageLocation.parseCapacityRatio() parses dfs.datanode.same.disk.tiering.capacity.ratio.percentage, a comma list of '[ratio]/path' entries (regex ^\\[([0-9.]*)\\](.+)$) that assigns each volume a fraction of its disk for same-disk tiering. After Double.parseDouble, a ratio outside [0,1] (negative or greater than 1) throws IllegalArgumentException listing the bad ratio and entry.","triggerScenarios":"Configuring e.g. [1.2]/disk1 or [-0.1]/disk1 in dfs.datanode.same.disk.tiering.capacity.ratio.percentage; also values like [0.5.] that parse to something odd, or percentages written as [50] instead of the fractional [0.5].","commonSituations":"Same-disk-tiering setups (mixing ARCHIVE on DISK mounts, HDFS-15418 era feature) where the admin wrote a percentage (50) instead of a fraction (0.5), or fractions that individually pass but were intended to sum differently; typos like 2.0 for 0.2.","solutions":["Rewrite every ratio as a fraction between 0 and 1 inclusive, e.g. [0.5]/disk1/archive","If you intended percentages, divide by 100: 30% -> [0.3]","Restart the DataNode and confirm parse succeeds (no startup abort)"],"exampleFix":"# before (hdfs-site.xml)\n<property>\n  <name>dfs.datanode.same.disk.tiering.capacity.ratio.percentage</name>\n  <value>[50]/disk1/archive,[0.3]/disk2/archive</value>\n</property>\n\n# after\n<property>\n  <name>dfs.datanode.same.disk.tiering.capacity.ratio.percentage</name>\n  <value>[0.5]/disk1/archive,[0.3]/disk2/archive</value>\n</property>","handlingStrategy":"validation","validationCode":"import java.util.regex.*;\nstatic final Pattern P = Pattern.compile(\"^\\\\[([0-9.]*)\\\\](.+)$\");\nvoid checkCapacityRatios(String conf) {\n  for (String t : conf.replaceAll(\"\\\\s\", \"\").split(\",\")) {\n    Matcher m = P.matcher(t);\n    if (!m.matches()) throw new IllegalArgumentException(\"Bad format: \" + t);\n    double d = Double.parseDouble(m.group(1));\n    if (d < 0 || d > 1) throw new IllegalArgumentException(\"Ratio out of [0,1]: \" + t);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Express capacity ratios as fractions (0.3 = 30%), never raw percentages","Add a config-lint step for dfs.datanode.same.disk.tiering.capacity.ratio.percentage in deploy pipelines"],"tags":["hdfs","datanode","storage","config","capacity","tiering","illegal-argument"],"backgroundTag":"config-value-out-of-range","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}