@Override
  public synchronized void updateYarnSysFS(Context ctx, String user,
      String appId, String spec) throws IOException {
    LocalDirsHandlerService dirsHandler = nmContext.getLocalDirsHandler();
    Path sysFSPath = dirsHandler.getLocalPathForWrite(
        "nmPrivate/" + appId + "/sysfs/app.json");
    File file = new File(sysFSPath.toString());
    List<String> localDirs = dirsHandler.getLocalDirs();
    if (file.exists()) {
      if (!file.delete()) {
        LOG.warn("Unable to delete {}", sysFSPath);
      }
    }
    if (file.createNewFile()) {
      FileOutputStream output = new FileOutputStream(file);
      try {
        output.write(spec.getBytes(StandardCharsets.UTF_8));
      } finally {
        output.close();
      }
    }
    PrivilegedOperation privOp = new PrivilegedOperation(
        PrivilegedOperation.OperationType.SYNC_YARN_SYSFS);
    String runAsUser = getRunAsUser(user);
    privOp.appendArgs(runAsUser,
        user,
        Integer.toString(PrivilegedOperation.RunAsUserCommand
        .SYNC_YARN_SYSFS.getValue()),
        appId, StringUtils.join(PrivilegedOperation
            .LINUX_FILE_PATH_SEPARATOR, localDirs));
    privOp.disableFailureLogging();
    PrivilegedOperationExecutor privilegedOperationExecutor =
        PrivilegedOperationExecutor.getInstance(nmContext.getConf());
    try {
      privilegedOperationExecutor.executePrivilegedOperation(null,
            privOp, null, null, false, false);
    } catch (PrivilegedOperationException e) {
      throw new IOException(e);
    }
  }
@Test
  public void testUpdateYarnSysFS() throws Exception {
    String user = System.getProperty("user.name");
    String appId="app-1";
    String spec="";
    Context ctx = mock(Context.class);
    LinuxContainerExecutor lce = mock(LinuxContainerExecutor.class);
    lce.updateYarnSysFS(ctx, user, appId, spec);
    verify(lce, times(1)).updateYarnSysFS(ctx, user, appId, spec);
  }