{"record":{"id":"b84447a86775a90a","repo":"apache/hadoop","slug":"cannot-find-locations-for-in","errorCode":null,"errorMessage":"Cannot find locations for {} in {}","messagePattern":"Cannot find locations for (.+?) in (.+?)","errorType":"exception","errorClass":"NoLocationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java","lineNumber":1375,"sourceCode":"   * <p>\n   *   /a - [ns0 - /a]\n   *   /a/b - [ns0 - /a/b]\n   *   /a/b/c - [ns1 - /a/b/c]\n   * </p>\n   * When the path is '/a', the result of locations should be\n   * [RemoteLocation('/a', ns0, '/a'), RemoteLocation('/a/b/c', ns1, '/a/b/c')]\n   * When the path is '/b', will throw NoLocationException.\n   *\n   * @param path the path to get content summary\n   * @return one list contains all the remote location\n   * @throws IOException if an I/O error occurs\n   */\n  @VisibleForTesting\n  protected List<RemoteLocation> getLocationsForContentSummary(String path) throws IOException {\n    // Try to get all the locations of the path.\n    final Map<String, List<RemoteLocation>> ns2Locations = getAllLocations(path);\n    if (ns2Locations.isEmpty()) {\n      throw new NoLocationException(path, subclusterResolver.getClass());\n    }\n\n    final List<RemoteLocation> locations = new ArrayList<>();\n    // remove the redundancy remoteLocation order by destination.\n    ns2Locations.forEach((k, v) -> {\n      List<RemoteLocation> sortedList = v.stream().sorted().collect(Collectors.toList());\n      int size = sortedList.size();\n      for (int i = size - 1; i > -1; i--) {\n        RemoteLocation currentLocation = sortedList.get(i);\n        if (i == 0) {\n          locations.add(currentLocation);\n        } else {\n          RemoteLocation preLocation = sortedList.get(i - 1);\n          if (!currentLocation.getDest().startsWith(preLocation.getDest() + Path.SEPARATOR)) {\n            locations.add(currentLocation);\n          } else {\n            LOG.debug(\"Ignore redundant location {}, because there is an ancestor location {}\",\n                currentLocation, preLocation);","sourceCodeStart":1357,"sourceCodeEnd":1393,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java#L1357-L1393","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add or fix the mount entry covering the path: hdfs dsadmin -addMount <path> <ns> <dest> (or add a / root/default mount)","Verify with 'hdfs dsadmin -listMountTable' that the queried path falls under some source path","If the data lives in one subcluster, run the content summary directly against that nameservice"],"exampleFix":"# before: /jobs not mounted -> NoLocationException\nhdfs dfs -fs hdfs://router -count /jobs\n\n# after: add the mount, then query\nhdfs dsadmin -addMount /jobs ns1 /jobs\nhdfs dfs -fs hdfs://router -count /jobs","handlingStrategy":"validation","validationCode":"// Confirm the path resolves to at least one mount before content summary\nMap<String, List<RemoteLocation>> all = ((RouterClientProtocol) proto).getAllLocations(path);\nif (all.isEmpty()) {\n  throw new FileNotFoundException(path + \" is not covered by any mount table entry\");\n}\nproto.getContentSummary(path);","typeGuard":null,"tryCatchPattern":"try {\n  proto.getContentSummary(path);\n} catch (NoLocationException e) { // subclass of IOException, catch before IOException\n  // path outside the mount table: add a mount entry for it or query the owning ns directly\n} catch (IOException e) { throw e; }","preventionTips":["Add a root or default mount entry so common top-level paths always resolve","Validate user paths against 'hdfs dsadmin -listMountTable' coverage in tooling","Catch NoLocationException specifically: it distinguishes mount-miss from real IO failures"],"tags":["hdfs","router-based-federation","content-summary","mount-table","resolution","no-location"],"backgroundTag":"path-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}