AllocationBasedResourceUtilizationTracker implements
    ResourceUtilizationTracker { @Override public boolean hasResourcesAvailable(Container container) { long pMemBytes = container.getResource().getMemorySize() * 1024 * 1024L; return hasResourcesAvailable(pMemBytes, (long) (getContainersMonitor().getVmemRatio()* pMemBytes), container.getResource().getVirtualCores()); } AllocationBasedResourceUtilizationTracker(ContainerScheduler scheduler); @Override ResourceUtilization getCurrentUtilization(); @Override void addContainerResources(Container container); @Override void subtractContainerResource(Container container); @Override boolean hasResourcesAvailable(Container container); ContainersMonitor getContainersMonitor();  }
@Test public void testHasResourcesAvailable() { AllocationBasedResourceUtilizationTracker tracker = new AllocationBasedResourceUtilizationTracker(mockContainerScheduler); Container testContainer = mock(Container.class); when(testContainer.getResource()).thenReturn(Resource.newInstance(512, 4)); for (int i = 0; i < 2; i++) { Assert.assertTrue(tracker.hasResourcesAvailable(testContainer)); tracker.addContainerResources(testContainer); } Assert.assertFalse(tracker.hasResourcesAvailable(testContainer)); }