LinuxContainerExecutor extends ContainerExecutor { @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("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); } } LinuxContainerExecutor();  LinuxContainerExecutor(LinuxContainerRuntime linuxContainerRuntime); @Override void setConf(Configuration conf); @Override void init(Context context); @Override void start(); @Override void stop(); @Override void startLocalizer(LocalizerStartContext ctx); @VisibleForTesting void buildMainArgs(List<String> command, String user, String appId,
      String locId, InetSocketAddress nmAddr, String tokenFileName,
      List<String> localDirs); @Override void prepareContainer(ContainerPrepareContext ctx); @Override int launchContainer(ContainerStartContext ctx); @Override int relaunchContainer(ContainerStartContext ctx); @Override String[] getIpAndHost(Container container); @Override int reacquireContainer(ContainerReacquisitionContext ctx); @Override boolean signalContainer(ContainerSignalContext ctx); @Override boolean reapContainer(ContainerReapContext ctx); @Override IOStreamPair execContainer(ContainerExecContext ctx); @Override void deleteAsUser(DeletionAsUserContext ctx); @Override void symLink(String target, String symlink); @Override boolean isContainerAlive(ContainerLivenessContext ctx); void mountCgroups(List<String> cgroupKVs, String hierarchy); @VisibleForTesting ResourceHandler getResourceHandler(); void removeDockerContainer(String containerId); @Override synchronized void updateYarnSysFS(Context ctx, String user,
      String appId, String spec); @Override String getExposedPorts(Container container); @Override Map<String, LocalResource> getLocalResources(Container container);  }
@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); }