{"record":{"id":"99021bd82ab24c6e","repo":"apache/hadoop","slug":"no-dfs-available-in-child-file-systems","errorCode":null,"errorMessage":"No DFS available in child file systems.","messagePattern":"No DFS available in child file systems\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java","lineNumber":1260,"sourceCode":"\n    // No path available in CacheDirectiveInfo, Let's shoot to all child fs.\n    List<IOException> failedExceptions = new ArrayList<>();\n    boolean isDFSExistsInChilds = false;\n\n    for (FileSystem fs : getChildFileSystems()) {\n      if (!(fs instanceof DistributedFileSystem)) {\n        continue;\n      }\n      isDFSExistsInChilds = true;\n      DistributedFileSystem dfs = (DistributedFileSystem) fs;\n      try {\n        dfs.modifyCacheDirective(info);\n      } catch (IOException ioe) {\n        failedExceptions.add(ioe);\n      }\n    }\n    if (!isDFSExistsInChilds) {\n      throw new UnsupportedOperationException(\n          \"No DFS available in child file systems.\");\n    }\n    if (failedExceptions.size() > 0) {\n      throw MultipleIOException.createIOException(failedExceptions);\n    }\n  }\n\n  @Override\n  public void modifyCacheDirective(CacheDirectiveInfo info,\n      EnumSet<CacheFlag> flags) throws IOException {\n    if (this.vfs == null) {\n      super.modifyCacheDirective(info, flags);\n      return;\n    }\n    if (info.getPath() != null) {\n      ViewFileSystemOverloadScheme.MountPathInfo<FileSystem> mountPathInfo =\n          this.vfs.getMountPathInfo(info.getPath(), getConf());\n      checkDFS(mountPathInfo.getTargetFs(), \"modifyCacheDirective\");","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java#L1242-L1278","documentation":"ViewDistributedFileSystem.modifyCacheDirective(info) fans the call out to all child filesystems. If none is a DistributedFileSystem it throws UnsupportedOperationException(\"No DFS available in child file systems.\"); if some children are DFS but their calls fail, failures are aggregated into MultipleIOException.","triggerScenarios":"Calling modifyCacheDirective on a ViewHDFS instance whose mounts are all non-HDFS (object stores or local filesystem), so getChildFileSystems() yields no DistributedFileSystem.","commonSituations":"Centralized caching scripts run against a viewfs URI with no HDFS mounts; mixed mount tables where admins expect cache APIs to work on a non-DFS default.","solutions":["Invoke modifyCacheDirective on the concrete DistributedFileSystem of the target cluster","Ensure at least one HDFS mount exists if the view-level cache API must work","Catch UnsupportedOperationException to detect a DFS-less view configuration early"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"DistributedFileSystem dfs = findChildDfs(vfs);\nif (dfs == null) {\n  throw new UnsupportedOperationException(\n      \"no HDFS child; call modifyCacheDirective on the target cluster\");\n}\ndfs.modifyCacheDirective(info);","typeGuard":"static boolean hasDfsChild(FileSystem fs) {\n  return fs instanceof DistributedFileSystem\n      || (fs instanceof ViewDistributedFileSystem\n          && ((ViewDistributedFileSystem) fs).getChildFileSystems().stream()\n              .anyMatch(c -> c instanceof DistributedFileSystem));\n}","tryCatchPattern":"try {\n  vfs.modifyCacheDirective(info);\n} catch (UnsupportedOperationException e) {\n  if (\"No DFS available in child file systems.\".equals(e.getMessage())) {\n    dfs.modifyCacheDirective(info); // route to concrete cluster\n  } else {\n    throw e;\n  }\n}","preventionTips":["Run cache directive APIs on concrete DistributedFileSystem instances, not views","Verify the view has HDFS children before adopting view-level caching workflows"],"tags":["hdfs","viewfs","centralized-caching","unsupported"],"backgroundTag":"viewfs-unsupported-dfs-api","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}