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

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

# Class ApplicationSubmissionContext

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

@Public @Stable public abstract class ApplicationSubmissionContext extends Object
`ApplicationSubmissionContext` represents all of the information needed by the `ResourceManager` to launch the `ApplicationMaster` for an application.

It includes details such as:

- `ApplicationId` of the application.
- Application user.
- Application name.
- `Priority` of the application.
- `ContainerLaunchContext` of the container in which the `ApplicationMaster` is executed.
- maxAppAttempts. The maximum number of application attempts. It should be no larger than the global number of max attempts in the YARN configuration.
- attemptFailuresValidityInterval. The default value is -1. when attemptFailuresValidityInterval in milliseconds is set to > 0, the failure number will no take failures which happen out of the validityInterval into failure count. If failure count reaches to maxAppAttempts, the application will be failed.
- Optional, application-specific `LogAggregationContext`

See Also:
  - `ContainerLaunchContext`
  - `ApplicationClientProtocol.submitApplication(org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ApplicationSubmissionContext()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract ResourceRequest`
  `getAMContainerResourceRequest()`
  Deprecated.
  See `getAMContainerResourceRequests()`
  `abstract List<ResourceRequest>`
  `getAMContainerResourceRequests()`
  Get the ResourceRequests of the AM container.
  `abstract ContainerLaunchContext`
  `getAMContainerSpec()`
  Get the `ContainerLaunchContext` to describe the `Container` with which the `ApplicationMaster` is launched.
  `abstract ApplicationId`
  `getApplicationId()`
  Get the `ApplicationId` of the submitted application.
  `abstract String`
  `getApplicationName()`
  Get the application name.
  `abstract Map<String,String>`
  `getApplicationSchedulingPropertiesMap()`
  Get application scheduling environment variables stored as a key value pair map for application.
  `abstract Set<String>`
  `getApplicationTags()`
  Get tags for the application
  `abstract Map<ApplicationTimeoutType,Long>`
  `getApplicationTimeouts()`
  Get `ApplicationTimeouts` of the application.
  `abstract String`
  `getApplicationType()`
  Get the application type
  `abstract long`
  `getAttemptFailuresValidityInterval()`
  Get the attemptFailuresValidityInterval in milliseconds for the application.
  `abstract boolean`
  `getCancelTokensWhenComplete()`
  `abstract boolean`
  `getKeepContainersAcrossApplicationAttempts()`
  Get the flag which indicates whether to keep containers across application attempts or not.
  `abstract LogAggregationContext`
  `getLogAggregationContext()`
  Get `LogAggregationContext` of the application
  `abstract int`
  `getMaxAppAttempts()`
  `abstract String`
  `getNodeLabelExpression()`
  Get node-label-expression for this app.
  `abstract Priority`
  `getPriority()`
  Get the `Priority` of the application.
  `abstract String`
  `getQueue()`
  Get the queue to which the application is being submitted.
  `abstract ReservationId`
  `getReservationID()`
  Get the reservation id, that corresponds to a valid resource allocation in the scheduler (between start and end time of the corresponding reservation)
  `abstract Resource`
  `getResource()`
  Get the resource required by the `ApplicationMaster` for this application.
  `abstract boolean`
  `getUnmanagedAM()`
  Get if the RM should manage the execution of the AM.
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, String applicationType, boolean keepContainers, String appLabelExpression, ResourceRequest resourceRequest)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, long attemptFailuresValidityInterval)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, String appLabelExpression, String amContainerLabelExpression)`
  `static ApplicationSubmissionContext`
  `newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, LogAggregationContext logAggregationContext)`
  `abstract void`
  `setAMContainerResourceRequest(ResourceRequest request)`
  Deprecated.
  See `setAMContainerResourceRequests(List)`
  `abstract void`
  `setAMContainerResourceRequests(List<ResourceRequest> requests)`
  Set ResourceRequests of the AM container.
  `abstract void`
  `setAMContainerSpec(ContainerLaunchContext amContainer)`
  Set the `ContainerLaunchContext` to describe the `Container` with which the `ApplicationMaster` is launched.
  `abstract void`
  `setApplicationId(ApplicationId applicationId)`
  Set the `ApplicationId` of the submitted application.
  `abstract void`
  `setApplicationName(String applicationName)`
  Set the application name.
  `abstract void`
  `setApplicationSchedulingPropertiesMap(Map<String,String> schedulingEnvMap)`
  Set the scheduling envs for the application.
  `abstract void`
  `setApplicationTags(Set<String> tags)`
  Set tags for the application.
  `abstract void`
  `setApplicationTimeouts(Map<ApplicationTimeoutType,Long> applicationTimeouts)`
  Set the `ApplicationTimeouts` for the application in seconds.
  `abstract void`
  `setApplicationType(String applicationType)`
  Set the application type
  `abstract void`
  `setAttemptFailuresValidityInterval(long attemptFailuresValidityInterval)`
  Set the attemptFailuresValidityInterval in milliseconds for the application.
  `abstract void`
  `setCancelTokensWhenComplete(boolean cancel)`
  Set to false if tokens should not be canceled when the app finished else false.
  `abstract void`
  `setKeepContainersAcrossApplicationAttempts(boolean keepContainers)`
  Set the flag which indicates whether to keep containers across application attempts.
  `abstract void`
  `setLogAggregationContext(LogAggregationContext logAggregationContext)`
  Set `LogAggregationContext` for the application
  `abstract void`
  `setMaxAppAttempts(int maxAppAttempts)`
  Set the number of max attempts of the application to be submitted.
  `abstract void`
  `setNodeLabelExpression(String nodeLabelExpression)`
  Set node-label-expression for this app
  `abstract void`
  `setPriority(Priority priority)`
  Set the `Priority` of the application.
  `abstract void`
  `setQueue(String queue)`
  Set the queue to which the application is being submitted
  `abstract void`
  `setReservationID(ReservationId reservationID)`
  Set the reservation id, that correspond to a valid resource allocation in the scheduler (between start and end time of the corresponding reservation)
  `abstract void`
  `setResource(Resource resource)`
  Set the resource required by the `ApplicationMaster` for this application.
  `abstract void`
  `setUnmanagedAM(boolean value)`

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

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

- ## Constructor Details

  - ### ApplicationSubmissionContext

    public ApplicationSubmissionContext()

- ## Method Details

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, String appLabelExpression, String amContainerLabelExpression)

  - ### newInstance

    public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers)

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType)

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource)

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, String applicationType, boolean keepContainers, String appLabelExpression, ResourceRequest resourceRequest)

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, long attemptFailuresValidityInterval)

  - ### newInstance

    @Public @Stable public static ApplicationSubmissionContext newInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers, LogAggregationContext logAggregationContext)

  - ### getApplicationId

    @Public @Stable public abstract ApplicationId getApplicationId()
    Get the `ApplicationId` of the submitted application.
    Returns:
      `ApplicationId` of the submitted application

  - ### setApplicationId

    @Public @Stable public abstract void setApplicationId(ApplicationId applicationId)
    Set the `ApplicationId` of the submitted application.
    Parameters:
      `applicationId` - `ApplicationId` of the submitted application

  - ### getApplicationName

    @Public @Stable public abstract String getApplicationName()
    Get the application name.
    Returns:
      application name

  - ### setApplicationName

    @Public @Stable public abstract void setApplicationName(String applicationName)
    Set the application name.
    Parameters:
      `applicationName` - application name

  - ### getQueue

    @Public @Stable public abstract String getQueue()
    Get the queue to which the application is being submitted.
    Returns:
      queue to which the application is being submitted

  - ### setQueue

    @Public @Stable public abstract void setQueue(String queue)
    Set the queue to which the application is being submitted
    Parameters:
      `queue` - queue to which the application is being submitted

  - ### getPriority

    @Public @Stable public abstract Priority getPriority()
    Get the `Priority` of the application.
    Returns:
      `Priority` of the application

  - ### setPriority

    @Private @Unstable public abstract void setPriority(Priority priority)
    Set the `Priority` of the application.
    Parameters:
      `priority` - `Priority` of the application

  - ### getAMContainerSpec

    @Public @Stable public abstract ContainerLaunchContext getAMContainerSpec()
    Get the `ContainerLaunchContext` to describe the `Container` with which the `ApplicationMaster` is launched.
    Returns:
      `ContainerLaunchContext` for the `ApplicationMaster` container

  - ### setAMContainerSpec

    @Public @Stable public abstract void setAMContainerSpec(ContainerLaunchContext amContainer)
    Set the `ContainerLaunchContext` to describe the `Container` with which the `ApplicationMaster` is launched.
    Parameters:
      `amContainer` - `ContainerLaunchContext` for the `ApplicationMaster` container

  - ### getUnmanagedAM

    @Public @Stable public abstract boolean getUnmanagedAM()
    Get if the RM should manage the execution of the AM. If true, then the RM will not allocate a container for the AM and start it. It will expect the AM to be launched and connect to the RM within the AM liveliness period and fail the app otherwise. The client should launch the AM only after the RM has ACCEPTED the application and changed the `YarnApplicationState`. Such apps will not be retried by the RM on app attempt failure. The default value is false.
    Returns:
      true if the AM is not managed by the RM

  - ### setUnmanagedAM

    @Public @Stable public abstract void setUnmanagedAM(boolean value)
    Parameters:
      `value` - true if RM should not manage the AM

  - ### getCancelTokensWhenComplete

    @LimitedPrivate("mapreduce") @Unstable public abstract boolean getCancelTokensWhenComplete()
    Returns:
      true if tokens should be canceled when the app completes.

  - ### setCancelTokensWhenComplete

    @LimitedPrivate("mapreduce") @Unstable public abstract void setCancelTokensWhenComplete(boolean cancel)
    Set to false if tokens should not be canceled when the app finished else false. WARNING: this is not recommended unless you want your single job tokens to be reused by others jobs.
    Parameters:
      `cancel` - true if tokens should be canceled when the app finishes.

  - ### getMaxAppAttempts

    @Public @Stable public abstract int getMaxAppAttempts()
    Returns:
      the number of max attempts of the application to be submitted

  - ### setMaxAppAttempts

    @Public @Stable public abstract void setMaxAppAttempts(int maxAppAttempts)
    Set the number of max attempts of the application to be submitted. WARNING: it should be no larger than the global number of max attempts in the Yarn configuration.
    Parameters:
      `maxAppAttempts` - the number of max attempts of the application to be submitted.

  - ### getResource

    @Public public abstract Resource getResource()
    Get the resource required by the `ApplicationMaster` for this application. Please note this will be DEPRECATED, use getResource in getAMContainerResourceRequest instead.
    Returns:
      the resource required by the `ApplicationMaster` for this application.

  - ### setResource

    @Public public abstract void setResource(Resource resource)
    Set the resource required by the `ApplicationMaster` for this application.
    Parameters:
      `resource` - the resource required by the `ApplicationMaster` for this application.

  - ### getApplicationType

    @Public @Stable public abstract String getApplicationType()
    Get the application type
    Returns:
      the application type

  - ### setApplicationType

    @Public @Stable public abstract void setApplicationType(String applicationType)
    Set the application type
    Parameters:
      `applicationType` - the application type

  - ### getKeepContainersAcrossApplicationAttempts

    @Public @Stable public abstract boolean getKeepContainersAcrossApplicationAttempts()
    Get the flag which indicates whether to keep containers across application attempts or not.
    Returns:
      the flag which indicates whether to keep containers across application attempts or not.

  - ### setKeepContainersAcrossApplicationAttempts

    @Public @Stable public abstract void setKeepContainersAcrossApplicationAttempts(boolean keepContainers)
    Set the flag which indicates whether to keep containers across application attempts.

    For managed AM, if the flag is true, running containers will not be killed when application attempt fails and these containers will be retrieved by the new application attempt on registration via `ApplicationMasterProtocol.registerApplicationMaster(RegisterApplicationMasterRequest)`.

    For unmanaged AM, if the flag is true, RM allows re-register and returns the running containers in the same attempt back to the UAM for HA.

    Parameters:
      `keepContainers` - the flag which indicates whether to keep containers across application attempts.

  - ### getApplicationTags

    @Public @Stable public abstract Set<String> getApplicationTags()
    Get tags for the application
    Returns:
      the application tags

  - ### setApplicationTags

    @Public @Stable public abstract void setApplicationTags(Set<String> tags)
    Set tags for the application. A maximum of `YarnConfiguration.RM_APPLICATION_MAX_TAGS` are allowed per application. Each tag can be at most `YarnConfiguration.RM_APPLICATION_MAX_TAG_LENGTH` characters, and can contain only ASCII characters.
    Parameters:
      `tags` - tags to set

  - ### getNodeLabelExpression

    @Public @Evolving public abstract String getNodeLabelExpression()
    Get node-label-expression for this app. If this is set, all containers of this application without setting node-label-expression in ResurceRequest will get allocated resources on only those nodes that satisfy this node-label-expression. If different node-label-expression of this app and ResourceRequest are set at the same time, the one set in ResourceRequest will be used when allocating container
    Returns:
      node-label-expression for this app

  - ### setNodeLabelExpression

    @Public @Evolving public abstract void setNodeLabelExpression(String nodeLabelExpression)
    Set node-label-expression for this app
    Parameters:
      `nodeLabelExpression` - node-label-expression of this app

  - ### getAMContainerResourceRequest

    @Public @Evolving @Deprecated public abstract ResourceRequest getAMContainerResourceRequest()
    Deprecated.
    See `getAMContainerResourceRequests()`
    Get the ResourceRequest of the AM container. If this is not null, scheduler will use this to acquire resource for AM container. If this is null, scheduler will assemble a ResourceRequest by using getResource and getPriority of ApplicationSubmissionContext. Number of containers and Priority will be ignored.
    Returns:
      ResourceRequest of the AM container

  - ### setAMContainerResourceRequest

    @Public @Evolving @Deprecated public abstract void setAMContainerResourceRequest(ResourceRequest request)
    Deprecated.
    See `setAMContainerResourceRequests(List)`
    Set ResourceRequest of the AM container
    Parameters:
      `request` - of the AM container

  - ### getAMContainerResourceRequests

    @Public @Evolving public abstract List<ResourceRequest> getAMContainerResourceRequests()
    Get the ResourceRequests of the AM container. If this is not null, scheduler will use this to acquire resource for AM container. If this is null, scheduler will use the ResourceRequest as determined by getAMContainerResourceRequest and its behavior. Number of containers and Priority will be ignored.
    Returns:
      List of ResourceRequests of the AM container

  - ### setAMContainerResourceRequests

    @Public @Evolving public abstract void setAMContainerResourceRequests(List<ResourceRequest> requests)
    Set ResourceRequests of the AM container.
    Parameters:
      `requests` - of the AM container

  - ### getAttemptFailuresValidityInterval

    @Public @Stable public abstract long getAttemptFailuresValidityInterval()
    Get the attemptFailuresValidityInterval in milliseconds for the application.
    Returns:
      the attemptFailuresValidityInterval

  - ### setAttemptFailuresValidityInterval

    @Public @Stable public abstract void setAttemptFailuresValidityInterval(long attemptFailuresValidityInterval)
    Set the attemptFailuresValidityInterval in milliseconds for the application.
    Parameters:
      `attemptFailuresValidityInterval` - attempt failures validity interval.

  - ### getLogAggregationContext

    @Public @Stable public abstract LogAggregationContext getLogAggregationContext()
    Get `LogAggregationContext` of the application
    Returns:
      `LogAggregationContext` of the application

  - ### setLogAggregationContext

    @Public @Stable public abstract void setLogAggregationContext(LogAggregationContext logAggregationContext)
    Set `LogAggregationContext` for the application
    Parameters:
      `logAggregationContext` - for the application

  - ### getReservationID

    @Public @Unstable public abstract ReservationId getReservationID()
    Get the reservation id, that corresponds to a valid resource allocation in the scheduler (between start and end time of the corresponding reservation)
    Returns:
      the reservation id representing the unique id of the corresponding reserved resource allocation in the scheduler

  - ### setReservationID

    @Public @Unstable public abstract void setReservationID(ReservationId reservationID)
    Set the reservation id, that correspond to a valid resource allocation in the scheduler (between start and end time of the corresponding reservation)
    Parameters:
      `reservationID` - representing the unique id of the corresponding reserved resource allocation in the scheduler

  - ### getApplicationTimeouts

    @Public @Unstable public abstract Map<ApplicationTimeoutType,Long> getApplicationTimeouts()
    Get `ApplicationTimeouts` of the application. Timeout value is in seconds.
    Returns:
      all `ApplicationTimeouts` of the application.

  - ### setApplicationTimeouts

    @Public @Unstable public abstract void setApplicationTimeouts(Map<ApplicationTimeoutType,Long> applicationTimeouts)
    Set the `ApplicationTimeouts` for the application in seconds. All pre-existing Map entries are cleared before adding the new Map.

    Note: If application timeout value is less than or equal to zero then application submission will throw an exception.

    Parameters:
      `applicationTimeouts` - `ApplicationTimeouts`s for the application

  - ### getApplicationSchedulingPropertiesMap

    @Public @Unstable public abstract Map<String,String> getApplicationSchedulingPropertiesMap()
    Get application scheduling environment variables stored as a key value pair map for application.
    Returns:
      placement envs for application.

  - ### setApplicationSchedulingPropertiesMap

    @Public @Unstable public abstract void setApplicationSchedulingPropertiesMap(Map<String,String> schedulingEnvMap)
    Set the scheduling envs for the application.
    Parameters:
      `schedulingEnvMap` - A map of env's for the application scheduling preferences.