@Override
  public Resource getMaximumResourceCapability(String queueName) {
    if(queueName == null || queueName.isEmpty()) {
      return  getMaximumResourceCapability();
    }
    FSQueue queue = queueMgr.getQueue(queueName);
    Resource schedulerLevelMaxResourceCapability =
        getMaximumResourceCapability();
    if (queue == null) {
      return schedulerLevelMaxResourceCapability;
    }
    Resource queueMaxResourceCapability = queue.getMaximumContainerAllocation();
    if (queueMaxResourceCapability.equals(Resources.unbounded())) {
      return schedulerLevelMaxResourceCapability;
    } else {
      return Resources.componentwiseMin(schedulerLevelMaxResourceCapability,
          queueMaxResourceCapability);
    }
  }
@Test
  public void testQueueMaximumCapacityAllocations() throws IOException {
    conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);

    int tooHighQueueAllocation = RM_SCHEDULER_MAXIMUM_ALLOCATION_MB_VALUE +1;

    AllocationFileWriter.create()
        .addQueue(new AllocationFileQueue.Builder("queueA")
            .maxContainerAllocation("512 mb 1 vcores").build())
        .addQueue(new AllocationFileQueue.Builder("queueB").build())
        .addQueue(new AllocationFileQueue.Builder("queueC")
            .maxContainerAllocation("2048 mb 3 vcores")
            .subQueue(new AllocationFileQueue.Builder("queueD").build())
            .build())
        .addQueue(new AllocationFileQueue.Builder("queueE")
            .maxContainerAllocation(tooHighQueueAllocation + " mb 1 vcores")
            .build())
        .writeToFile(ALLOC_FILE);

    scheduler.init(conf);

    Assert.assertEquals(1, scheduler.getMaximumResourceCapability("root.queueA")
        .getVirtualCores());
    Assert.assertEquals(512,
        scheduler.getMaximumResourceCapability("root.queueA").getMemorySize());

    Assert.assertEquals(DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
        scheduler.getMaximumResourceCapability("root.queueB")
            .getVirtualCores());
    Assert.assertEquals(RM_SCHEDULER_MAXIMUM_ALLOCATION_MB_VALUE,
        scheduler.getMaximumResourceCapability("root.queueB").getMemorySize());

    Assert.assertEquals(3, scheduler.getMaximumResourceCapability("root.queueC")
        .getVirtualCores());
    Assert.assertEquals(2048,
        scheduler.getMaximumResourceCapability("root.queueC").getMemorySize());

    Assert.assertEquals(3, scheduler
        .getMaximumResourceCapability("root.queueC.queueD").getVirtualCores());
    Assert.assertEquals(2048, scheduler
        .getMaximumResourceCapability("root.queueC.queueD").getMemorySize());

    Assert.assertEquals(RM_SCHEDULER_MAXIMUM_ALLOCATION_MB_VALUE, scheduler
        .getMaximumResourceCapability("root.queueE").getMemorySize());
  }