org.apache.hadoop.hdfs
Class NameNodeProxies

java.lang.Object
  extended by org.apache.hadoop.hdfs.NameNodeProxies

public class NameNodeProxies
extends Object

Create proxy objects to communicate with a remote NN. All remote access to an NN should be funneled through this class. Most of the time you'll want to use createProxy(Configuration, URI, Class), which will create either an HA- or non-HA-enabled client proxy as appropriate.


Nested Class Summary
static class NameNodeProxies.ProxyAndInfo<PROXYTYPE>
          Wrapper for a client proxy as well as its associated service ID.
 
Constructor Summary
NameNodeProxies()
           
 
Method Summary
static
<T> AbstractNNFailoverProxyProvider<T>
createFailoverProxyProvider(org.apache.hadoop.conf.Configuration conf, URI nameNodeUri, Class<T> xface, boolean checkPort, AtomicBoolean fallbackToSimpleAuth)
          Creates the Failover proxy provider instance
static
<T> NameNodeProxies.ProxyAndInfo<T>
createNonHAProxy(org.apache.hadoop.conf.Configuration conf, InetSocketAddress nnAddr, Class<T> xface, org.apache.hadoop.security.UserGroupInformation ugi, boolean withRetries)
          Creates an explicitly non-HA-enabled proxy object.
static
<T> NameNodeProxies.ProxyAndInfo<T>
createNonHAProxy(org.apache.hadoop.conf.Configuration conf, InetSocketAddress nnAddr, Class<T> xface, org.apache.hadoop.security.UserGroupInformation ugi, boolean withRetries, AtomicBoolean fallbackToSimpleAuth)
          Creates an explicitly non-HA-enabled proxy object.
static
<T> NameNodeProxies.ProxyAndInfo<T>
createProxy(org.apache.hadoop.conf.Configuration conf, URI nameNodeUri, Class<T> xface)
          Creates the namenode proxy with the passed protocol.
static
<T> NameNodeProxies.ProxyAndInfo<T>
createProxy(org.apache.hadoop.conf.Configuration conf, URI nameNodeUri, Class<T> xface, AtomicBoolean fallbackToSimpleAuth)
          Creates the namenode proxy with the passed protocol.
static
<T> NameNodeProxies.ProxyAndInfo<T>
createProxyWithLossyRetryHandler(org.apache.hadoop.conf.Configuration config, URI nameNodeUri, Class<T> xface, int numResponseToDrop, AtomicBoolean fallbackToSimpleAuth)
          Generate a dummy namenode proxy instance that utilizes our hacked LossyRetryInvocationHandler.
static
<T> Class<org.apache.hadoop.io.retry.FailoverProxyProvider<T>>
getFailoverProxyProviderClass(org.apache.hadoop.conf.Configuration conf, URI nameNodeUri)
          Gets the configured Failover proxy provider's class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameNodeProxies

public NameNodeProxies()
Method Detail

createProxy

public static <T> NameNodeProxies.ProxyAndInfo<T> createProxy(org.apache.hadoop.conf.Configuration conf,
                                                              URI nameNodeUri,
                                                              Class<T> xface)
                                                   throws IOException
Creates the namenode proxy with the passed protocol. This will handle creation of either HA- or non-HA-enabled proxy objects, depending upon if the provided URI is a configured logical URI.

Parameters:
conf - the configuration containing the required IPC properties, client failover configurations, etc.
nameNodeUri - the URI pointing either to a specific NameNode or to a logical nameservice.
xface - the IPC interface which should be created
Returns:
an object containing both the proxy and the associated delegation token service it corresponds to
Throws:
IOException - if there is an error creating the proxy

createProxy

public static <T> NameNodeProxies.ProxyAndInfo<T> createProxy(org.apache.hadoop.conf.Configuration conf,
                                                              URI nameNodeUri,
                                                              Class<T> xface,
                                                              AtomicBoolean fallbackToSimpleAuth)
                                                   throws IOException
Creates the namenode proxy with the passed protocol. This will handle creation of either HA- or non-HA-enabled proxy objects, depending upon if the provided URI is a configured logical URI.

Parameters:
conf - the configuration containing the required IPC properties, client failover configurations, etc.
nameNodeUri - the URI pointing either to a specific NameNode or to a logical nameservice.
xface - the IPC interface which should be created
fallbackToSimpleAuth - set to true or false during calls to indicate if a secure client falls back to simple auth
Returns:
an object containing both the proxy and the associated delegation token service it corresponds to
Throws:
IOException - if there is an error creating the proxy

createProxyWithLossyRetryHandler

public static <T> NameNodeProxies.ProxyAndInfo<T> createProxyWithLossyRetryHandler(org.apache.hadoop.conf.Configuration config,
                                                                                   URI nameNodeUri,
                                                                                   Class<T> xface,
                                                                                   int numResponseToDrop,
                                                                                   AtomicBoolean fallbackToSimpleAuth)
                                                                        throws IOException
Generate a dummy namenode proxy instance that utilizes our hacked LossyRetryInvocationHandler. Proxy instance generated using this method will proactively drop RPC responses. Currently this method only support HA setup. null will be returned if the given configuration is not for HA.

Parameters:
config - the configuration containing the required IPC properties, client failover configurations, etc.
nameNodeUri - the URI pointing either to a specific NameNode or to a logical nameservice.
xface - the IPC interface which should be created
numResponseToDrop - The number of responses to drop for each RPC call
fallbackToSimpleAuth - set to true or false during calls to indicate if a secure client falls back to simple auth
Returns:
an object containing both the proxy and the associated delegation token service it corresponds to. Will return null of the given configuration does not support HA.
Throws:
IOException - if there is an error creating the proxy

createNonHAProxy

public static <T> NameNodeProxies.ProxyAndInfo<T> createNonHAProxy(org.apache.hadoop.conf.Configuration conf,
                                                                   InetSocketAddress nnAddr,
                                                                   Class<T> xface,
                                                                   org.apache.hadoop.security.UserGroupInformation ugi,
                                                                   boolean withRetries)
                                                        throws IOException
Creates an explicitly non-HA-enabled proxy object. Most of the time you don't want to use this, and should instead use createProxy(org.apache.hadoop.conf.Configuration, java.net.URI, java.lang.Class).

Parameters:
conf - the configuration object
nnAddr - address of the remote NN to connect to
xface - the IPC interface which should be created
ugi - the user who is making the calls on the proxy object
withRetries - certain interfaces have a non-standard retry policy
Returns:
an object containing both the proxy and the associated delegation token service it corresponds to
Throws:
IOException

createNonHAProxy

public static <T> NameNodeProxies.ProxyAndInfo<T> createNonHAProxy(org.apache.hadoop.conf.Configuration conf,
                                                                   InetSocketAddress nnAddr,
                                                                   Class<T> xface,
                                                                   org.apache.hadoop.security.UserGroupInformation ugi,
                                                                   boolean withRetries,
                                                                   AtomicBoolean fallbackToSimpleAuth)
                                                        throws IOException
Creates an explicitly non-HA-enabled proxy object. Most of the time you don't want to use this, and should instead use createProxy(org.apache.hadoop.conf.Configuration, java.net.URI, java.lang.Class).

Parameters:
conf - the configuration object
nnAddr - address of the remote NN to connect to
xface - the IPC interface which should be created
ugi - the user who is making the calls on the proxy object
withRetries - certain interfaces have a non-standard retry policy
fallbackToSimpleAuth - - set to true or false during this method to indicate if a secure client falls back to simple auth
Returns:
an object containing both the proxy and the associated delegation token service it corresponds to
Throws:
IOException

getFailoverProxyProviderClass

public static <T> Class<org.apache.hadoop.io.retry.FailoverProxyProvider<T>> getFailoverProxyProviderClass(org.apache.hadoop.conf.Configuration conf,
                                                                                                           URI nameNodeUri)
                                                                                                throws IOException
Gets the configured Failover proxy provider's class

Throws:
IOException

createFailoverProxyProvider

public static <T> AbstractNNFailoverProxyProvider<T> createFailoverProxyProvider(org.apache.hadoop.conf.Configuration conf,
                                                                                 URI nameNodeUri,
                                                                                 Class<T> xface,
                                                                                 boolean checkPort,
                                                                                 AtomicBoolean fallbackToSimpleAuth)
                                                                      throws IOException
Creates the Failover proxy provider instance

Throws:
IOException


Copyright © 2014 Apache Software Foundation. All Rights Reserved.