Search in sources :

Example 1 with ClientNamenodeProtocolPB

use of org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB in project hadoop by apache.

the class NameNodeProxiesClient method createNonHAProxyWithClientProtocol.

public static ClientProtocol createNonHAProxyWithClientProtocol(InetSocketAddress address, Configuration conf, UserGroupInformation ugi, boolean withRetries, AtomicBoolean fallbackToSimpleAuth) throws IOException {
    RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class, ProtobufRpcEngine.class);
    final RetryPolicy defaultPolicy = RetryUtils.getDefaultRetryPolicy(conf, HdfsClientConfigKeys.Retry.POLICY_ENABLED_KEY, HdfsClientConfigKeys.Retry.POLICY_ENABLED_DEFAULT, HdfsClientConfigKeys.Retry.POLICY_SPEC_KEY, HdfsClientConfigKeys.Retry.POLICY_SPEC_DEFAULT, SafeModeException.class.getName());
    final long version = RPC.getProtocolVersion(ClientNamenodeProtocolPB.class);
    ClientNamenodeProtocolPB proxy = RPC.getProtocolProxy(ClientNamenodeProtocolPB.class, version, address, ugi, conf, NetUtils.getDefaultSocketFactory(conf), org.apache.hadoop.ipc.Client.getTimeout(conf), defaultPolicy, fallbackToSimpleAuth).getProxy();
    if (withRetries) {
        // create the proxy with retries
        Map<String, RetryPolicy> methodNameToPolicyMap = new HashMap<>();
        ClientProtocol translatorProxy = new ClientNamenodeProtocolTranslatorPB(proxy);
        return (ClientProtocol) RetryProxy.create(ClientProtocol.class, new DefaultFailoverProxyProvider<>(ClientProtocol.class, translatorProxy), methodNameToPolicyMap, defaultPolicy);
    } else {
        return new ClientNamenodeProtocolTranslatorPB(proxy);
    }
}
Also used : ClientNamenodeProtocolPB(org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB) HashMap(java.util.HashMap) ClientNamenodeProtocolTranslatorPB(org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB) SafeModeException(org.apache.hadoop.hdfs.server.namenode.SafeModeException) DefaultFailoverProxyProvider(org.apache.hadoop.io.retry.DefaultFailoverProxyProvider) ClientProtocol(org.apache.hadoop.hdfs.protocol.ClientProtocol) RetryPolicy(org.apache.hadoop.io.retry.RetryPolicy)

Aggregations

HashMap (java.util.HashMap)1 ClientProtocol (org.apache.hadoop.hdfs.protocol.ClientProtocol)1 ClientNamenodeProtocolPB (org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB)1 ClientNamenodeProtocolTranslatorPB (org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB)1 SafeModeException (org.apache.hadoop.hdfs.server.namenode.SafeModeException)1 DefaultFailoverProxyProvider (org.apache.hadoop.io.retry.DefaultFailoverProxyProvider)1 RetryPolicy (org.apache.hadoop.io.retry.RetryPolicy)1