{"record":{"id":"ae86cb11bd4ba8f3","repo":"apache/hadoop","slug":"getdefaultreplication-on-path-f-is-not-within","errorCode":null,"errorMessage":"getDefaultReplication on path `<f>' is not within a mount point","messagePattern":"getDefaultReplication on path `<f>' 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":987,"sourceCode":"      InodeTree.ResolveResult<FileSystem> res =\n        fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getDefaultBlockSize(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultBlockSize\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultBlockSize for path \" + f + \" with exception\", e);\n    }\n  }\n\n  @Override\n  public short getDefaultReplication(Path f) {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n        fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getDefaultReplication(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultReplication\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultReplication for path \" + f + \" with exception\", e);\n    }\n  }\n\n  @Override\n  public FsServerDefaults getServerDefaults(Path f) throws IOException {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n          fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getServerDefaults(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getServerDefaults\");\n    }\n  }\n\n  @Override","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L969-L1005","documentation":"ViewFileSystem.getDefaultReplication(Path) resolves the path through the mount table; a FileNotFoundException from resolve() (path not under any mount link) is translated into NotInMountpointException('getDefaultReplication on path ... is not within a mount point'). Replication is a property of the target HDFS, so viewfs cannot answer for unmounted paths.","triggerScenarios":"Calling getDefaultReplication(path) where path resolves to an internal mount-table directory ('/' or a parent of mounts such as /data when only /data/hdfs is linked), or where the path prefix matches no configured fs.viewfs.mounttable.default.link.* entry.","commonSituations":"Output committers and writers that ask for default replication of the output directory when the output dir is not in the mount table; incomplete mount tables after a viewfs cutover; tests using viewfs URIs with a minimal config.","solutions":["Mount the directory in question, e.g. add fs.viewfs.mounttable.default.link.<name>=<target>","Point the replication query at a path that is already mounted (check with `hadoop fs -ls viewfs://cluster/`)","Add linkMergeSlash to cover the whole namespace: fs.viewfs.mounttable.default.linkMergeSlash=hdfs://nameservice1/","Catch NotInMountpointException and fall back to the target cluster's dfs.replication value"],"exampleFix":"// before\nshort rep = fs.getDefaultReplication(new Path(\"/staging\")); // throws if /staging not mounted\n\n// after\nshort rep;\ntry {\n  rep = fs.getDefaultReplication(new Path(\"/staging\"));\n} catch (NotInMountpointException e) {\n  rep = (short) conf.getInt(\"dfs.replication\", 3);\n}","handlingStrategy":"try-catch","validationCode":"// Ensure the replication query targets a mounted prefix\nstatic boolean replicationPathSafe(Configuration conf, Path p) {\n  return conf.get(\"fs.viewfs.mounttable.default.linkMergeSlash\") != null\n      || isMounted(conf, p); // see getDefaultBlockSize guard\n}","typeGuard":null,"tryCatchPattern":"try {\n  short rep = fs.getDefaultReplication(p);\n} catch (NotInMountpointException e) {\n  short rep = (short) conf.getInt(\"dfs.replication\", 3);\n}","preventionTips":["Mount output/staging directories so replication queries on them resolve","Cache replication defaults from the target cluster once instead of querying per path","Include replication-default queries in viewfs migration test suites"],"tags":["viewfs","hadoop","mount-table","replication","configuration"],"backgroundTag":"viewfs-not-in-mountpoint","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}