apache/hadoop · error · NotInMountpointException

getUsed on path `/' is not within a mount point

Error message

getUsed on path `/' is not within a mount point

What it means

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').

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java:1316

    }
    InodeTree.ResolveResult<FileSystem> res = fsState.resolve(
        getUriPath(p), true);
    return res.targetFileSystem.getStatus(p);
  }

  /**
   * Return the total size of all files under "/", if {@link
   * Constants#CONFIG_VIEWFS_LINK_MERGE_SLASH} is supported and is a valid
   * mount point. Else, throw NotInMountpointException.
   *
   * @throws IOException raised on errors performing I/O.
   */
  @Override
  public long getUsed() throws IOException {
    InodeTree.ResolveResult<FileSystem> res = fsState.resolve(
        getUriPath(InodeTree.SlashPath), true);
    if (res.isInternalDir()) {
      throw new NotInMountpointException(InodeTree.SlashPath, "getUsed");
    } else {
      return res.targetFileSystem.getUsed();
    }
  }

  @Override
  public Path getLinkTarget(Path path) throws IOException {
    InodeTree.ResolveResult<FileSystem> res;
    try {
      res = fsState.resolve(getUriPath(path), true);
    } catch (FileNotFoundException e) {
      throw new NotInMountpointException(path, "getLinkTarget");
    }
    return res.targetFileSystem.getLinkTarget(res.remainingPath);
  }

  /**
   * Reject the concat operation; forward the rest to the viewed FS.

View on GitHub (pinned to 2add963021)

Solutions

  1. Add fs.viewfs.mounttable.default.linkMergeSlash=hdfs://nameservice1/ so '/' resolves to a real cluster and getUsed() delegates
  2. Report usage per mount instead: iterate `hadoop fs -ls viewfs://cluster/` and call getStatus()/getUsed() on each mounted child path
  3. Query the target cluster(s) directly with fs.getStatus() or dfsadmin -report for capacity figures
  4. Catch NotInMountpointException in generic dashboards and display per-cluster values rather than one aggregate

Example fix

// before
FileSystem fs = FileSystem.get(new URI("viewfs://cluster"), conf);
long used = fs.getUsed(); // throws: '/' is an internal dir

// after
long used = 0;
try {
  used = fs.getUsed();
} catch (NotInMountpointException e) {
  for (FileStatus st : fs.listStatus(new Path("/"))) {
    used += fs.getContentSummary(st.getPath()).getSpaceConsumed();
  }
}
Defensive patterns

Strategy: fallback

Validate before calling

// Detect a virtual root before calling getUsed
static boolean rootIsRealMount(Configuration conf) {
  return conf.get("fs.viewfs.mounttable.default.linkMergeSlash") != null;
}

Try / catch

long used;
try {
  used = fs.getUsed();
} catch (NotInMountpointException e) {
  used = 0;
  for (FileStatus st : fs.listStatus(new Path("/"))) {
    used += fs.getContentSummary(st.getPath()).getSpaceConsumed();
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/66aadbfbffc1e09b. Report an issue: GitHub.