apache/hadoop · error · IllegalArgumentException

Not allow to add an inner node: {}

Error message

Not allow to add an inner node: {}

What it means

NetworkTopologyWithNodeGroup models a three-level /rack/nodegroup/host topology. Its add(Node) override keeps the base class rule — only leaf nodes may be added — and throws IllegalArgumentException for any InnerNode (including InnerNodeWithNodeGroup) before taking the write lock.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopologyWithNodeGroup.java:180

  /**
   * Check if network topology is aware of NodeGroup
   */
  @Override
  public boolean isNodeGroupAware() {
    return true;
  }

  /** Add a leaf node
   * Update node counter & rack counter if necessary
   * @param node node to be added; can be null
   * @exception IllegalArgumentException if add a node to a leave 
   *                                     or node to be added is not a leaf
   */
  @Override
  public void add(Node node) {
    if (node==null) return;
    if( node instanceof InnerNode ) {
      throw new IllegalArgumentException(
        "Not allow to add an inner node: "+NodeBase.getPath(node));
    }
    netlock.writeLock().lock();
    try {
      Node rack = null;

      // if node only with default rack info, here we need to add default 
      // nodegroup info
      if (NetworkTopology.DEFAULT_RACK.equals(node.getNetworkLocation())) {
        node.setNetworkLocation(node.getNetworkLocation() + 
            NetworkTopologyWithNodeGroup.DEFAULT_NODEGROUP);
      }
      Node nodeGroup = getNode(node.getNetworkLocation());
      if (nodeGroup == null) {
        nodeGroup = new InnerNodeWithNodeGroup(node.getNetworkLocation());
      }
      rack = getNode(nodeGroup.getNetworkLocation());

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass only leaf nodes (DatanodeDescriptor / NodeBase not extending InnerNode) to add()
  2. Filter lookup results with !(node instanceof InnerNode) first
  3. Never construct InnerNodeWithNodeGroup for registration; the topology creates nodegroups internally

Example fix

// before
topology.add(factory.newInnerNode("/rack1/ng1")); // throws

// after
Node leaf = new NodeBase("host1:50010", "/rack1/ng1");
topology.add(leaf);
Defensive patterns

Strategy: validation

Validate before calling

if (node instanceof InnerNode) {
  throw new IllegalArgumentException(
      "Refusing to add inner node " + NodeBase.getPath(node));
}
topologyWithNodeGroup.add(node);

Type guard

static boolean isAddableLeaf(Node n) {
  return n != null && !(n instanceof InnerNode);
}

Prevention

When it happens

Trigger: Calling add() on a node-group-aware topology with an InnerNode instance, e.g. a nodegroup created via factory.newInnerNode() or a node fetched with getNode() that is actually inner.

Common situations: Custom topology tooling for node-group clusters (Hadoop compute deployments using nodegroup-aware placement); re-adding nodes returned by lookups; mocks extending InnerNodeWithNodeGroup.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/4d0cbf2290d75c89. Report an issue: GitHub.