apache/hadoop · error · UnsupportedOperationException
No DFS found in child fs. This API can't be supported in non
Error message
No DFS found in child fs. This API can't be supported in non DFS
What it means
ViewDistributedFileSystem.listCacheDirectives throws UnsupportedOperationException("No DFS found in child fs. This API can't be supported in non DFS") only in the fallback path: when the filter has no path, it queries every child DistributedFileSystem, and if none exists the API has nothing to serve. When the filter carries a path, the call routes to that mount's DFS instead.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java:1362
if (filter != null && filter.getPath() != null) {
ViewFileSystemOverloadScheme.MountPathInfo<FileSystem> mountPathInfo =
this.vfs.getMountPathInfo(filter.getPath(), getConf());
checkDFS(mountPathInfo.getTargetFs(), "listCacheDirectives");
return ((DistributedFileSystem) mountPathInfo.getTargetFs())
.listCacheDirectives(new CacheDirectiveInfo.Builder(filter)
.setPath(mountPathInfo.getPathOnTarget()).build());
}
// No path available in filter. Let's try to shoot to all child fs.
final List<RemoteIterator<CacheDirectiveEntry>> iters = new ArrayList<>();
for (FileSystem fs : getChildFileSystems()) {
if (fs instanceof DistributedFileSystem) {
iters.add(((DistributedFileSystem) fs).listCacheDirectives(filter));
}
}
if (iters.size() == 0) {
throw new UnsupportedOperationException(
"No DFS found in child fs. This API can't be supported in non DFS");
}
return new RemoteIterator<CacheDirectiveEntry>() {
int currIdx = 0;
RemoteIterator<CacheDirectiveEntry> currIter = iters.get(currIdx++);
@Override
public boolean hasNext() throws IOException {
if (currIter.hasNext()) {
return true;
}
while (currIdx < iters.size()) {
currIter = iters.get(currIdx++);
if (currIter.hasNext()) {
return true;
}
}View on GitHub (pinned to 2add963021)
Solutions
- Set a path in the CacheDirectiveInfo filter so the call routes to a specific mount's DFS
- Or call listCacheDirectives directly on the child DistributedFileSystem
- Ensure the view contains at least one HDFS mount
Example fix
// before: empty filter, fails when no HDFS child exists
RemoteIterator<CacheDirectiveEntry> it =
vfs.listCacheDirectives(new CacheDirectiveInfo.Builder().build());
// after: scope the filter to a path so it routes to that mount
RemoteIterator<CacheDirectiveEntry> it = vfs.listCacheDirectives(
new CacheDirectiveInfo.Builder().setPath(new Path("/data")).build()); Defensive patterns
Strategy: validation
Validate before calling
// Prefer a path-scoped filter: it routes to a specific mount and never
// depends on DFS children existing
CacheDirectiveInfo scoped = new CacheDirectiveInfo.Builder(filter)
.setPath(new Path("/data")).build();
RemoteIterator<CacheDirectiveEntry> it = vfs.listCacheDirectives(scoped); Type guard
static boolean canListUnfiltered(FileSystem fs) {
return fs instanceof DistributedFileSystem
|| (fs instanceof ViewDistributedFileSystem
&& ((ViewDistributedFileSystem) fs).getChildFileSystems().stream()
.anyMatch(c -> c instanceof DistributedFileSystem));
} Try / catch
try {
return vfs.listCacheDirectives(filter);
} catch (UnsupportedOperationException e) {
if (e.getMessage() != null && e.getMessage().contains("No DFS found in child fs")) {
return Collections.emptyIterator(); // no HDFS child means no directives
}
throw e;
} Prevention
- Always set a path in the CacheDirectiveInfo filter when using views
- Feature-check child filesystems before list-all style calls
When it happens
Trigger: Calling listCacheDirectives with a CacheDirectiveInfo filter that has no path set, on a ViewHDFS with zero DistributedFileSystem children.
Common situations: Generic list-all tools using an empty filter against viewfs URIs with only object-store mounts.
Related errors
- No DFS available in child file systems.
- createSymlink is not supported in ViewHDFS
- No more elements
- Not able to initialize fs in getDefaultBlockSize for path <
- Not able to initialize fs in getDefaultReplication for path
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/fb6a64eb1aa2e2fe.
Report an issue: GitHub.