{"record":{"id":"73efd6299cae6c81","repo":"apache/hadoop","slug":"only-machinenode-can-be-added-to-racknode","errorCode":null,"errorMessage":"Only MachineNode can be added to RackNode","messagePattern":"Only MachineNode can be added to RackNode","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-rumen/src/main/java/org/apache/hadoop/tools/rumen/RackNode.java","lineNumber":34,"sourceCode":" * limitations under the License.\n */\npackage org.apache.hadoop.tools.rumen;\n\nimport java.util.Set;\n\n/**\n * {@link RackNode} represents a rack node in the cluster topology.\n */\npublic final class RackNode extends Node {\n  public RackNode(String name, int level) {\n    // Hack: ensuring rack name starts with \"/\".\n    super(name.startsWith(\"/\") ? name : \"/\" + name, level);\n  }\n  \n  @Override\n  public synchronized boolean addChild(Node child) {\n    if (!(child instanceof MachineNode)) {\n      throw new IllegalArgumentException(\n          \"Only MachineNode can be added to RackNode\");\n    }\n    return super.addChild(child);\n  }\n  \n  /**\n   * Get the machine nodes that belong to the rack.\n   * @return The machine nodes that belong to the rack.\n   */\n  @SuppressWarnings({ \"cast\", \"unchecked\" })\n  public Set<MachineNode> getMachinesInRack() {\n    return (Set<MachineNode>)(Set)getChildren();\n  }\n}\n","sourceCodeStart":16,"sourceCodeEnd":49,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-rumen/src/main/java/org/apache/hadoop/tools/rumen/RackNode.java#L16-L49","documentation":"Error \"Only MachineNode can be added to RackNode\" thrown in apache/hadoop.","triggerScenarios":"A non-MachineNode node is added as a child of a RackNode in a Rumen topology; racks may only contain machines.","commonSituations":"See trigger scenarios.","solutions":["Add only MachineNode instances as children of a RackNode."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}