本文整理匯總了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);
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}