Class AMRMProxyService
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.yarn.server.nodemanager.amrmproxy.AMRMProxyService
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service,org.apache.hadoop.yarn.api.ApplicationMasterProtocol
public class AMRMProxyService
extends org.apache.hadoop.service.CompositeService
implements org.apache.hadoop.yarn.api.ApplicationMasterProtocol
AMRMProxyService is a service that runs on each node manager that can be used
to intercept and inspect messages from application master to the cluster
resource manager. It listens to messages from the application master and
creates a request intercepting pipeline instance for each application. The
pipeline is a chain of interceptor instances that can inspect and modify the
request/response as needed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPrivate structure for encapsulating RequestInterceptor and ApplicationAttemptId instances.Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
ConstructorsConstructorDescriptionAMRMProxyService(Context nmContext, org.apache.hadoop.yarn.event.AsyncDispatcher dispatcher) Creates an instance of the service. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.yarn.api.protocolrecords.AllocateResponseallocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest request) This is called by the AMs started on this node to send heart beat to RM.protected RequestInterceptorThis method creates and returns reference of the first interceptor in the chain of request interceptor instances.org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponsefinishApplicationMaster(org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest request) This is called by the AMs started on this node to unregister from the RM.protected Map<org.apache.hadoop.yarn.api.records.ApplicationId,AMRMProxyService.RequestInterceptorChainWrapper> Gets the Request interceptor chains for all the applications.protected voidinitializePipeline(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId, String user, org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> amrmToken, org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> localToken, Map<String, byte[]> recoveredDataMap, boolean isRecovery, org.apache.hadoop.security.Credentials credentials) Initializes the request interceptor pipeline for the specified application.voidprocessApplicationStartRequest(org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest request) Callback from the ContainerManager implementation for initializing the application request processing pipeline.voidrecover()Recover from NM state store.org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponseregisterApplicationMaster(org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest request) This is called by the AMs started on this node to register with the RM.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) protected voidprotected voidprotected voidstopApplication(org.apache.hadoop.yarn.api.records.ApplicationId applicationId) Shuts down the request processing pipeline for the specified application attempt id.Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeServiceMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
AMRMProxyService
Creates an instance of the service.- Parameters:
nmContext- NM contextdispatcher- NM dispatcher
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStart
- Overrides:
serviceStartin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
serviceStop
- Overrides:
serviceStopin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
recover
Recover from NM state store. Called after serviceInit before serviceStart.- Throws:
IOException- if recover fails
-
registerApplicationMaster
public org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse registerApplicationMaster(org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException This is called by the AMs started on this node to register with the RM. This method does the initial authorization and then forwards the request to the application instance specific interceptor chain.- Specified by:
registerApplicationMasterin interfaceorg.apache.hadoop.yarn.api.ApplicationMasterProtocol- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
finishApplicationMaster
public org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse finishApplicationMaster(org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException This is called by the AMs started on this node to unregister from the RM. This method does the initial authorization and then forwards the request to the application instance specific interceptor chain.- Specified by:
finishApplicationMasterin interfaceorg.apache.hadoop.yarn.api.ApplicationMasterProtocol- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
allocate
public org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse allocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException This is called by the AMs started on this node to send heart beat to RM. This method does the initial authorization and then forwards the request to the application instance specific pipeline, which is a chain of request interceptor objects. One application request processing pipeline is created per AM instance.- Specified by:
allocatein interfaceorg.apache.hadoop.yarn.api.ApplicationMasterProtocol- Throws:
org.apache.hadoop.yarn.exceptions.YarnExceptionIOException
-
processApplicationStartRequest
public void processApplicationStartRequest(org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest request) throws IOException, org.apache.hadoop.yarn.exceptions.YarnException Callback from the ContainerManager implementation for initializing the application request processing pipeline.- Parameters:
request- - encapsulates information for starting an AM- Throws:
IOException- if failsorg.apache.hadoop.yarn.exceptions.YarnException- if fails
-
initializePipeline
protected void initializePipeline(org.apache.hadoop.yarn.api.records.ApplicationAttemptId applicationAttemptId, String user, org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> amrmToken, org.apache.hadoop.security.token.Token<org.apache.hadoop.yarn.security.AMRMTokenIdentifier> localToken, Map<String, byte[]> recoveredDataMap, boolean isRecovery, org.apache.hadoop.security.Credentials credentials) Initializes the request interceptor pipeline for the specified application.- Parameters:
applicationAttemptId- attempt iduser- user nameamrmToken- amrmToken issued by RMlocalToken- amrmToken issued by AMRMProxyrecoveredDataMap- the recovered states for AMRMProxy from NMSSisRecovery- whether this is to recover a previously existing pipeline
-
stopApplication
protected void stopApplication(org.apache.hadoop.yarn.api.records.ApplicationId applicationId) Shuts down the request processing pipeline for the specified application attempt id.- Parameters:
applicationId- application id
-
getPipelines
protected Map<org.apache.hadoop.yarn.api.records.ApplicationId,AMRMProxyService.RequestInterceptorChainWrapper> getPipelines()Gets the Request interceptor chains for all the applications.- Returns:
- the request interceptor chains.
-
createRequestInterceptorChain
This method creates and returns reference of the first interceptor in the chain of request interceptor instances.- Returns:
- the reference of the first interceptor in the chain
-
getBindAddress
-
getSecretManager
-