org.apache.hadoop.yarn.client.api
Class NMClient

java.lang.Object
  extended by org.apache.hadoop.service.AbstractService
      extended by org.apache.hadoop.yarn.client.api.NMClient
All Implemented Interfaces:
Closeable, Service

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class NMClient
extends AbstractService


Constructor Summary
protected NMClient(String name)
           
 
Method Summary
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.
static NMClient createNMClient()
          Create a new instance of NMClient.
static NMClient createNMClient(String name)
          Create a new instance of NMClient.
abstract  ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId)
          Query the status of a container.
abstract  Map<String,ByteBuffer> startContainer(Container container, ContainerLaunchContext containerLaunchContext)
          Start an allocated container.
abstract  void stopContainer(ContainerId containerId, NodeId nodeId)
          Stop an started 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NMClient

@InterfaceAudience.Private
protected NMClient(String name)
Method Detail

createNMClient

@InterfaceAudience.Public
public static NMClient createNMClient()
Create a new instance of NMClient.


createNMClient

@InterfaceAudience.Public
public static NMClient createNMClient(String name)
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 ApplicationMaster or 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 via Container. In addition, the AM needs to provide the ContainerLaunchContext as well.

Parameters:
container - the allocated container
containerLaunchContext - the context information needed by the NodeManager to launch the container
Returns:
a map between the auxiliary service names and their outputs
Throws:
YarnException
IOException

stopContainer

public abstract void stopContainer(ContainerId containerId,
                                   NodeId nodeId)
                            throws YarnException,
                                   IOException

Stop an started container.

Parameters:
containerId - the Id of the started container
nodeId - the Id of the NodeManager
Throws:
YarnException
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 container
nodeId - the Id of the NodeManager
Returns:
the status of a container
Throws:
YarnException
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. after AbstractService.stop().

Parameters:
enabled - whether the feature is enabled or not


Copyright © 2013 Apache Software Foundation. All Rights Reserved.