public abstract class ContainerExecutor extends Object implements org.apache.hadoop.conf.Configurable
Modifier and Type | Class and Description |
---|---|
static class |
ContainerExecutor.DelayedProcessKiller |
static class |
ContainerExecutor.ExitCode |
static class |
ContainerExecutor.Signal
The constants for the signals.
|
Modifier and Type | Field and Description |
---|---|
static String |
DIRECTORY_CONTENTS |
static org.apache.hadoop.fs.permission.FsPermission |
TASK_LAUNCH_SCRIPT_PERMISSION |
Constructor and Description |
---|
ContainerExecutor() |
Modifier and Type | Method and Description |
---|---|
void |
activateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId,
org.apache.hadoop.fs.Path pidFilePath)
Mark the container as active
|
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.
|
org.apache.hadoop.conf.Configuration |
getConf() |
protected String |
getNMEnvVar(String varname) |
protected org.apache.hadoop.fs.Path |
getPidFilePath(org.apache.hadoop.yarn.api.records.ContainerId containerId)
Get the pidFile of the container.
|
String |
getProcessId(org.apache.hadoop.yarn.api.records.ContainerId containerID)
Get the process-identifier for the container
|
protected String[] |
getRunCommand(String command,
String groupId,
String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration conf) |
protected String[] |
getRunCommand(String command,
String groupId,
String userName,
org.apache.hadoop.fs.Path pidFile,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.yarn.api.records.Resource resource)
Return a command to execute the given command in OS shell.
|
abstract void |
init()
Run the executor initialization steps.
|
protected boolean |
isContainerActive(org.apache.hadoop.yarn.api.records.ContainerId containerId)
Is the container 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 classPathJar,
org.apache.hadoop.fs.Path pwd,
String owner)
On Windows the ContainerLaunch creates a temporary special jar manifest of
other jars to workaround the CLASSPATH length.
|
protected void |
logOutput(String output) |
int |
reacquireContainer(ContainerReacquisitionContext ctx)
Recover an already existing container.
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
abstract boolean |
signalContainer(ContainerSignalContext ctx)
Signal container with the specified signal.
|
abstract void |
startLocalizer(LocalizerStartContext ctx)
Prepare the environment for containers in this application to execute.
|
protected void |
updateEnvForWhitelistVars(Map<String,String> env)
Propagate variables from the nodemanager's environment into the
container's environment if unspecified by the container.
|
void |
writeLaunchEnv(OutputStream out,
Map<String,String> environment,
Map<org.apache.hadoop.fs.Path,List<String>> resources,
List<String> command,
org.apache.hadoop.fs.Path logDir)
This method writes out the launch environment of a container.
|
void |
writeLaunchEnv(OutputStream out,
Map<String,String> environment,
Map<org.apache.hadoop.fs.Path,List<String>> resources,
List<String> command,
org.apache.hadoop.fs.Path logDir,
String outFilename) |
public static final org.apache.hadoop.fs.permission.FsPermission TASK_LAUNCH_SCRIPT_PERMISSION
public static final String DIRECTORY_CONTENTS
public void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
public org.apache.hadoop.conf.Configuration getConf()
getConf
in interface org.apache.hadoop.conf.Configurable
public abstract void init() throws IOException
IOException
public org.apache.hadoop.fs.Path localizeClasspathJar(org.apache.hadoop.fs.Path classPathJar, org.apache.hadoop.fs.Path pwd, String owner) throws IOException
classPathJar
- owner
- IOException
public abstract void startLocalizer(LocalizerStartContext ctx) throws IOException, 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.IOException
- For most application init failuresInterruptedException
- If application init thread is halted by NMpublic abstract int launchContainer(ContainerStartContext ctx) throws IOException
ctx
- Encapsulates information necessary for launching containers.IOException
public abstract boolean signalContainer(ContainerSignalContext ctx) throws IOException
ctx
- Encapsulates information necessary for signaling containers.IOException
public abstract void deleteAsUser(DeletionAsUserContext ctx) throws IOException, InterruptedException
ctx
- Encapsulates information necessary for deletion.IOException
InterruptedException
public abstract boolean isContainerAlive(ContainerLivenessContext ctx) throws IOException
ctx
- Encapsulates information necessary for container liveness check.IOException
public int reacquireContainer(ContainerReacquisitionContext ctx) throws IOException, InterruptedException
ctx
- encapsulates information necessary to reacquire containerIOException
InterruptedException
public void writeLaunchEnv(OutputStream out, Map<String,String> environment, Map<org.apache.hadoop.fs.Path,List<String>> resources, List<String> command, org.apache.hadoop.fs.Path logDir) throws 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 run.logDir
- The log dir to copy debugging information toIOException
- if any errors happened writing to the OutputStream,
while creating symlinkspublic void writeLaunchEnv(OutputStream out, Map<String,String> environment, Map<org.apache.hadoop.fs.Path,List<String>> resources, List<String> command, org.apache.hadoop.fs.Path logDir, String outFilename) throws IOException
IOException
protected void logOutput(String output)
protected org.apache.hadoop.fs.Path getPidFilePath(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId
- protected String[] getRunCommand(String command, String groupId, String userName, org.apache.hadoop.fs.Path pidFile, org.apache.hadoop.conf.Configuration conf)
protected String[] getRunCommand(String command, String groupId, String userName, org.apache.hadoop.fs.Path pidFile, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.yarn.api.records.Resource resource)
protected boolean isContainerActive(org.apache.hadoop.yarn.api.records.ContainerId containerId)
containerId
- protected void updateEnvForWhitelistVars(Map<String,String> env)
env
- the environment to updateYarnConfiguration.NM_ENV_WHITELIST
public void activateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId, org.apache.hadoop.fs.Path pidFilePath)
containerId
- the ContainerIdpidFilePath
- Path where the executor should write the pid of the launched
processpublic void deactivateContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId)
public String getProcessId(org.apache.hadoop.yarn.api.records.ContainerId containerID)
containerID
- Copyright © 2018 Apache Software Foundation. All Rights Reserved.