public void mountCgroups(List<String> cgroupKVs, String hierarchy)
      throws IOException {
    try {
      PrivilegedOperation mountCGroupsOp = new PrivilegedOperation(
          PrivilegedOperation.OperationType.MOUNT_CGROUPS, hierarchy);
      Configuration conf = super.getConf();

      mountCGroupsOp.appendArgs(cgroupKVs);
      PrivilegedOperationExecutor privilegedOperationExecutor =
          getPrivilegedOperationExecutor();

      privilegedOperationExecutor.executePrivilegedOperation(mountCGroupsOp,
          false);
    } catch (PrivilegedOperationException e) {
      int exitCode = e.getExitCode();
      LOG.warn("Exception in LinuxContainerExecutor mountCgroups ", e);

      throw new IOException("Problem mounting cgroups " + cgroupKVs +
          "; exit code = " + exitCode + " and output: " + e.getOutput(),
          e);
    }
  }
@Test
  public void testCGroups() throws Exception {
    Assume.assumeTrue(shouldRun());
    String cgroupsMount = System.getProperty("cgroups.mount");
    Assume.assumeTrue((cgroupsMount != null) && !cgroupsMount.isEmpty());

    assertTrue("Cgroups mount point does not exist", new File(
        cgroupsMount).exists());
    List<String> cgroupKVs = new ArrayList<>();

    String hierarchy = "hadoop-yarn";
    String[] controllers = { "cpu", "net_cls" };
    for (String controller : controllers) {
      cgroupKVs.add(controller + "=" + cgroupsMount + "/" + controller);
      assertTrue(new File(cgroupsMount, controller).exists());
    }

    try {
      exec.mountCgroups(cgroupKVs, hierarchy);
      for (String controller : controllers) {
        assertTrue(controller + " cgroup not mounted", new File(
            cgroupsMount + "/" + controller + "/tasks").exists());
        assertTrue(controller + " cgroup hierarchy not created",
            new File(cgroupsMount + "/" + controller + "/" + hierarchy).exists());
        assertTrue(controller + " cgroup hierarchy created incorrectly",
            new File(cgroupsMount + "/" + controller + "/" + hierarchy
                + "/tasks").exists());
      }
    } catch (IOException ie) {
      fail("Couldn't mount cgroups " + ie.toString());
      throw ie;
    }
  }