NumaResourceHandlerImpl implements ResourceHandler { @Override public List<PrivilegedOperation> preStart(Container container) throws ResourceHandlerException { List<PrivilegedOperation> ret = null; NumaResourceAllocation numaAllocation = numaResourceAllocator .allocateNumaNodes(container); if (numaAllocation != null) { ret = new ArrayList<>(); ArrayList<String> args = new ArrayList<>(); args.add(numaCtlCmd); args.add( "--interleave=" + String.join(",", numaAllocation.getMemNodes())); args.add( "--cpunodebind=" + String.join(",", numaAllocation.getCpuNodes())); ret.add(new PrivilegedOperation(OperationType.ADD_NUMA_PARAMS, args)); } return ret; } NumaResourceHandlerImpl(Configuration conf, Context nmContext); @Override List<PrivilegedOperation> bootstrap(Configuration configuration); @Override List<PrivilegedOperation> preStart(Container container); @Override List<PrivilegedOperation> reacquireContainer(ContainerId containerId); @Override List<PrivilegedOperation> updateContainer(Container container); @Override List<PrivilegedOperation> postComplete(ContainerId containerId); @Override List<PrivilegedOperation> teardown(); @Override String toString();  }
@Test public void testAllocateNumaMemoryResource() throws ResourceHandlerException { testAllocateNumaResource("container_1481156246874_0001_01_000001", Resource.newInstance(2048, 2), "0", "0"); testAllocateNumaResource("container_1481156246874_0001_01_000002", Resource.newInstance(60000, 2), "1", "1"); testAllocateNumaResource("container_1481156246874_0001_01_000003", Resource.newInstance(80000, 2), "0,1", "0"); when(mockContainer.getContainerId()).thenReturn( ContainerId.fromString("container_1481156246874_0001_01_000004")); when(mockContainer.getResource()) .thenReturn(Resource.newInstance(80000, 2)); assertNull(numaResourceHandler.preStart(mockContainer)); testAllocateNumaResource("container_1481156246874_0001_01_000005", Resource.newInstance(1024, 2), "1", "1"); }
@Test public void testAllocateNumaCpusResource() throws ResourceHandlerException { testAllocateNumaResource("container_1481156246874_0001_01_000001", Resource.newInstance(2048, 2), "0", "0"); testAllocateNumaResource("container_1481156246874_0001_01_000002", Resource.newInstance(2048, 2), "1", "1"); testAllocateNumaResource("container_1481156246874_0001_01_000003", Resource.newInstance(2048, 3), "0", "0,1"); when(mockContainer.getContainerId()).thenReturn( ContainerId.fromString("container_1481156246874_0001_01_000004")); when(mockContainer.getResource()).thenReturn(Resource.newInstance(2048, 2)); assertNull(numaResourceHandler.preStart(mockContainer)); testAllocateNumaResource("container_1481156246874_0001_01_000005", Resource.newInstance(2048, 1), "1", "1"); }