当前位置: 首页>>代码示例>>Java>>正文


Java NetUtils.getSocketFactory方法代码示例

本文整理汇总了Java中org.apache.hadoop.net.NetUtils.getSocketFactory方法的典型用法代码示例。如果您正苦于以下问题:Java NetUtils.getSocketFactory方法的具体用法?Java NetUtils.getSocketFactory怎么用?Java NetUtils.getSocketFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.net.NetUtils的用法示例。


在下文中一共展示了NetUtils.getSocketFactory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NuCypherExtClient

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
/**
  * Create a new NuCypherExtClient connected to the given nameNodeUri or rpcNamenode.
  * If HA is enabled and a positive value is set for
  * {@link HdfsClientConfigKeys#DFS_CLIENT_TEST_DROP_NAMENODE_RESPONSE_NUM_KEY}
  * in the configuration, the DFSClient will use
  * {@link LossyRetryInvocationHandler} as its RetryInvocationHandler.
  * Otherwise one of nameNodeUri or rpcNamenode must be null.
  */
 @VisibleForTesting
 public NuCypherExtClient(URI nameNodeUri, NuCypherExtClientProtocol rpcNamenode,
                        Configuration conf, FileSystem.Statistics stats) throws IOException {
//   this.dfsClientConf = new DfsClientConf(conf);
   this.conf = conf;
   this.stats = stats;
   this.socketFactory = NetUtils.getSocketFactory(conf, NuCypherExtClientProtocol.class);

   this.ugi = UserGroupInformation.getCurrentUser();

   this.authority = nameNodeUri == null? "null": nameNodeUri.getAuthority();
   this.clientName = "NuCypherExtClient_" + conf.get("mapreduce.task.attempt.id", "NONMAPREDUCE") + "_" +
       ThreadLocalRandom.current().nextInt()  + "_" +
       Thread.currentThread().getId();
   int numResponseToDrop = conf.getInt(
       DFS_CLIENT_TEST_DROP_NAMENODE_RESPONSE_NUM_KEY,
       DFS_CLIENT_TEST_DROP_NAMENODE_RESPONSE_NUM_DEFAULT);
   ProxyAndInfo<NuCypherExtClientProtocol> proxyInfo = null;
   AtomicBoolean nnFallbackToSimpleAuth = new AtomicBoolean(false);

   if (numResponseToDrop > 0) {
     // This case is used for testing.
     LOG.warn(DFS_CLIENT_TEST_DROP_NAMENODE_RESPONSE_NUM_KEY
         + " is set to " + numResponseToDrop
         + ", this hacked client will proactively drop responses");
     proxyInfo = NuCypherExtNameNodeProxiesClient.createProxyWithLossyRetryHandler(conf,
         nameNodeUri, NuCypherExtClientProtocol.class, numResponseToDrop,
         nnFallbackToSimpleAuth);
   }

   if (proxyInfo != null) {
     // this.dtService = proxyInfo.getDelegationTokenService();
     this.namenode = proxyInfo.getProxy();
   } else if (rpcNamenode != null) {
     // This case is used for testing.
     Preconditions.checkArgument(nameNodeUri == null);
     this.namenode = rpcNamenode;
     //dtService = null;
   } else {
     Preconditions.checkArgument(nameNodeUri != null,
         "null URI");
     proxyInfo = NuCypherExtNameNodeProxiesClient.createProxyWithNuCypherExtClientProtocol(conf,
         nameNodeUri, nnFallbackToSimpleAuth);
     // this.dtService = proxyInfo.getDelegationTokenService();
     this.namenode = proxyInfo.getProxy();
   }

   String localInterfaces[] =
       conf.getTrimmedStrings(DFS_CLIENT_LOCAL_INTERFACES);
   localInterfaceAddrs = getLocalInterfaceAddrs(localInterfaces);
   if (LOG.isDebugEnabled() && 0 != localInterfaces.length) {
     LOG.debug("Using local interfaces [" +
         Joiner.on(',').join(localInterfaces)+ "] with addresses [" +
         Joiner.on(',').join(localInterfaceAddrs) + "]");
   }
 }
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:65,代码来源:NuCypherExtClient.java


注:本文中的org.apache.hadoop.net.NetUtils.getSocketFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。