Class ApplicationSubmissionContext
java.lang.Object
org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext
ApplicationSubmissionContext represents all of the
information needed by the ResourceManager to launch
the ApplicationMaster for an application.
It includes details such as:
ApplicationIdof the application.- Application user.
- Application name.
Priorityof the application.-
ContainerLaunchContextof the container in which theApplicationMasteris 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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ResourceRequestDeprecated.abstract List<ResourceRequest>Get the ResourceRequests of the AM container.abstract ContainerLaunchContextGet theContainerLaunchContextto describe theContainerwith which theApplicationMasteris launched.abstract ApplicationIdGet theApplicationIdof the submitted application.abstract StringGet the application name.Get application scheduling environment variables stored as a key value pair map for application.Get tags for the applicationabstract Map<ApplicationTimeoutType,Long> GetApplicationTimeoutsof the application.abstract StringGet the application typeabstract longGet the attemptFailuresValidityInterval in milliseconds for the application.abstract booleangetCancelTokensWhenComplete()abstract booleanGet the flag which indicates whether to keep containers across application attempts or not.abstract LogAggregationContextGetLogAggregationContextof the applicationabstract intabstract StringGet node-label-expression for this app.abstract PriorityGet thePriorityof the application.abstract StringgetQueue()Get the queue to which the application is being submitted.abstract ReservationIdGet the reservation id, that corresponds to a valid resource allocation in the scheduler (between start and end time of the corresponding reservation)abstract ResourceGet the resource required by theApplicationMasterfor this application.abstract booleanGet if the RM should manage the execution of the AM.static ApplicationSubmissionContextnewInstance(ApplicationId applicationId, String applicationName, String queue, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, String applicationType, boolean keepContainers, String appLabelExpression, ResourceRequest resourceRequest) static ApplicationSubmissionContextnewInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource) static ApplicationSubmissionContextnewInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType) static ApplicationSubmissionContextnewInstance(ApplicationId applicationId, String applicationName, String queue, Priority priority, ContainerLaunchContext amContainer, boolean isUnmanagedAM, boolean cancelTokensWhenComplete, int maxAppAttempts, Resource resource, String applicationType, boolean keepContainers) static ApplicationSubmissionContextnewInstance(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 ApplicationSubmissionContextnewInstance(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 ApplicationSubmissionContextnewInstance(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 voidDeprecated.abstract voidsetAMContainerResourceRequests(List<ResourceRequest> requests) Set ResourceRequests of the AM container.abstract voidsetAMContainerSpec(ContainerLaunchContext amContainer) Set theContainerLaunchContextto describe theContainerwith which theApplicationMasteris launched.abstract voidsetApplicationId(ApplicationId applicationId) Set theApplicationIdof the submitted application.abstract voidsetApplicationName(String applicationName) Set the application name.abstract voidsetApplicationSchedulingPropertiesMap(Map<String, String> schedulingEnvMap) Set the scheduling envs for the application.abstract voidsetApplicationTags(Set<String> tags) Set tags for the application.abstract voidsetApplicationTimeouts(Map<ApplicationTimeoutType, Long> applicationTimeouts) Set theApplicationTimeoutsfor the application in seconds.abstract voidsetApplicationType(String applicationType) Set the application typeabstract voidsetAttemptFailuresValidityInterval(long attemptFailuresValidityInterval) Set the attemptFailuresValidityInterval in milliseconds for the application.abstract voidsetCancelTokensWhenComplete(boolean cancel) Set to false if tokens should not be canceled when the app finished else false.abstract voidsetKeepContainersAcrossApplicationAttempts(boolean keepContainers) Set the flag which indicates whether to keep containers across application attempts.abstract voidsetLogAggregationContext(LogAggregationContext logAggregationContext) SetLogAggregationContextfor the applicationabstract voidsetMaxAppAttempts(int maxAppAttempts) Set the number of max attempts of the application to be submitted.abstract voidsetNodeLabelExpression(String nodeLabelExpression) Set node-label-expression for this appabstract voidsetPriority(Priority priority) Set thePriorityof the application.abstract voidSet the queue to which the application is being submittedabstract voidsetReservationID(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 voidsetResource(Resource resource) Set the resource required by theApplicationMasterfor this application.abstract voidsetUnmanagedAM(boolean value)
-
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
Get theApplicationIdof the submitted application.- Returns:
ApplicationIdof the submitted application
-
setApplicationId
Set theApplicationIdof the submitted application.- Parameters:
applicationId-ApplicationIdof the submitted application
-
getApplicationName
Get the application name.- Returns:
- application name
-
setApplicationName
Set the application name.- Parameters:
applicationName- application name
-
getQueue
Get the queue to which the application is being submitted.- Returns:
- queue to which the application is being submitted
-
setQueue
Set the queue to which the application is being submitted- Parameters:
queue- queue to which the application is being submitted
-
getPriority
Get thePriorityof the application.- Returns:
Priorityof the application
-
setPriority
Set thePriorityof the application.- Parameters:
priority-Priorityof the application
-
getAMContainerSpec
Get theContainerLaunchContextto describe theContainerwith which theApplicationMasteris launched.- Returns:
ContainerLaunchContextfor theApplicationMastercontainer
-
setAMContainerSpec
Set theContainerLaunchContextto describe theContainerwith which theApplicationMasteris launched.- Parameters:
amContainer-ContainerLaunchContextfor theApplicationMastercontainer
-
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 theYarnApplicationState. 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
Get the resource required by theApplicationMasterfor this application. Please note this will be DEPRECATED, use getResource in getAMContainerResourceRequest instead.- Returns:
- the resource required by the
ApplicationMasterfor this application.
-
setResource
Set the resource required by theApplicationMasterfor this application.- Parameters:
resource- the resource required by theApplicationMasterfor this application.
-
getApplicationType
Get the application type- Returns:
- the application type
-
setApplicationType
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
Get tags for the application- Returns:
- the application tags
-
setApplicationTags
Set tags for the application. A maximum ofYarnConfiguration.RM_APPLICATION_MAX_TAGSare allowed per application. Each tag can be at mostYarnConfiguration.RM_APPLICATION_MAX_TAG_LENGTHcharacters, and can contain only ASCII characters.- Parameters:
tags- tags to set
-
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
Set node-label-expression for this app- Parameters:
nodeLabelExpression- node-label-expression of this app
-
getAMContainerResourceRequest
Deprecated.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.Set ResourceRequest of the AM container- Parameters:
request- of the AM container
-
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
GetLogAggregationContextof the application- Returns:
LogAggregationContextof the application
-
setLogAggregationContext
@Public @Stable public abstract void setLogAggregationContext(LogAggregationContext logAggregationContext) SetLogAggregationContextfor the application- Parameters:
logAggregationContext- for the application
-
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
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
GetApplicationTimeoutsof the application. Timeout value is in seconds.- Returns:
- all
ApplicationTimeoutsof the application.
-
setApplicationTimeouts
@Public @Unstable public abstract void setApplicationTimeouts(Map<ApplicationTimeoutType, Long> applicationTimeouts) Set theApplicationTimeoutsfor 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-ApplicationTimeoutss for the application
-
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.
-
getAMContainerResourceRequests()