Class NMClient
- All Implemented Interfaces:
Closeable,AutoCloseable,Service
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
Service.STATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidcleanupRunningContainersOnStop(boolean enabled) Set whether the containers that are started by this client, and are still running should be stopped when the client stops.abstract voidcommitLastReInitialization(ContainerId containerId) Commit last reInitialization of the specified container.static NMClientCreate a new instance of NMClient.static NMClientcreateNMClient(String name) Create a new instance of NMClient.abstract ContainerStatusgetContainerStatus(ContainerId containerId, NodeId nodeId) Query the status of a container.getLocalizationStatuses(ContainerId containerId, NodeId nodeId) Get the localization statuses of a container.Get the NM token cache of theNMClient.getNodeIdOfStartedContainer(ContainerId containerId) Get the NodeId of the node on which container is running.abstract voidincreaseContainerResource(Container container) Deprecated.voidlocalize(ContainerId containerId, NodeId nodeId, Map<String, LocalResource> localResources) Localize resources for a container.abstract voidreInitializeContainer(ContainerId containerId, ContainerLaunchContext containerLaunchContex, boolean autoCommit) Re-Initialize the Container.abstract voidrestartContainer(ContainerId containerId) Restart the specified container.abstract voidrollbackLastReInitialization(ContainerId containerId) Rollback last reInitialization of the specified container.voidsetNMTokenCache(NMTokenCache nmTokenCache) Set the NM Token cache of theNMClient.abstract Map<String,ByteBuffer> startContainer(Container container, ContainerLaunchContext containerLaunchContext) Start an allocated container.abstract voidstopContainer(ContainerId containerId, NodeId nodeId) Stop an started container.abstract voidupdateContainerResource(Container container) Update the resources of a container.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, serviceStart, serviceStop, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
NMClient
-
-
Method Details
-
createNMClient
Create a new instance of NMClient. -
createNMClient
Create a new instance of NMClient. -
startContainer
public abstract Map<String,ByteBuffer> startContainer(Container container, ContainerLaunchContext containerLaunchContext) throws YarnException, IOException Start an allocated container.
The
ApplicationMasteror other applications that use the client must provide the details of the allocated container, including the Id, the assigned node's Id and the token viaContainer. In addition, the AM needs to provide theContainerLaunchContextas well.- Parameters:
container- the allocated containercontainerLaunchContext- the context information needed by theNodeManagerto launch the container- Returns:
- a map between the auxiliary service names and their outputs
- Throws:
YarnException- YarnException.IOException- IOException.
-
increaseContainerResource
@Deprecated public abstract void increaseContainerResource(Container container) throws YarnException, IOException Deprecated.Increase the resource of a container.
The
ApplicationMasteror other applications that use the client must provide the details of the container, including the Id and the target resource encapsulated in the updated container token viaContainer.- Parameters:
container- the container with updated token.- Throws:
YarnException- YarnException.IOException- IOException.
-
updateContainerResource
Update the resources of a container.
The
ApplicationMasteror other applications that use the client must provide the details of the container, including the Id and the target resource encapsulated in the updated container token viaContainer.- Parameters:
container- the container with updated token.- Throws:
YarnException- YarnException.IOException- IOException.
-
stopContainer
public abstract void stopContainer(ContainerId containerId, NodeId nodeId) throws YarnException, IOException Stop an started container.
- Parameters:
containerId- the Id of the started containernodeId- the Id of theNodeManager- Throws:
YarnException- YarnException.IOException- IOException.
-
getContainerStatus
public abstract ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId) throws YarnException, IOException Query the status of a container.
- Parameters:
containerId- the Id of the started containernodeId- the Id of theNodeManager- Returns:
- the status of a container.
- Throws:
YarnException- YarnException.IOException- IOException.
-
reInitializeContainer
public abstract void reInitializeContainer(ContainerId containerId, ContainerLaunchContext containerLaunchContex, boolean autoCommit) throws YarnException, IOException Re-Initialize the Container.
- Parameters:
containerId- the Id of the container to Re-Initialize.containerLaunchContex- the updated ContainerLaunchContext.autoCommit- commit re-initialization automatically ?- Throws:
YarnException- YarnException.IOException- IOException.
-
restartContainer
Restart the specified container.
- Parameters:
containerId- the Id of the container to restart.- Throws:
YarnException- YarnException.IOException- IOException.
-
rollbackLastReInitialization
public abstract void rollbackLastReInitialization(ContainerId containerId) throws YarnException, IOException Rollback last reInitialization of the specified container.
- Parameters:
containerId- the Id of the container to restart.- Throws:
YarnException- YarnException.IOException- IOException.
-
commitLastReInitialization
public abstract void commitLastReInitialization(ContainerId containerId) throws YarnException, IOException Commit last reInitialization of the specified container.
- Parameters:
containerId- the Id of the container to commit reInitialize.- Throws:
YarnException- YarnException.IOException- IOException.
-
cleanupRunningContainersOnStop
public abstract void cleanupRunningContainersOnStop(boolean enabled) Set whether the containers that are started by this client, and are still running should be stopped when the client stops. By default, the feature should be enabled.
However, containers will be stopped only when service is stopped. i.e. afterAbstractService.stop().- Parameters:
enabled- whether the feature is enabled or not
-
setNMTokenCache
Set the NM Token cache of theNMClient. This cache must be shared with theAMRMClientthat requested the containers managed by thisNMClientIf a NM token cache is not set, the
NMTokenCache.getSingleton()singleton instance will be used.- Parameters:
nmTokenCache- the NM token cache to use.
-
getNMTokenCache
Get the NM token cache of theNMClient. This cache must be shared with theAMRMClientthat requested the containers managed by thisNMClientIf a NM token cache is not set, the
NMTokenCache.getSingleton()singleton instance will be used.- Returns:
- the NM token cache
-
getNodeIdOfStartedContainer
Get the NodeId of the node on which container is running. It returns null if the container if container is not found or if it is not running.- Parameters:
containerId- Container Id of the container.- Returns:
- NodeId of the container on which it is running.
-
localize
@Unstable public void localize(ContainerId containerId, NodeId nodeId, Map<String, LocalResource> localResources) throws YarnException, IOExceptionLocalize resources for a container.- Parameters:
containerId- the ID of the containernodeId- node Id of the containerlocalResources- resources to localize- Throws:
YarnExceptionIOException
-
getLocalizationStatuses
@Unstable public List<LocalizationStatus> getLocalizationStatuses(ContainerId containerId, NodeId nodeId) throws YarnException, IOException Get the localization statuses of a container.- Parameters:
containerId- the Id of the containernodeId- node Id of the container- Returns:
- the status of a container.
- Throws:
YarnException- YarnException.IOException- IOException.
-