org.apache.hadoop.conf.ConfigurableDefaultContainerExecutor, LinuxContainerExecutorpublic abstract class ContainerExecutor
extends java.lang.Object
implements org.apache.hadoop.conf.Configurable
| Modifier and Type | Class | Description |
|---|---|---|
static class |
ContainerExecutor.DelayedProcessKiller |
This class will signal a target container after a specified delay.
|
static class |
ContainerExecutor.ExitCode |
The container exit code.
|
static class |
ContainerExecutor.Signal |
The constants for the signals.
|
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
DIRECTORY_CONTENTS |
The relative path to which debug information will be written.
|
static org.apache.hadoop.fs.permission.FsPermission |
TASK_LAUNCH_SCRIPT_PERMISSION |
The permissions to use when creating the launch script.
|
static java.lang.String |
TOKEN_FILE_NAME_FMT |
|
protected static java.lang.String |
WILDCARD |
| Constructor | Description |
|---|---|
ContainerExecutor() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
activateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId,
org.apache.hadoop.fs.Path pidFilePath) |
Mark the container as active.
|
void |
cleanupBeforeRelaunch(Container container) |
Perform any cleanup before the next launch of the container.
|
void |
deactivateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) |
Mark the container as inactive.
|
abstract void |
deleteAsUser(DeletionAsUserContext ctx) |
Delete specified directories as a given user.
|
abstract org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair |
execContainer(ContainerExecContext ctx) |
Perform interactive docker command into running container.
|
org.apache.hadoop.conf.Configuration |
getConf() |
|
java.lang.String |
getExposedPorts(Container container) |
|
java.lang.String[] |
getIpAndHost(Container container) |
|
static java.lang.String[] |
getLocalIpAndHost(Container container) |
|
java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> |
getLocalResources(Container container) |
|
protected java.lang.String |
getNMEnvVar(java.lang.String varname) |
|
protected org.apache.hadoop.fs.Path |
getPidFilePath(org.apache.hadoop.yarn.api.records.ContainerId containerId) |
Get the pidFile of the container.
|
java.lang.String |
getProcessId(org.apache.hadoop.yarn.api.records.ContainerId containerID) |
Get the process-identifier for the container.
|
protected java.lang.String[] |
getRunCommand(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config) |
Return a command line to execute the given command in the OS shell.
|
protected java.lang.String[] |
getRunCommand(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config,
org.apache.hadoop.yarn.api.records.Resource resource) |
Return a command line to execute the given command in the OS shell.
|
protected java.lang.String[] |
getRunCommandForOther(java.lang.String command,
org.apache.hadoop.conf.Configuration config) |
Return a command line to execute the given command in the OS shell.
|
protected java.lang.String[] |
getRunCommandForWindows(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config,
org.apache.hadoop.yarn.api.records.Resource resource) |
Return a command line to execute the given command in the OS shell.
|
abstract void |
init(Context nmContext) |
Run the executor initialization steps.
|
protected boolean |
isContainerActive(org.apache.hadoop.yarn.api.records.ContainerId containerId) |
Return whether the container is still active.
|
abstract boolean |
isContainerAlive(ContainerLivenessContext ctx) |
Check if a container is alive.
|
abstract int |
launchContainer(ContainerStartContext ctx) |
Launch the container on the node.
|
org.apache.hadoop.fs.Path |
localizeClasspathJar(org.apache.hadoop.fs.Path jarPath,
org.apache.hadoop.fs.Path target,
java.lang.String owner) |
This function localizes the JAR file on-demand.
|
protected void |
logOutput(java.lang.String output) |
Log each line of the output string as INFO level log messages.
|
void |
pauseContainer(Container container) |
Pause the container.
|
void |
prepareContainer(ContainerPrepareContext ctx) |
Prepare the container prior to the launch environment being written.
|
int |
reacquireContainer(ContainerReacquisitionContext ctx) |
Recover an already existing container.
|
protected java.io.File[] |
readDirAsUser(java.lang.String user,
org.apache.hadoop.fs.Path dir) |
Return the files in the target directory.
|
abstract boolean |
reapContainer(ContainerReapContext ctx) |
Perform the steps necessary to reap the container.
|
abstract int |
relaunchContainer(ContainerStartContext ctx) |
Relaunch the container on the node.
|
void |
resumeContainer(Container container) |
Resume the container from pause state.
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
|
abstract boolean |
signalContainer(ContainerSignalContext ctx) |
Signal container with the specified signal.
|
void |
start() |
|
abstract void |
startLocalizer(LocalizerStartContext ctx) |
Prepare the environment for containers in this application to execute.
|
void |
stop() |
|
abstract void |
symLink(java.lang.String target,
java.lang.String symlink) |
Create a symlink file which points to the target.
|
abstract void |
updateYarnSysFS(Context ctx,
java.lang.String user,
java.lang.String appId,
java.lang.String spec) |
Update cluster information inside container.
|
void |
writeLaunchEnv(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String> environment,
java.util.Map<org.apache.hadoop.fs.Path,java.util.List<java.lang.String>> resources,
java.util.List<java.lang.String> command,
org.apache.hadoop.fs.Path logDir,
java.lang.String user,
java.lang.String outFilename,
java.util.LinkedHashSet<java.lang.String> nmVars) |
This method writes out the launch environment of a container to a specified
path.
|
void |
writeLaunchEnv(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String> environment,
java.util.Map<org.apache.hadoop.fs.Path,java.util.List<java.lang.String>> resources,
java.util.List<java.lang.String> command,
org.apache.hadoop.fs.Path logDir,
java.lang.String user,
java.util.LinkedHashSet<java.lang.String> nmVars) |
This method writes out the launch environment of a container to the
default container launch script.
|
protected static final java.lang.String WILDCARD
public static final java.lang.String TOKEN_FILE_NAME_FMT
public static final org.apache.hadoop.fs.permission.FsPermission TASK_LAUNCH_SCRIPT_PERMISSION
public static final java.lang.String DIRECTORY_CONTENTS
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf in interface org.apache.hadoop.conf.Configurablepublic org.apache.hadoop.conf.Configuration getConf()
getConf in interface org.apache.hadoop.conf.Configurablepublic abstract void init(Context nmContext) throws java.io.IOException
nmContext - Context of NMjava.io.IOException - if initialization failspublic void start()
public void stop()
public org.apache.hadoop.fs.Path localizeClasspathJar(org.apache.hadoop.fs.Path jarPath,
org.apache.hadoop.fs.Path target,
java.lang.String owner)
throws java.io.IOException
jarPath - the path to the JAR to localizetarget - the directory where the JAR file should be localizedowner - the name of the user who should own the localized filejava.io.IOException - if localization failspublic abstract void startLocalizer(LocalizerStartContext ctx) throws java.io.IOException, java.lang.InterruptedException
For $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
ctx - 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 NMpublic void prepareContainer(ContainerPrepareContext ctx) throws java.io.IOException
ctx - Encapsulates information necessary for launching containers.java.io.IOException - if errors occur during container preparationpublic abstract int launchContainer(ContainerStartContext ctx) throws java.io.IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
ctx - Encapsulates information necessary for launching containers.java.io.IOException - if the container launch failsorg.apache.hadoop.yarn.exceptions.ConfigurationException - if config error was foundpublic abstract int relaunchContainer(ContainerStartContext ctx) throws java.io.IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
ctx - Encapsulates information necessary for relaunching containers.java.io.IOException - if the container relaunch failsorg.apache.hadoop.yarn.exceptions.ConfigurationException - if config error was foundpublic abstract boolean signalContainer(ContainerSignalContext ctx) throws java.io.IOException
ctx - Encapsulates information necessary for signaling containers.java.io.IOException - if signaling the container failspublic abstract boolean reapContainer(ContainerReapContext ctx) throws java.io.IOException
ctx - Encapsulates information necessary for reaping containers.java.io.IOException - if reaping the container fails.public abstract org.apache.hadoop.hdfs.protocol.datatransfer.IOStreamPair execContainer(ContainerExecContext ctx) throws ContainerExecutionException
ctx - Encapsulates information necessary for exec containers.ContainerExecutionException - if container exec fails.public abstract void deleteAsUser(DeletionAsUserContext ctx) throws java.io.IOException, java.lang.InterruptedException
ctx - Encapsulates information necessary for deletion.java.io.IOException - if delete failsjava.lang.InterruptedException - if interrupted while waiting for the deletion
operation to completepublic abstract void symLink(java.lang.String target,
java.lang.String symlink)
throws java.io.IOException
target - The target for symlinksymlink - the symlink filejava.io.IOException - Error when creating symlinkspublic abstract boolean isContainerAlive(ContainerLivenessContext ctx) throws java.io.IOException
ctx - Encapsulates information necessary for container liveness check.java.io.IOException - if there is a failure while checking the container
statuspublic java.util.Map<java.lang.String,org.apache.hadoop.yarn.api.records.LocalResource> getLocalResources(Container container) throws java.io.IOException
java.io.IOExceptionpublic abstract void updateYarnSysFS(Context ctx, java.lang.String user, java.lang.String appId, java.lang.String spec) throws java.io.IOException
ctx - 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
ctx - 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 writeLaunchEnv(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String> environment,
java.util.Map<org.apache.hadoop.fs.Path,java.util.List<java.lang.String>> resources,
java.util.List<java.lang.String> command,
org.apache.hadoop.fs.Path logDir,
java.lang.String user,
java.util.LinkedHashSet<java.lang.String> nmVars)
throws java.io.IOException
ContainerLaunch.CONTAINER_SCRIPT.out - the output stream to which the environment is written (usually
a script file which will be executed by the Launcher)environment - the environment variables and their valuesresources - the resources which have been localized for this
container. Symlinks will be created to these localized resourcescommand - the command that will be runlogDir - the log dir to which to copy debugging informationuser - the username of the job ownernmVars - the set of environment vars that are explicitly set by NMjava.io.IOException - if any errors happened writing to the OutputStream,
while creating symlinks@VisibleForTesting
public void writeLaunchEnv(java.io.OutputStream out,
java.util.Map<java.lang.String,java.lang.String> environment,
java.util.Map<org.apache.hadoop.fs.Path,java.util.List<java.lang.String>> resources,
java.util.List<java.lang.String> command,
org.apache.hadoop.fs.Path logDir,
java.lang.String user,
java.lang.String outFilename,
java.util.LinkedHashSet<java.lang.String> nmVars)
throws java.io.IOException
out - the output stream to which the environment is written (usually
a script file which will be executed by the Launcher)environment - the environment variables and their valuesresources - the resources which have been localized for this
container. Symlinks will be created to these localized resourcescommand - the command that will be runlogDir - the log dir to which to copy debugging informationuser - the username of the job owneroutFilename - the path to which to write the launch environmentnmVars - the set of environment vars that are explicitly set by NMjava.io.IOException - if any errors happened writing to the OutputStream,
while creating symlinksprotected java.io.File[] readDirAsUser(java.lang.String user,
org.apache.hadoop.fs.Path dir)
user - the user as whom to access the target directorydir - the target directoryprotected void logOutput(java.lang.String output)
output - the output string to logprotected org.apache.hadoop.fs.Path getPidFilePath(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId - the container IDprotected java.lang.String[] getRunCommand(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config)
command - the command to executegroupId - the job owner's GIDuserName - the job owner's usernamepidFile - the path to the container's PID fileconfig - the configurationprotected java.lang.String[] getRunCommand(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config,
org.apache.hadoop.yarn.api.records.Resource resource)
command - the command to executegroupId - the job owner's GID for Windows. On other operating systems
it is ignored.userName - the job owner's username for Windows. On other operating
systems it is ignored.pidFile - the path to the container's PID file on Windows. On other
operating systems it is ignored.config - the configurationresource - on Windows this parameter controls memory and CPU limits.
If null, no limits are set. On other operating systems it is ignored.protected java.lang.String[] getRunCommandForWindows(java.lang.String command,
java.lang.String groupId,
java.lang.String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration config,
org.apache.hadoop.yarn.api.records.Resource resource)
command - the command to executegroupId - the job owner's GIDuserName - the job owner's usernamepidFile - the path to the container's PID fileconfig - the configurationresource - this parameter controls memory and CPU limits.
If null, no limits are set.protected java.lang.String[] getRunCommandForOther(java.lang.String command,
org.apache.hadoop.conf.Configuration config)
command - the command to executeconfig - the configurationprotected boolean isContainerActive(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId - the target container's ID@VisibleForTesting protected java.lang.String getNMEnvVar(java.lang.String varname)
public void activateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId,
org.apache.hadoop.fs.Path pidFilePath)
containerId - the container IDpidFilePath - the path where the executor should write the PID
of the launched processpublic java.lang.String[] getIpAndHost(Container container) throws ContainerExecutionException
ContainerExecutionExceptionpublic static java.lang.String[] getLocalIpAndHost(Container container)
public void deactivateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId - the container IDpublic void pauseContainer(Container container)
container - the Containerpublic void resumeContainer(Container container)
container - the Containerpublic void cleanupBeforeRelaunch(Container container) throws java.io.IOException, java.lang.InterruptedException
container - containerjava.io.IOExceptionjava.lang.InterruptedExceptionpublic java.lang.String getProcessId(org.apache.hadoop.yarn.api.records.ContainerId containerID)
containerID - the container IDpublic java.lang.String getExposedPorts(Container container) throws ContainerExecutionException
ContainerExecutionExceptionCopyright © 2008–2025 Apache Software Foundation. All rights reserved.