org.apache.hadoop.conf.ConfigurableWindowsSecureContainerExecutorpublic class DefaultContainerExecutor extends ContainerExecutor
DefaultContainerExecuter class offers generic container
execution services. Process execution is handled in a platform-independent
way via ProcessBuilder.| Modifier and Type | Class | Description |
|---|---|---|
protected class |
DefaultContainerExecutor.LocalWrapperScriptBuilder |
This class is a utility to create a wrapper script that is platform
appropriate.
|
ContainerExecutor.DelayedProcessKiller, ContainerExecutor.ExitCode, ContainerExecutor.Signal| Modifier and Type | Field | Description |
|---|---|---|
protected org.apache.hadoop.fs.FileContext |
lfs |
A
FileContext for the local file system. |
DIRECTORY_CONTENTS, TASK_LAUNCH_SCRIPT_PERMISSION, TOKEN_FILE_NAME_FMT, WILDCARD| Constructor | Description |
|---|---|
DefaultContainerExecutor() |
Default constructor for use in testing.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected org.apache.hadoop.util.Shell.CommandExecutor |
buildCommandExecutor(java.lang.String wrapperScriptPath,
java.lang.String containerIdStr,
java.lang.String user,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.yarn.api.records.Resource resource,
java.io.File workDir,
java.util.Map<java.lang.String,java.lang.String> environment,
java.lang.String[] numaCommands) |
Create a new
Shell.ShellCommandExecutor using the parameters. |
void |
clearLogDirPermissions() |
Clear the internal variable for repeatable testing.
|
static boolean |
containerIsAlive(java.lang.String pid) |
Returns true if the process with the specified pid is alive.
|
protected void |
copyFile(org.apache.hadoop.fs.Path src,
org.apache.hadoop.fs.Path dst,
java.lang.String owner) |
Copy a file using the
lfs FileContext. |
protected ContainerLocalizer |
createContainerLocalizer(java.lang.String user,
java.lang.String appId,
java.lang.String locId,
java.lang.String tokenFileName,
java.util.List<java.lang.String> localDirs,
org.apache.hadoop.fs.FileContext localizerFc) |
Create a new
ContainerLocalizer instance. |
protected void |
createDir(org.apache.hadoop.fs.Path dirPath,
org.apache.hadoop.fs.permission.FsPermission perms,
boolean createParent,
java.lang.String user) |
Use the
lfs FileContext to create the target directory. |
void |
deleteAsUser(DeletionAsUserContext ctx) |
Delete specified directories as a given user.
|
org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair |
execContainer(ContainerExecContext ctx) |
Perform interactive docker command into running container.
|
protected DefaultContainerExecutor.LocalWrapperScriptBuilder |
getLocalWrapperScriptBuilder(java.lang.String containerIdStr,
org.apache.hadoop.fs.Path containerWorkDir) |
Create a
DefaultContainerExecutor.LocalWrapperScriptBuilder for the given container ID
and path that is appropriate to the current platform. |
java.lang.String |
getLogDirPermissions() |
Return the default container log directory permissions.
|
protected org.apache.hadoop.fs.Path |
getWorkingDir(java.util.List<java.lang.String> localDirs,
java.lang.String user,
java.lang.String appId) |
Return a randomly chosen application directory from a list of local storage
directories.
|
void |
init(Context nmContext) |
Run the executor initialization steps.
|
boolean |
isContainerAlive(ContainerLivenessContext ctx) |
Check if a container is alive.
|
protected void |
killContainer(java.lang.String pid,
ContainerExecutor.Signal signal) |
Send a specified signal to the specified pid
|
int |
launchContainer(ContainerStartContext ctx) |
Launch the container on the node.
|
void |
postComplete(org.apache.hadoop.yarn.api.records.ContainerId containerId) |
clean up and release of resources.
|
int |
reacquireContainer(ContainerReacquisitionContext ctx) |
Recover an already existing container.
|
boolean |
reapContainer(ContainerReapContext ctx) |
No-op for reaping containers within the DefaultContainerExecutor.
|
int |
relaunchContainer(ContainerStartContext ctx) |
Relaunch the container on the node.
|
void |
setNumactl(java.lang.String numactl) |
|
void |
setNumaResourceAllocator(NumaResourceAllocator numaResourceAllocator) |
|
protected void |
setScriptExecutable(org.apache.hadoop.fs.Path script,
java.lang.String owner) |
Make a file executable using the
lfs FileContext. |
boolean |
signalContainer(ContainerSignalContext ctx) |
Signal container with the specified signal.
|
void |
startLocalizer(LocalizerStartContext ctx) |
Prepare the environment for containers in this application to execute.
|
void |
symLink(java.lang.String target,
java.lang.String symlink) |
Create a symlink file which points to the target.
|
void |
updateYarnSysFS(Context ctx,
java.lang.String user,
java.lang.String appId,
java.lang.String spec) |
Update cluster information inside container.
|
activateContainer, cleanupBeforeRelaunch, deactivateContainer, getConf, getExposedPorts, getIpAndHost, getLocalIpAndHost, getLocalResources, getNMEnvVar, getPidFilePath, getProcessId, getRunCommand, getRunCommand, getRunCommandForOther, getRunCommandForWindows, isContainerActive, localizeClasspathJar, logOutput, pauseContainer, prepareContainer, readDirAsUser, resumeContainer, setConf, start, stop, writeLaunchEnv, writeLaunchEnvprotected final org.apache.hadoop.fs.FileContext lfs
FileContext for the local file system.@VisibleForTesting public DefaultContainerExecutor()
protected void copyFile(org.apache.hadoop.fs.Path src,
org.apache.hadoop.fs.Path dst,
java.lang.String owner)
throws java.io.IOException
lfs FileContext.src - the file to copydst - where to copy the fileowner - the owner of the new copy. Used only in secure Windows
clustersjava.io.IOException - when the copy failsWindowsSecureContainerExecutorprotected void setScriptExecutable(org.apache.hadoop.fs.Path script,
java.lang.String owner)
throws java.io.IOException
lfs FileContext.script - the path to make executableowner - the new owner for the file. Used only in secure Windows
clustersjava.io.IOException - when the change mode operation failsWindowsSecureContainerExecutorpublic void init(Context nmContext) throws java.io.IOException
ContainerExecutorinit in class ContainerExecutornmContext - Context of NMjava.io.IOException - if initialization failspublic void startLocalizer(LocalizerStartContext ctx) throws java.io.IOException, java.lang.InterruptedException
ContainerExecutorFor $x in local.dirs create $x/$user/$appId Copy $nmLocal/appTokens -> $N/$user/$appId For $rsrc in private resources Copy $rsrc -> $N/$user/filecache/[idef] For $rsrc in job resources Copy $rsrc -> $N/$user/$appId/filecache/idef
startLocalizer in class ContainerExecutorctx - LocalizerStartContext that encapsulates necessary information
for starting a localizer.java.io.IOException - for most application init failuresjava.lang.InterruptedException - if application init thread is halted by NM@Private @VisibleForTesting protected ContainerLocalizer createContainerLocalizer(java.lang.String user, java.lang.String appId, java.lang.String locId, java.lang.String tokenFileName, java.util.List<java.lang.String> localDirs, org.apache.hadoop.fs.FileContext localizerFc) throws java.io.IOException
ContainerLocalizer instance.user - the user who owns the job for which the localization is being
runappId - the ID of the application for which the localization is being
runlocId - the ID of the container for which the localization is being
runlocalDirs - a list of directories to use as destinations for the
localizationlocalizerFc - the FileContext to use when localizing filesContainerLocalizer instancejava.io.IOException - if user or locId is null or if
the container localizer has an initialization failurepublic int launchContainer(ContainerStartContext ctx) throws java.io.IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
ContainerExecutorlaunchContainer in class ContainerExecutorctx - Encapsulates information necessary for launching containers.java.io.IOException - if the container launch failsorg.apache.hadoop.yarn.exceptions.ConfigurationException - if config error was foundpublic int relaunchContainer(ContainerStartContext ctx) throws java.io.IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
ContainerExecutorrelaunchContainer in class ContainerExecutorctx - Encapsulates information necessary for relaunching containers.java.io.IOException - if the container relaunch failsorg.apache.hadoop.yarn.exceptions.ConfigurationException - if config error was foundprotected org.apache.hadoop.util.Shell.CommandExecutor buildCommandExecutor(java.lang.String wrapperScriptPath,
java.lang.String containerIdStr,
java.lang.String user,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.yarn.api.records.Resource resource,
java.io.File workDir,
java.util.Map<java.lang.String,java.lang.String> environment,
java.lang.String[] numaCommands)
Shell.ShellCommandExecutor using the parameters.wrapperScriptPath - the path to the script to executecontainerIdStr - the container IDuser - the application owner's usernamepidFile - the path to the container's PID fileresource - this parameter controls memory and CPU limits.workDir - If not-null, specifies the directory which should be set
as the current working directory for the command. If null,
the current working directory is not modified.environment - the container environmentnumaCommands - list of prefix numa commandsShell.ShellCommandExecutorShell.ShellCommandExecutorprotected DefaultContainerExecutor.LocalWrapperScriptBuilder getLocalWrapperScriptBuilder(java.lang.String containerIdStr, org.apache.hadoop.fs.Path containerWorkDir)
DefaultContainerExecutor.LocalWrapperScriptBuilder for the given container ID
and path that is appropriate to the current platform.containerIdStr - the container IDcontainerWorkDir - the container's working directoryDefaultContainerExecutor.LocalWrapperScriptBuilderpublic boolean signalContainer(ContainerSignalContext ctx) throws java.io.IOException
ContainerExecutorsignalContainer in class ContainerExecutorctx - Encapsulates information necessary for signaling containers.java.io.IOException - if signaling the container failspublic boolean reapContainer(ContainerReapContext ctx)
reapContainer in class ContainerExecutorctx - Encapsulates information necessary for reaping containers.public boolean isContainerAlive(ContainerLivenessContext ctx) throws java.io.IOException
ContainerExecutorisContainerAlive in class ContainerExecutorctx - Encapsulates information necessary for container liveness check.java.io.IOException - if there is a failure while checking the container
status@VisibleForTesting
public static boolean containerIsAlive(java.lang.String pid)
throws java.io.IOException
pid - String pidjava.io.IOException - if the command to test process liveliness failsprotected void killContainer(java.lang.String pid,
ContainerExecutor.Signal signal)
throws java.io.IOException
pid - the pid of the process [group] to signal.signal - signal to sendjava.io.IOException - if the command to kill the process failspublic void deleteAsUser(DeletionAsUserContext ctx) throws java.io.IOException, java.lang.InterruptedException
ContainerExecutordeleteAsUser in class ContainerExecutorctx - Encapsulates information necessary for deletion.java.io.IOException - if delete failsjava.lang.InterruptedException - if interrupted while waiting for the deletion
operation to completepublic void symLink(java.lang.String target,
java.lang.String symlink)
throws java.io.IOException
ContainerExecutorsymLink in class ContainerExecutortarget - The target for symlinksymlink - the symlink filejava.io.IOException - Error when creating symlinksprotected org.apache.hadoop.fs.Path getWorkingDir(java.util.List<java.lang.String> localDirs,
java.lang.String user,
java.lang.String appId)
throws java.io.IOException
localDirs - the target directories from which to selectuser - the user who owns the applicationappId - the application IDjava.io.IOException - if no application directories for the user can be
foundprotected void createDir(org.apache.hadoop.fs.Path dirPath,
org.apache.hadoop.fs.permission.FsPermission perms,
boolean createParent,
java.lang.String user)
throws java.io.IOException
lfs FileContext to create the target directory.dirPath - the target directoryperms - the target permissions for the target directorycreateParent - whether the parent directories should also be createduser - the user as whom the target directory should be created.
Used only on secure Windows hosts.java.io.IOException - if there's a failure performing a file operationWindowsSecureContainerExecutor@VisibleForTesting public java.lang.String getLogDirPermissions()
@VisibleForTesting public void clearLogDirPermissions()
public org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair execContainer(ContainerExecContext ctx) throws ContainerExecutionException
ContainerExecutorexecContainer in class ContainerExecutorctx - Encapsulates information necessary for exec containers.ContainerExecutionExceptionpublic void updateYarnSysFS(Context ctx, java.lang.String user, java.lang.String appId, java.lang.String spec) throws java.io.IOException
ContainerExecutorupdateYarnSysFS in class ContainerExecutorctx - ContainerRuntimeContextuser - Owner of applicationappId - YARN application IDspec - Service Specificationjava.io.IOException - if there is a failure while writing spec to diskpublic int reacquireContainer(ContainerReacquisitionContext ctx) throws java.io.IOException, java.lang.InterruptedException
ContainerExecutorreacquireContainer in class ContainerExecutorctx - encapsulates information necessary to reacquire containerjava.io.IOException - if there is a failure while reacquiring the containerjava.lang.InterruptedException - if interrupted while waiting to reacquire
the containerpublic void postComplete(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId - containerId of running container@VisibleForTesting public void setNumaResourceAllocator(NumaResourceAllocator numaResourceAllocator)
@VisibleForTesting public void setNumactl(java.lang.String numactl)
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.