java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.yarn.server.nodemanager.containermanager.ContainerManagerImpl
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service, org.apache.hadoop.service.ServiceStateChangeListener, org.apache.hadoop.yarn.api.ContainerManagementProtocol, org.apache.hadoop.yarn.event.EventHandler<ContainerManagerEvent>, ContainerManager

public class ContainerManagerImpl extends org.apache.hadoop.service.CompositeService implements ContainerManager
  • Field Details

  • Constructor Details

  • Method Details

    • serviceInit

      public void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.CompositeService
      Throws:
      Exception
    • createContainerManagerDispatcher

      protected org.apache.hadoop.yarn.event.AsyncDispatcher createContainerManagerDispatcher()
    • createAMRMProxyService

      protected void createAMRMProxyService(org.apache.hadoop.conf.Configuration conf)
    • createContainerScheduler

      @VisibleForTesting protected ContainerScheduler createContainerScheduler(Context cntxt)
    • createContainersMonitor

      protected ContainersMonitor createContainersMonitor(ContainerExecutor exec)
    • recoverActiveContainer

      protected void recoverActiveContainer(Application app, org.apache.hadoop.yarn.api.records.ContainerLaunchContext launchContext, org.apache.hadoop.yarn.security.ContainerTokenIdentifier token, NMStateStoreService.RecoveredContainerState rcs) throws IOException
      Recover a running container.
      Throws:
      IOException
    • createLogHandler

      protected LogHandler createLogHandler(org.apache.hadoop.conf.Configuration conf, Context context, DeletionService deletionService)
    • getContainersMonitor

      public ContainersMonitor getContainersMonitor()
      Specified by:
      getContainersMonitor in interface ContainerManager
    • createResourceLocalizationService

      protected ResourceLocalizationService createResourceLocalizationService(ContainerExecutor exec, DeletionService deletionContext, Context nmContext, NodeManagerMetrics nmMetrics)
    • createSharedCacheUploaderService

      protected SharedCacheUploadService createSharedCacheUploaderService()
    • createNMTimelinePublisher

      @VisibleForTesting protected NMTimelinePublisher createNMTimelinePublisher(Context ctxt)
    • createContainersLauncher

      protected AbstractContainersLauncher createContainersLauncher(Context ctxt, ContainerExecutor exec)
    • createApplicationEventDispatcher

      protected org.apache.hadoop.yarn.event.EventHandler<ApplicationEvent> createApplicationEventDispatcher()
    • serviceStart

      protected void serviceStart() throws Exception
      Overrides:
      serviceStart in class org.apache.hadoop.service.CompositeService
      Throws:
      Exception
    • serviceStop

      public void serviceStop() throws Exception
      Overrides:
      serviceStop in class org.apache.hadoop.service.CompositeService
      Throws:
      Exception
    • cleanUpApplicationsOnNMShutDown

      public void cleanUpApplicationsOnNMShutDown()
    • cleanupContainersOnNMResync

      public void cleanupContainersOnNMResync()
    • getRemoteUgi

      protected org.apache.hadoop.security.UserGroupInformation getRemoteUgi() throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • selectNMTokenIdentifier

      @Private @VisibleForTesting protected org.apache.hadoop.yarn.security.NMTokenIdentifier selectNMTokenIdentifier(org.apache.hadoop.security.UserGroupInformation remoteUgi)
    • authorizeUser

      protected void authorizeUser(org.apache.hadoop.security.UserGroupInformation remoteUgi, org.apache.hadoop.yarn.security.NMTokenIdentifier nmTokenIdentifier) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • authorizeStartAndResourceIncreaseRequest

      @Private @VisibleForTesting protected void authorizeStartAndResourceIncreaseRequest(org.apache.hadoop.yarn.security.NMTokenIdentifier nmTokenIdentifier, org.apache.hadoop.yarn.security.ContainerTokenIdentifier containerTokenIdentifier, boolean startRequest) throws org.apache.hadoop.yarn.exceptions.YarnException
      Parameters:
      containerTokenIdentifier - of the container whose resource is to be started or increased
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • startContainers

      public org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse startContainers(org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest requests) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Start a list of containers on this NodeManager.
      Specified by:
      startContainers in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • startContainerInternal

      protected void startContainerInternal(org.apache.hadoop.yarn.security.ContainerTokenIdentifier containerTokenIdentifier, org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest request, String remoteUser) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • verifyAndGetContainerTokenIdentifier

      protected org.apache.hadoop.yarn.security.ContainerTokenIdentifier verifyAndGetContainerTokenIdentifier(org.apache.hadoop.yarn.api.records.Token token, org.apache.hadoop.yarn.security.ContainerTokenIdentifier containerTokenIdentifier) throws org.apache.hadoop.yarn.exceptions.YarnException, org.apache.hadoop.security.token.SecretManager.InvalidToken
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      org.apache.hadoop.security.token.SecretManager.InvalidToken
    • increaseContainersResource

      @Deprecated public org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse increaseContainersResource(org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest requests) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Deprecated.
      Increase resource of a list of containers on this NodeManager.
      Specified by:
      increaseContainersResource in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • updateContainer

      public org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateResponse updateContainer(org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Update resource of a list of containers on this NodeManager.
      Specified by:
      updateContainer in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • updateNMTokenIdentifier

      @Private @VisibleForTesting protected void updateNMTokenIdentifier(org.apache.hadoop.yarn.security.NMTokenIdentifier nmTokenIdentifier) throws org.apache.hadoop.security.token.SecretManager.InvalidToken
      Throws:
      org.apache.hadoop.security.token.SecretManager.InvalidToken
    • stopContainers

      public org.apache.hadoop.yarn.api.protocolrecords.StopContainersResponse stopContainers(org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest requests) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Stop a list of containers running on this NodeManager.
      Specified by:
      stopContainers in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • stopContainerInternal

      protected void stopContainerInternal(org.apache.hadoop.yarn.api.records.ContainerId containerID, String remoteUser) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • getContainerStatuses

      public org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse getContainerStatuses(org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Get a list of container statuses running on this NodeManager
      Specified by:
      getContainerStatuses in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • getContainerStatusInternal

      protected org.apache.hadoop.yarn.api.records.ContainerStatus getContainerStatusInternal(org.apache.hadoop.yarn.api.records.ContainerId containerID, org.apache.hadoop.yarn.security.NMTokenIdentifier nmTokenIdentifier, String remoteUser) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • authorizeGetAndStopContainerRequest

      @Private @VisibleForTesting protected void authorizeGetAndStopContainerRequest(org.apache.hadoop.yarn.api.records.ContainerId containerId, Container container, boolean stopRequest, org.apache.hadoop.yarn.security.NMTokenIdentifier identifier, String remoteUser) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • handle

      public void handle(ContainerManagerEvent event)
      Specified by:
      handle in interface org.apache.hadoop.yarn.event.EventHandler<ContainerManagerEvent>
    • stateChanged

      public void stateChanged(org.apache.hadoop.service.Service service)
      Specified by:
      stateChanged in interface org.apache.hadoop.service.ServiceStateChangeListener
    • getContext

      public Context getContext()
    • getAuxServiceMetaData

      public Map<String,ByteBuffer> getAuxServiceMetaData()
    • getAMRMProxyService

      @Private public AMRMProxyService getAMRMProxyService()
    • setAMRMProxyService

      @Private protected void setAMRMProxyService(AMRMProxyService amrmProxyService)
    • isServiceStopped

      protected boolean isServiceStopped()
    • getOpportunisticContainersStatus

      public org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus getOpportunisticContainersStatus()
      Specified by:
      getOpportunisticContainersStatus in interface ContainerManager
    • updateQueuingLimit

      public void updateQueuingLimit(org.apache.hadoop.yarn.server.api.records.ContainerQueuingLimit queuingLimit)
      Specified by:
      updateQueuingLimit in interface ContainerManager
    • signalToContainer

      public org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse signalToContainer(org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Specified by:
      signalToContainer in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • localize

      public org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse localize(org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Specified by:
      localize in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • reInitializeContainer

      public org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerResponse reInitializeContainer(org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Specified by:
      reInitializeContainer in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • restartContainer

      public org.apache.hadoop.yarn.api.protocolrecords.RestartContainerResponse restartContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Specified by:
      restartContainer in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • reInitializeContainer

      public void reInitializeContainer(org.apache.hadoop.yarn.api.records.ContainerId containerId, org.apache.hadoop.yarn.api.records.ContainerLaunchContext reInitLaunchContext, boolean autoCommit) throws org.apache.hadoop.yarn.exceptions.YarnException
      ReInitialize a container using a new Launch Context. If the retryFailureContext is not provided, The container is terminated on Failure. NOTE: Auto-Commit is true by default. This also means that the rollback context is purged as soon as the command to start the new process is sent. (The Container moves to RUNNING state)
      Parameters:
      containerId - Container Id.
      autoCommit - Auto Commit flag.
      reInitLaunchContext - Target Launch Context.
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - YARN Exception.
    • rollbackLastReInitialization

      public org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse rollbackLastReInitialization(org.apache.hadoop.yarn.api.records.ContainerId containerId) throws org.apache.hadoop.yarn.exceptions.YarnException
      Rollback the last reInitialization, if possible.
      Specified by:
      rollbackLastReInitialization in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Parameters:
      containerId - Container ID.
      Returns:
      Rollback Response.
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - YARN Exception.
    • commitLastReInitialization

      public org.apache.hadoop.yarn.api.protocolrecords.CommitResponse commitLastReInitialization(org.apache.hadoop.yarn.api.records.ContainerId containerId) throws org.apache.hadoop.yarn.exceptions.YarnException
      Commit last reInitialization after which no rollback will be possible.
      Specified by:
      commitLastReInitialization in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Parameters:
      containerId - Container ID.
      Returns:
      Commit Response.
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException - YARN Exception.
    • getContainerScheduler

      public ContainerScheduler getContainerScheduler()
      Specified by:
      getContainerScheduler in interface ContainerManager
    • handleCredentialUpdate

      public void handleCredentialUpdate()
      Specified by:
      handleCredentialUpdate in interface ContainerManager
    • getLocalizationStatuses

      public org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesResponse getLocalizationStatuses(org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException, IOException
      Specified by:
      getLocalizationStatuses in interface org.apache.hadoop.yarn.api.ContainerManagementProtocol
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
      IOException
    • getResourceLocalizationService

      public ResourceLocalizationService getResourceLocalizationService()
      Specified by:
      getResourceLocalizationService in interface ContainerManager
    • getDispatcher

      public org.apache.hadoop.yarn.event.AsyncDispatcher getDispatcher()