private static PlacementRule getParentRule(Element parent,
                                             FairScheduler fs)
      throws AllocationConfigurationException {
    LOG.debug("Creating new parent rule: {}", parent.getAttribute("name"));
    PlacementRule parentRule = createRule(parent);
    // Init the rule, we do not want to add it to the list of the
    // placement manager
    try {
      parentRule.initialize(fs);
    } catch (IOException ioe) {
      // We should never throw as we pass in a FS object, however we
      // still should consider any exception here a config error.
      throw new AllocationConfigurationException(
          "Parent Rule initialisation failed with exception", ioe);
    }
    return parentRule;
  }
@Test
  public void testMultipleParentRules() throws Exception {
    StringBuilder sb = new StringBuilder();
    sb.append("<queuePlacementPolicy>");
    sb.append("  <rule name='nestedUserQueue'>");
    sb.append("    <rule name='primaryGroup'/>");
    sb.append("    <rule name='default'/>");
    sb.append("  </rule>");
    sb.append("</queuePlacementPolicy>");

    createPolicy(sb.toString());
    PlacementRule nested = placementManager.getPlacementRules().get(0);
    if (nested instanceof UserPlacementRule) {
      PlacementRule parent = ((FSPlacementRule)nested).getParentRule();
      assertTrue("Nested rule should have been Default rule",
          parent instanceof DefaultPlacementRule);
    } else {
      fail("Policy parsing failed: rule with multiple parents not set");
    }
  }