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

java.lang.Object
  extended by org.apache.hadoop.yarn.client.api.NMTokenCache

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class NMTokenCache
extends Object

NMTokenCache manages NMTokens required for an Application Master communicating with individual NodeManagers.

By default Yarn client libraries AMRMClient and NMClient use getSingleton() instance of the cache.

If running multiple Application Masters in the same JVM, a different cache instance should be used for each Application Master.

It is also possible to mix the usage of a client (AMRMClient or NMClient, or the async versions of them) with a protocol proxy ( ContainerManagementProtocolProxy or ApplicationMasterProtocol).


Constructor Summary
NMTokenCache()
          Creates a NM token cache instance.
 
Method Summary
 void clearCache()
          It will remove all the nm tokens from its cache
 boolean containsToken(String nodeAddr)
          Returns true if NMToken is present in cache.
static org.apache.hadoop.yarn.api.records.Token getNMToken(String nodeAddr)
          Returns NMToken, null if absent.
static NMTokenCache getSingleton()
          Returns the singleton NM token cache.
 org.apache.hadoop.yarn.api.records.Token getToken(String nodeAddr)
          Returns NMToken, null if absent
 int numberOfTokensInCache()
          Returns the number of NMTokens present in cache.
 void removeToken(String nodeAddr)
          Removes NMToken for specified node manager
static void setNMToken(String nodeAddr, org.apache.hadoop.yarn.api.records.Token token)
          Sets the NMToken for node address only in the singleton obtained from getSingleton().
 void setToken(String nodeAddr, org.apache.hadoop.yarn.api.records.Token token)
          Sets the NMToken for node address
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NMTokenCache

public NMTokenCache()
Creates a NM token cache instance.

Method Detail

getSingleton

public static NMTokenCache getSingleton()
Returns the singleton NM token cache.

Returns:
the singleton NM token cache.

getNMToken

@InterfaceAudience.Public
public static org.apache.hadoop.yarn.api.records.Token getNMToken(String nodeAddr)
Returns NMToken, null if absent. Only the singleton obtained from getSingleton() is looked at for the tokens. If you are using your own NMTokenCache that is different from the singleton, use getToken(String)

Parameters:
nodeAddr -
Returns:
Token NMToken required for communicating with node manager

setNMToken

@InterfaceAudience.Public
public static void setNMToken(String nodeAddr,
                                                       org.apache.hadoop.yarn.api.records.Token token)
Sets the NMToken for node address only in the singleton obtained from getSingleton(). If you are using your own NMTokenCache that is different from the singleton, use setToken(String, Token)

Parameters:
nodeAddr - node address (host:port)
token - NMToken

getToken

@InterfaceAudience.Public
@InterfaceStability.Evolving
public org.apache.hadoop.yarn.api.records.Token getToken(String nodeAddr)
Returns NMToken, null if absent

Parameters:
nodeAddr -
Returns:
Token NMToken required for communicating with node manager

setToken

@InterfaceAudience.Public
@InterfaceStability.Evolving
public void setToken(String nodeAddr,
                                                                          org.apache.hadoop.yarn.api.records.Token token)
Sets the NMToken for node address

Parameters:
nodeAddr - node address (host:port)
token - NMToken

containsToken

@InterfaceAudience.Private
public boolean containsToken(String nodeAddr)
Returns true if NMToken is present in cache.


numberOfTokensInCache

@InterfaceAudience.Private
public int numberOfTokensInCache()
Returns the number of NMTokens present in cache.


removeToken

@InterfaceAudience.Private
public void removeToken(String nodeAddr)
Removes NMToken for specified node manager

Parameters:
nodeAddr - node address (host:port)

clearCache

@InterfaceAudience.Private
public void clearCache()
It will remove all the nm tokens from its cache



Copyright © 2014 Apache Software Foundation. All Rights Reserved.