@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;
  }
@Test
  public void testAllocateNumaMemoryResource() throws ResourceHandlerException {
    // allocates node 0 for memory and cpu
    testAllocateNumaResource("container_1481156246874_0001_01_000001",
        Resource.newInstance(2048, 2), "0", "0");
    // allocates node 1 for memory and cpu since allocator uses round
    // robin assignment
    testAllocateNumaResource("container_1481156246874_0001_01_000002",
        Resource.newInstance(60000, 2), "1", "1");
    // allocates node 0,1 for memory since there is no sufficient memory in any
    // one node
    testAllocateNumaResource("container_1481156246874_0001_01_000003",
        Resource.newInstance(80000, 2), "0,1", "0");
    // returns null since there are no sufficient resources available for the
    // request
    when(mockContainer.getContainerId()).thenReturn(
        ContainerId.fromString("container_1481156246874_0001_01_000004"));
    when(mockContainer.getResource())
        .thenReturn(Resource.newInstance(80000, 2));
    assertNull(numaResourceHandler.preStart(mockContainer));
    // allocates node 1 for memory and cpu
    testAllocateNumaResource("container_1481156246874_0001_01_000005",
        Resource.newInstance(1024, 2), "1", "1");
  }