java.lang.Object
org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch
All Implemented Interfaces:
Callable<Integer>
Direct Known Subclasses:
ContainerRelaunch, RecoveredContainerLaunch, RecoverPausedContainerLaunch

public class ContainerLaunch extends Object implements Callable<Integer>
  • Field Details

  • Constructor Details

  • Method Details

    • expandEnvironment

      @VisibleForTesting public static String expandEnvironment(String var, org.apache.hadoop.fs.Path containerLogDir)
    • call

      public Integer call()
      Specified by:
      call in interface Callable<Integer>
    • validateContainerState

      protected boolean validateContainerState()
    • getContainerLogDirs

      protected List<String> getContainerLogDirs(List<String> logDirs)
    • getContainerLocalDirs

      protected List<String> getContainerLocalDirs(List<String> localDirs)
    • getUserLocalDirs

      protected List<String> getUserLocalDirs(List<String> localDirs)
    • getNMFilecacheDirs

      protected List<String> getNMFilecacheDirs(List<String> localDirs)
    • getUserFilecacheDirs

      protected List<String> getUserFilecacheDirs(List<String> localDirs)
    • getApplicationLocalDirs

      protected List<String> getApplicationLocalDirs(List<String> localDirs, String appIdStr)
    • getLocalizedResources

      protected Map<org.apache.hadoop.fs.Path,List<String>> getLocalizedResources() throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • launchContainer

      protected int launchContainer(ContainerStartContext ctx) throws IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.ConfigurationException
    • relaunchContainer

      protected int relaunchContainer(ContainerStartContext ctx) throws IOException, org.apache.hadoop.yarn.exceptions.ConfigurationException
      Throws:
      IOException
      org.apache.hadoop.yarn.exceptions.ConfigurationException
    • prepareForLaunch

      protected int prepareForLaunch(ContainerStartContext ctx) throws IOException
      Throws:
      IOException
    • setContainerCompletedStatus

      protected void setContainerCompletedStatus(int exitCode)
    • handleContainerExitCode

      protected void handleContainerExitCode(int exitCode, org.apache.hadoop.fs.Path containerLogDir)
    • handleContainerExitWithFailure

      protected void handleContainerExitWithFailure(org.apache.hadoop.yarn.api.records.ContainerId containerID, int ret, org.apache.hadoop.fs.Path containerLogDir, StringBuilder diagnosticInfo)
      Tries to tail and fetch TAIL_SIZE_IN_BYTES of data from the error log. ErrorLog filename is not fixed and depends upon app, hence file name pattern is used.
      Parameters:
      containerID -
      ret -
      containerLogDir -
      diagnosticInfo -
    • getPidFileSubpath

      protected String getPidFileSubpath(String appIdStr, String containerIdStr)
    • signalContainer

      public void signalContainer(org.apache.hadoop.yarn.api.records.SignalContainerCommand command) throws IOException
      Send a signal to the container.
      Throws:
      IOException
    • translateCommandToSignal

      @VisibleForTesting public static ContainerExecutor.Signal translateCommandToSignal(org.apache.hadoop.yarn.api.records.SignalContainerCommand command)
    • pauseContainer

      public void pauseContainer() throws IOException
      Pause the container. Cancels the launch if the container isn't launched yet. Otherwise asks the executor to pause the container.
      Throws:
      IOException - in case of errors.
    • resumeContainer

      public void resumeContainer() throws IOException
      Resume the container. Cancels the launch if the container isn't launched yet. Otherwise asks the executor to pause the container.
      Throws:
      IOException - in case of error.
    • getRelativeContainerLogDir

      public static String getRelativeContainerLogDir(String appIdStr, String containerIdStr)
    • getContainerPrivateDir

      protected String getContainerPrivateDir(String appIdStr, String containerIdStr)
    • sanitizeEnv

      public void sanitizeEnv(Map<String,String> environment, org.apache.hadoop.fs.Path pwd, List<org.apache.hadoop.fs.Path> appDirs, List<String> userLocalDirs, List<String> containerLogDirs, Map<org.apache.hadoop.fs.Path,List<String>> resources, org.apache.hadoop.fs.Path nmPrivateClasspathJarDir, Set<String> nmVars) throws IOException
      Throws:
      IOException
    • addConfigsToEnv

      public void addConfigsToEnv(Map<String,String> environment)
      There are some configurations (such as "yarn.nodemanager.admin-env") whose values need to be added to the environment variables.
      Parameters:
      environment - The environment variables map to add the configuration values to.
    • getExitCodeFile

      public static String getExitCodeFile(String pidFile)
    • getContainerWorkDir

      protected org.apache.hadoop.fs.Path getContainerWorkDir() throws IOException
      Throws:
      IOException
    • cleanupContainerFiles

      protected void cleanupContainerFiles(org.apache.hadoop.fs.Path containerWorkDir)
      Clean up container's files for container relaunch or cleanup.