apache/hadoop · error · IllegalArgumentException
Not allow to remove an inner node: {}
Error message
Not allow to remove an inner node: {} What it means
NetworkTopologyWithNodeGroup.remove(Node) keeps the base-class contract: only leaf nodes can be removed. Inner nodes (racks and nodegroups) are structural and managed by the topology, so an InnerNode argument throws IllegalArgumentException before the write lock is taken.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java:232
}
}
if(LOG.isDebugEnabled()) {
LOG.debug("NetworkTopology became:\n" + this.toString());
}
} finally {
netlock.writeLock().unlock();
}
}
/** Remove a node
* Update node counter and rack counter if necessary
* @param node node to be removed; can be null
*/
@Override
public void remove(Node node) {
if (node==null) return;
if( node instanceof InnerNode ) {
throw new IllegalArgumentException(
"Not allow to remove an inner node: "+NodeBase.getPath(node));
}
LOG.info("Removing a node: "+NodeBase.getPath(node));
netlock.writeLock().lock();
try {
if (clusterMap.remove(node)) {
Node nodeGroup = getNode(node.getNetworkLocation());
if (nodeGroup == null) {
nodeGroup = factory.newInnerNode(node.getNetworkLocation());
}
InnerNode rack = (InnerNode)getNode(nodeGroup.getNetworkLocation());
if (rack == null) {
numOfRacks--;
}
}
if(LOG.isDebugEnabled()) {
LOG.debug("NetworkTopology became:\n" + this.toString());
}View on GitHub (pinned to 2add963021)
Solutions
- Remove the leaf datanodes individually; nodegroup and rack levels clean up automatically
- Guard with !(node instanceof InnerNode) before remove()
- Rebuild the topology object if you need a full reset
Example fix
// before
topology.remove(nodeByPath); // could be an InnerNode
// after
if (!(nodeByPath instanceof InnerNode)) {
topology.remove(nodeByPath);
} Defensive patterns
Strategy: validation
Validate before calling
if (!(node instanceof InnerNode)) {
topologyWithNodeGroup.remove(node);
} Type guard
static boolean isRemovableLeaf(Node n) {
return n != null && !(n instanceof InnerNode);
} Prevention
- Type-check nodes from path lookups before remove() in node-group clusters too
- Drain nodegroups by removing their member datanodes
When it happens
Trigger: Calling remove(node) with a node instanceof InnerNode — a nodegroup/rack object from getNode(), or a mock extending InnerNode/InnerNodeWithNodeGroup.
Common situations: Node-group cluster tooling that resolves targets by path and removes without a type check; tests stubbing Node with an InnerNode base.
Related errors
- Not allow to add an inner node: {}
- Not allow to add an inner node: {}
- Not allow to remove an inner node: {}
- Unexpected data node {} at an illegal network location
- Unsupported comparator: {comparator}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/d2d411cd4ad38776.
Report an issue: GitHub.