當前位置: 首頁>>代碼示例>>Java>>正文


Java NetUtils.getDefaultSocketFactory方法代碼示例

本文整理匯總了Java中org.apache.hadoop.net.NetUtils.getDefaultSocketFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java NetUtils.getDefaultSocketFactory方法的具體用法?Java NetUtils.getDefaultSocketFactory怎麽用?Java NetUtils.getDefaultSocketFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.net.NetUtils的用法示例。


在下文中一共展示了NetUtils.getDefaultSocketFactory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProxyForAddress

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
private HAServiceProtocol getProxyForAddress(Configuration conf,
    int timeoutMs, InetSocketAddress addr) throws IOException {
  Configuration confCopy = new Configuration(conf);
  // Lower the timeout so we quickly fail to connect
  confCopy.setInt(
      CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, 1);
  SocketFactory factory = NetUtils.getDefaultSocketFactory(confCopy);
  return new HAServiceProtocolClientSideTranslatorPB(
      addr,
      confCopy, factory, timeoutMs);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:12,代碼來源:HAServiceTarget.java

示例2: getZKFCProxy

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
/**
 * @return a proxy to the ZKFC which is associated with this HA service.
 */
public ZKFCProtocol getZKFCProxy(Configuration conf, int timeoutMs)
    throws IOException {
  Configuration confCopy = new Configuration(conf);
  // Lower the timeout so we quickly fail to connect
  confCopy.setInt(CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, 1);
  SocketFactory factory = NetUtils.getDefaultSocketFactory(confCopy);
  return new ZKFCProtocolClientSideTranslatorPB(
      getZKFCAddress(),
      confCopy, factory, timeoutMs);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:14,代碼來源:HAServiceTarget.java

示例3: testSocketFactoryAsKeyInMap

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
@Test
public void testSocketFactoryAsKeyInMap() {
  Map<SocketFactory, Integer> dummyCache = new HashMap<SocketFactory, Integer>();
  int toBeCached1 = 1;
  int toBeCached2 = 2;
  Configuration conf = new Configuration();
  conf.set(CommonConfigurationKeys.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY,
      "org.apache.hadoop.ipc.TestSocketFactory$DummySocketFactory");
  final SocketFactory dummySocketFactory = NetUtils
      .getDefaultSocketFactory(conf);
  dummyCache.put(dummySocketFactory, toBeCached1);

  conf.set(CommonConfigurationKeys.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY,
      "org.apache.hadoop.net.StandardSocketFactory");
  final SocketFactory defaultSocketFactory = NetUtils
      .getDefaultSocketFactory(conf);
  dummyCache.put(defaultSocketFactory, toBeCached2);

  Assert
      .assertEquals("The cache contains two elements", 2, dummyCache.size());
  Assert.assertEquals("Equals of both socket factory shouldn't be same",
      defaultSocketFactory.equals(dummySocketFactory), false);

  assertSame(toBeCached2, dummyCache.remove(defaultSocketFactory));
  dummyCache.put(defaultSocketFactory, toBeCached2);
  assertSame(toBeCached1, dummyCache.remove(dummySocketFactory));

}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:29,代碼來源:TestSocketFactory.java

示例4: RpcClientImpl

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
/**
 * Used in test only. Construct an IPC client for the cluster {@code clusterId} with
 * the default SocketFactory
 */
@VisibleForTesting
RpcClientImpl(Configuration conf, String clusterId) {
  this(conf, clusterId, NetUtils.getDefaultSocketFactory(conf), null, null);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:RpcClientImpl.java

示例5: Client

import org.apache.hadoop.net.NetUtils; //導入方法依賴的package包/類
/**
 * Construct an IPC client with the default SocketFactory
 * @param valueClass
 * @param conf
 */
public Client(Class<? extends Writable> valueClass, Configuration conf) {
  this(valueClass, conf, NetUtils.getDefaultSocketFactory(conf));
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:9,代碼來源:Client.java


注:本文中的org.apache.hadoop.net.NetUtils.getDefaultSocketFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。