apache/hadoop · error · IllegalArgumentException

Only MachineNode can be added to RackNode

Error message

Only MachineNode can be added to RackNode

What it means

Rumen topology guard: RackNode.addChild only accepts MachineNode children; an attempt was made to attach a different node type to a rack.

Solutions

  1. Add only MachineNode instances as children of a RackNode.
Defensive patterns

Strategy: validation

When it happens

Trigger: A non-MachineNode node is added as a child of a RackNode in a Rumen topology; racks may only contain machines.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hadoop-tools/hadoop-rumen/src/main/java/org/apache/hadoop/tools/rumen/RackNode.java:34

 * limitations under the License.
 */
package org.apache.hadoop.tools.rumen;

import java.util.Set;

/**
 * {@link RackNode} represents a rack node in the cluster topology.
 */
public final class RackNode extends Node {
  public RackNode(String name, int level) {
    // Hack: ensuring rack name starts with "/".
    super(name.startsWith("/") ? name : "/" + name, level);
  }
  
  @Override
  public synchronized boolean addChild(Node child) {
    if (!(child instanceof MachineNode)) {
      throw new IllegalArgumentException(
          "Only MachineNode can be added to RackNode");
    }
    return super.addChild(child);
  }
  
  /**
   * Get the machine nodes that belong to the rack.
   * @return The machine nodes that belong to the rack.
   */
  @SuppressWarnings({ "cast", "unchecked" })
  public Set<MachineNode> getMachinesInRack() {
    return (Set<MachineNode>)(Set)getChildren();
  }
}

View on GitHub (pinned to 2add963021)