apache/hadoop · error · NoLocationException

Cannot find locations for {} in {}

Error message

Cannot find locations for {} in {}

What it means

getLocationsForContentSummary() must fan a contentSummary out to every namespace containing the path, so it resolves ALL locations (including sub-mounts). If getAllLocations(path) returns an empty map - the path is not covered by any mount table entry - it throws NoLocationException('Cannot find locations for <path> in <resolverClass>'), an IOException subclass. The message names the resolver class (normally MountTableResolver) to hint the mount table lacks a mapping.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java:1375

   * <p>
   *   /a - [ns0 - /a]
   *   /a/b - [ns0 - /a/b]
   *   /a/b/c - [ns1 - /a/b/c]
   * </p>
   * When the path is '/a', the result of locations should be
   * [RemoteLocation('/a', ns0, '/a'), RemoteLocation('/a/b/c', ns1, '/a/b/c')]
   * When the path is '/b', will throw NoLocationException.
   *
   * @param path the path to get content summary
   * @return one list contains all the remote location
   * @throws IOException if an I/O error occurs
   */
  @VisibleForTesting
  protected List<RemoteLocation> getLocationsForContentSummary(String path) throws IOException {
    // Try to get all the locations of the path.
    final Map<String, List<RemoteLocation>> ns2Locations = getAllLocations(path);
    if (ns2Locations.isEmpty()) {
      throw new NoLocationException(path, subclusterResolver.getClass());
    }

    final List<RemoteLocation> locations = new ArrayList<>();
    // remove the redundancy remoteLocation order by destination.
    ns2Locations.forEach((k, v) -> {
      List<RemoteLocation> sortedList = v.stream().sorted().collect(Collectors.toList());
      int size = sortedList.size();
      for (int i = size - 1; i > -1; i--) {
        RemoteLocation currentLocation = sortedList.get(i);
        if (i == 0) {
          locations.add(currentLocation);
        } else {
          RemoteLocation preLocation = sortedList.get(i - 1);
          if (!currentLocation.getDest().startsWith(preLocation.getDest() + Path.SEPARATOR)) {
            locations.add(currentLocation);
          } else {
            LOG.debug("Ignore redundant location {}, because there is an ancestor location {}",
                currentLocation, preLocation);

View on GitHub (pinned to 2add963021)

Solutions

  1. Add or fix the mount entry covering the path: hdfs dsadmin -addMount <path> <ns> <dest> (or add a / root/default mount)
  2. Verify with 'hdfs dsadmin -listMountTable' that the queried path falls under some source path
  3. If the data lives in one subcluster, run the content summary directly against that nameservice

Example fix

# before: /jobs not mounted -> NoLocationException
hdfs dfs -fs hdfs://router -count /jobs

# after: add the mount, then query
hdfs dsadmin -addMount /jobs ns1 /jobs
hdfs dfs -fs hdfs://router -count /jobs
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the path resolves to at least one mount before content summary
Map<String, List<RemoteLocation>> all = ((RouterClientProtocol) proto).getAllLocations(path);
if (all.isEmpty()) {
  throw new FileNotFoundException(path + " is not covered by any mount table entry");
}
proto.getContentSummary(path);

Try / catch

try {
  proto.getContentSummary(path);
} catch (NoLocationException e) { // subclass of IOException, catch before IOException
  // path outside the mount table: add a mount entry for it or query the owning ns directly
} catch (IOException e) { throw e; }

Prevention

When it happens

Trigger: hdfs dfs -count/-du through the Router on a path outside every mount entry (e.g. /tmp or / when only /data and /logs are mounted); querying a path before its mount entry is added; using a non-default FileSubclusterResolver whose resolution yields nothing for the path.

Common situations: Fresh RBF deployments forget a root/default mount entry so top-level paths resolve nowhere; mount entry removed while clients still reference the path; content summary tools walking from the federation root without a root mount.

Related errors


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