當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。