ContainerLaunchContext (Apache Hadoop YARN API 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.api.records, class: ContainerLaunchContext

Package org.apache.hadoop.yarn.api.records

# Class ContainerLaunchContext

java.lang.Object
org.apache.hadoop.yarn.api.records.ContainerLaunchContext

@Public @Stable public abstract class ContainerLaunchContext extends Object
`ContainerLaunchContext` represents all of the information needed by the `NodeManager` to launch a container.

It includes details such as:

- `ContainerId` of the container.
- `Resource` allocated to the container.
- User to whom the container is allocated.
- Security tokens (if security is enabled).
- `LocalResource` necessary for running the container such as binaries, jar, shared-objects, side-files etc.
- Optional, application-specific binary service data.
- Environment variables for the launched process.
- Command to launch the container.
- Retry strategy when container exits with failure.

See Also:
  - `ContainerManagementProtocol.startContainers(org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ContainerLaunchContext()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract Map<ApplicationAccessType,String>`
  `getApplicationACLs()`
  Get the `ApplicationACL`s for the application.
  `abstract List<String>`
  `getCommands()`
  Get the list of commands for launching the container.
  `abstract ContainerRetryContext`
  `getContainerRetryContext()`
  Get the `ContainerRetryContext` to relaunch container.
  `abstract Map<String,String>`
  `getEnvironment()`
  Get environment variables for the container.
  `abstract Map<String,LocalResource>`
  `getLocalResources()`
  Get `LocalResource` required by the container.
  `abstract Map<String,ByteBuffer>`
  `getServiceData()`
  Get application-specific binary service data.
  `abstract ByteBuffer`
  `getTokens()`
  Get all the tokens needed by this container.
  `abstract ByteBuffer`
  `getTokensConf()`
  Get the configuration used by RM to renew tokens.
  `static ContainerLaunchContext`
  `newInstance(Map<String,LocalResource> localResources, Map<String,String> environment, List<String> commands, Map<String,ByteBuffer> serviceData, ByteBuffer tokens, Map<ApplicationAccessType,String> acls)`
  `static ContainerLaunchContext`
  `newInstance(Map<String,LocalResource> localResources, Map<String,String> environment, List<String> commands, Map<String,ByteBuffer> serviceData, ByteBuffer tokens, Map<ApplicationAccessType,String> acls, ContainerRetryContext containerRetryContext)`
  `abstract void`
  `setApplicationACLs(Map<ApplicationAccessType,String> acls)`
  Set the `ApplicationACL`s for the application.
  `abstract void`
  `setCommands(List<String> commands)`
  Add the list of commands for launching the container.
  `abstract void`
  `setContainerRetryContext(ContainerRetryContext containerRetryContext)`
  Set the `ContainerRetryContext` to relaunch container.
  `abstract void`
  `setEnvironment(Map<String,String> environment)`
  Add environment variables for the container.
  `abstract void`
  `setLocalResources(Map<String,LocalResource> localResources)`
  Set `LocalResource` required by the container.
  `abstract void`
  `setServiceData(Map<String,ByteBuffer> serviceData)`
  Set application-specific binary service data.
  `abstract void`
  `setTokens(ByteBuffer tokens)`
  Set security tokens needed by this container.
  `abstract void`
  `setTokensConf(ByteBuffer tokensConf)`
  Set the configuration used by RM to renew the tokens.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ContainerLaunchContext

    public ContainerLaunchContext()

- ## Method Details

  - ### newInstance

    @Public @Stable public static ContainerLaunchContext newInstance(Map<String,LocalResource> localResources, Map<String,String> environment, List<String> commands, Map<String,ByteBuffer> serviceData, ByteBuffer tokens, Map<ApplicationAccessType,String> acls)

  - ### newInstance

    @Public @Unstable public static ContainerLaunchContext newInstance(Map<String,LocalResource> localResources, Map<String,String> environment, List<String> commands, Map<String,ByteBuffer> serviceData, ByteBuffer tokens, Map<ApplicationAccessType,String> acls, ContainerRetryContext containerRetryContext)

  - ### getTokens

    @Public @Stable public abstract ByteBuffer getTokens()
    Get all the tokens needed by this container. It may include file-system tokens, ApplicationMaster related tokens if this container is an ApplicationMaster or framework level tokens needed by this container to communicate to various services in a secure manner.
    Returns:
      tokens needed by this container.

  - ### setTokens

    @Public @Stable public abstract void setTokens(ByteBuffer tokens)
    Set security tokens needed by this container.
    Parameters:
      `tokens` - security tokens

  - ### getTokensConf

    @Public @Unstable public abstract ByteBuffer getTokensConf()
    Get the configuration used by RM to renew tokens.
    Returns:
      The configuration used by RM to renew the tokens.

  - ### setTokensConf

    @Public @Unstable public abstract void setTokensConf(ByteBuffer tokensConf)
    Set the configuration used by RM to renew the tokens.
    Parameters:
      `tokensConf` - The configuration used by RM to renew the tokens

  - ### getLocalResources

    @Public @Stable public abstract Map<String,LocalResource> getLocalResources()
    Get `LocalResource` required by the container.
    Returns:
      all `LocalResource` required by the container

  - ### setLocalResources

    @Public @Stable public abstract void setLocalResources(Map<String,LocalResource> localResources)
    Set `LocalResource` required by the container. All pre-existing Map entries are cleared before adding the new Map
    Parameters:
      `localResources` - `LocalResource` required by the container

  - ### getServiceData

    @Public @Stable public abstract Map<String,ByteBuffer> getServiceData()

    Get application-specific binary service data. This is a map keyed by the name of each `AuxiliaryService` that is configured on a NodeManager and value correspond to the application specific data targeted for the keyed `AuxiliaryService`.

    This will be used to initialize this application on the specific `AuxiliaryService` running on the NodeManager by calling `AuxiliaryService.initializeApplication(ApplicationInitializationContext)`

    Returns:
      application-specific binary service data

  - ### setServiceData

    @Public @Stable public abstract void setServiceData(Map<String,ByteBuffer> serviceData)

    Set application-specific binary service data. This is a map keyed by the name of each `AuxiliaryService` that is configured on a NodeManager and value correspond to the application specific data targeted for the keyed `AuxiliaryService`. All pre-existing Map entries are preserved.

    Parameters:
      `serviceData` - application-specific binary service data

  - ### getEnvironment

    @Public @Stable public abstract Map<String,String> getEnvironment()
    Get environment variables for the container.
    Returns:
      environment variables for the container

  - ### setEnvironment

    @Public @Stable public abstract void setEnvironment(Map<String,String> environment)
    Add environment variables for the container. All pre-existing Map entries are cleared before adding the new Map
    Parameters:
      `environment` - environment variables for the container

  - ### getCommands

    @Public @Stable public abstract List<String> getCommands()
    Get the list of commands for launching the container.
    Returns:
      the list of commands for launching the container

  - ### setCommands

    @Public @Stable public abstract void setCommands(List<String> commands)
    Add the list of commands for launching the container. All pre-existing List entries are cleared before adding the new List
    Parameters:
      `commands` - the list of commands for launching the container

  - ### getApplicationACLs

    @Public @Stable public abstract Map<ApplicationAccessType,String> getApplicationACLs()
    Get the `ApplicationACL`s for the application.
    Returns:
      all the `ApplicationACL`s

  - ### setApplicationACLs

    @Public @Stable public abstract void setApplicationACLs(Map<ApplicationAccessType,String> acls)
    Set the `ApplicationACL`s for the application. All pre-existing Map entries are cleared before adding the new Map
    Parameters:
      `acls` - `ApplicationACL`s for the application

  - ### getContainerRetryContext

    @Public @Unstable public abstract ContainerRetryContext getContainerRetryContext()
    Get the `ContainerRetryContext` to relaunch container.
    Returns:
      `ContainerRetryContext` to relaunch container.

  - ### setContainerRetryContext

    @Public @Unstable public abstract void setContainerRetryContext(ContainerRetryContext containerRetryContext)
    Set the `ContainerRetryContext` to relaunch container.
    Parameters:
      `containerRetryContext` - `ContainerRetryContext` to relaunch container.