public void setMaxAMShare(Resource resource) {
    maxAMShareMB.set(resource.getMemorySize());
    maxAMShareVCores.set(resource.getVirtualCores());
    if (customResources != null) {
      customResources.setMaxAMShare(resource);
    }
  }
@Test
  public void testSetMaxAMShare() {
    FSQueueMetrics metrics = setupMetrics(RESOURCE_NAME);

    Resource res = Resource.newInstance(2048L, 4, ImmutableMap.of(RESOURCE_NAME,
        20L));
    metrics.setMaxAMShare(res);

    assertEquals(getErrorMessage("maxAMShareMB"),
        2048L, metrics.getMaxAMShareMB());
    assertEquals(getErrorMessage("maxAMShareVcores"),
        4L, metrics.getMaxAMShareVCores());
    assertEquals(getErrorMessage("maxAMShareMB"),
        2048L, metrics.getMaxAMShare().getMemorySize());
    assertEquals(getErrorMessage("maxAMShareVcores"),
        4L, metrics.getMaxAMShare().getVirtualCores());
    assertEquals(getErrorMessage(
        "maxAMShare for resource: " + RESOURCE_NAME),
        20L, metrics.getMaxAMShare().getResourceValue(RESOURCE_NAME));

    res = Resource.newInstance(2049L, 5);
    metrics.setMaxAMShare(res);

    assertEquals(getErrorMessage("maxAMShareMB"),
        2049L, metrics.getMaxAMShareMB());
    assertEquals(getErrorMessage("maxAMShareVcores"),
        5L, metrics.getMaxAMShareVCores());
    assertEquals(getErrorMessage("maxAMShareMB"),
        2049L, metrics.getMaxAMShare().getMemorySize());
    assertEquals(getErrorMessage("maxAMShareVcores"),
        5L, metrics.getMaxAMShare().getVirtualCores());
    assertEquals(getErrorMessage(
        "maxAMShare for resource: " + RESOURCE_NAME),
        0, metrics.getMaxAMShare().getResourceValue(RESOURCE_NAME));
  }