apache/hadoop · error · IllegalArgumentException
${name}, which is located at ${networkLocation}, is not a de
Error message
${name}, which is located at ${networkLocation}, is not a descendant of ${path} What it means
IllegalArgumentException from InnerNodeImpl.add(Node) when the node being added is not located under this inner node: n's network location does not begin with this node's path, so it cannot become a child. The message includes the node name, its network location, and the path it was expected to descend from. The check keeps the topology tree consistent — you can only add '/dc1/rack1/node1' to '/dc1/rack1' or its ancestors.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/InnerNodeImpl.java:132
if (!isAncestor(n)) {
throw new IllegalArgumentException(
this + "is not an ancestor of " + n);
}
String name = n.getNetworkLocation().substring(getPath(this).length());
if (name.charAt(0) == PATH_SEPARATOR) {
name = name.substring(1);
}
int index=name.indexOf(PATH_SEPARATOR);
if (index != -1) {
name = name.substring(0, index);
}
return name;
}
@Override
public boolean add(Node n) {
if (!isAncestor(n)) {
throw new IllegalArgumentException(n.getName()
+ ", which is located at " + n.getNetworkLocation()
+ ", is not a descendant of " + getPath(this));
}
if (isParent(n)) {
// this node is the parent of n; add n directly
n.setParent(this);
n.setLevel(this.level+1);
Node prev = childrenMap.put(n.getName(), n);
if (prev != null) {
for(int i=0; i<children.size(); i++) {
if (children.get(i).getName().equals(n.getName())) {
children.set(i, n);
return false;
}
}
}
children.add(n);
numOfLeaves++;View on GitHub (pinned to 2add963021)
Solutions
- Before add(), verify isAncestor(n) or use NetworkTopology.add() which locates the correct parent instead of guessing
- Normalize all network locations in the topology script: leading '/', no trailing '/', same depth everywhere
- Check that getLeaf/getInner lookups use the same location format that was used at Node registration
Example fix
// before innerNodeRackA.add(nodeInRackB); // nodeInRackB.getNetworkLocation()=/rackB -> IllegalArgumentException // after NetworkTopology clusterTopology = new NetworkTopologyImpl(); clusterTopology.add(nodeInRackB); // routes to the correct parent automatically
Defensive patterns
Strategy: validation
Validate before calling
if (!innerNode.isAncestor(n)) {
// do not guess the parent; let NetworkTopology locate it
topology.add(n);
return;
} Try / catch
catch (IllegalArgumentException e) { /* 'not a descendant of' */ log n's location vs expected path; re-resolve parent via getInner/NetworkTopology; } Prevention
- Prefer NetworkTopology.add() over InnerNode.add() in application code
- Normalize location strings at Node construction time
- Assert isAncestor before manual tree manipulation in tests
When it happens
Trigger: Adding a DataNode whose network location is '/rackB' to an InnerNode with path '/rackA'; calling add() on a node obtained by getLeaf while the leaf's location changed; mixing relative ('rack1') and absolute ('/rack1') location strings so the prefix test fails.
Common situations: Topology script returning different racks for the same node over time; DataNodes re-registered with a changed network location; custom Node implementations whose getNetworkLocation() is not normalized.
Related errors
- ${node}is not an ancestor of ${n}
- Wrong length: {digest.length}
- Wrong length: {hex.length}
- Not a hex character: {c}
- No schema options are provided
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/2a91c5c842b7a632.
Report an issue: GitHub.