{"record":{"id":"66aadbfbffc1e09b","repo":"apache/hadoop","slug":"getused-on-path-is-not-within-a-mount-point","errorCode":null,"errorMessage":"getUsed on path `/' is not within a mount point","messagePattern":"getUsed on path `/' is not within a mount point","errorType":"exception","errorClass":"NotInMountpointException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java","lineNumber":1316,"sourceCode":"    }\n    InodeTree.ResolveResult<FileSystem> res = fsState.resolve(\n        getUriPath(p), true);\n    return res.targetFileSystem.getStatus(p);\n  }\n\n  /**\n   * Return the total size of all files under \"/\", if {@link\n   * Constants#CONFIG_VIEWFS_LINK_MERGE_SLASH} is supported and is a valid\n   * mount point. Else, throw NotInMountpointException.\n   *\n   * @throws IOException raised on errors performing I/O.\n   */\n  @Override\n  public long getUsed() throws IOException {\n    InodeTree.ResolveResult<FileSystem> res = fsState.resolve(\n        getUriPath(InodeTree.SlashPath), true);\n    if (res.isInternalDir()) {\n      throw new NotInMountpointException(InodeTree.SlashPath, \"getUsed\");\n    } else {\n      return res.targetFileSystem.getUsed();\n    }\n  }\n\n  @Override\n  public Path getLinkTarget(Path path) throws IOException {\n    InodeTree.ResolveResult<FileSystem> res;\n    try {\n      res = fsState.resolve(getUriPath(path), true);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(path, \"getLinkTarget\");\n    }\n    return res.targetFileSystem.getLinkTarget(res.remainingPath);\n  }\n\n  /**\n   * Reject the concat operation; forward the rest to the viewed FS.","sourceCodeStart":1298,"sourceCodeEnd":1334,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L1298-L1334","documentation":"ViewFileSystem.getUsed() is only meaningful when the root '/' itself is a real mount, which happens when the mount table uses linkMergeSlash (fs.viewfs.mounttable.default.linkMergeSlash). The code resolves '/'; if the result is an internal mount-table directory (res.isInternalDir()), there is no single file system to ask and it throws NotInMountpointException(InodeTree.SlashPath, 'getUsed').","triggerScenarios":"Calling fs.getUsed() on a viewfs:// URI whose mount table has only leaf mounts (link.X entries) and no linkMergeSlash; monitoring or accounting tools that sum used bytes via FileSystem.getUsed() against the default FS.","commonSituations":"Cluster-monitoring agents wired to fs.defaultFS=viewfs://cluster after a federation migration; scripts ported from plain HDFS that used getUsed() for capacity reporting; mount tables intentionally keeping '/' virtual for mount management.","solutions":["Add fs.viewfs.mounttable.default.linkMergeSlash=hdfs://nameservice1/ so '/' resolves to a real cluster and getUsed() delegates","Report usage per mount instead: iterate `hadoop fs -ls viewfs://cluster/` and call getStatus()/getUsed() on each mounted child path","Query the target cluster(s) directly with fs.getStatus() or dfsadmin -report for capacity figures","Catch NotInMountpointException in generic dashboards and display per-cluster values rather than one aggregate"],"exampleFix":"// before\nFileSystem fs = FileSystem.get(new URI(\"viewfs://cluster\"), conf);\nlong used = fs.getUsed(); // throws: '/' is an internal dir\n\n// after\nlong used = 0;\ntry {\n  used = fs.getUsed();\n} catch (NotInMountpointException e) {\n  for (FileStatus st : fs.listStatus(new Path(\"/\"))) {\n    used += fs.getContentSummary(st.getPath()).getSpaceConsumed();\n  }\n}","handlingStrategy":"fallback","validationCode":"// Detect a virtual root before calling getUsed\nstatic boolean rootIsRealMount(Configuration conf) {\n  return conf.get(\"fs.viewfs.mounttable.default.linkMergeSlash\") != null;\n}","typeGuard":null,"tryCatchPattern":"long used;\ntry {\n  used = fs.getUsed();\n} catch (NotInMountpointException e) {\n  used = 0;\n  for (FileStatus st : fs.listStatus(new Path(\"/\"))) {\n    used += fs.getContentSummary(st.getPath()).getSpaceConsumed();\n  }\n}","preventionTips":["Do not wire capacity dashboards to FileSystem.getUsed() on a viewfs default FS","Use linkMergeSlash if a single aggregate value is required","Report per-mount usage during staged migrations"],"tags":["viewfs","hadoop","mount-table","linkmergeslash","capacity"],"backgroundTag":"viewfs-not-in-mountpoint","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}