List of usage examples for org.apache.hadoop.net NetUtils getDefaultSocketFactory
public static SocketFactory getDefaultSocketFactory(Configuration conf)
From source file:backup.datanode.ipc.DataNodeBackupRPC.java
License:Apache License
public static DataNodeBackupRPC getDataNodeBackupRPC(InetSocketAddress dataNodeIPCAddress, Configuration conf, UserGroupInformation ugi) throws IOException, InterruptedException { int port = conf.getInt(DFS_BACKUP_DATANODE_RPC_PORT_KEY, DFS_BACKUP_DATANODE_RPC_PORT_DEFAULT); if (port == 0) { port = dataNodeIPCAddress.getPort() + 1; }/*from ww w. j a v a2s . c o m*/ InetSocketAddress dataNodeAddress = new InetSocketAddress(dataNodeIPCAddress.getAddress(), port); return RPC.getProtocolProxy(DataNodeBackupRPC.class, RPC.getProtocolVersion(DataNodeBackupRPC.class), dataNodeAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf)).getProxy(); }
From source file:backup.namenode.ipc.NameNodeBackupRPC.java
License:Apache License
public static NameNodeBackupRPC getDataNodeBackupRPC(InetSocketAddress nameNodeIPCAddres, Configuration conf, UserGroupInformation ugi) throws IOException, InterruptedException { int port = conf.getInt(DFS_BACKUP_NAMENODE_RPC_PORT_KEY, DFS_BACKUP_NAMENODE_RPC_PORT_DEFAULT); if (port == 0) { port = nameNodeIPCAddres.getPort() + 1; }/*from www .ja va 2s.co m*/ InetSocketAddress nameNodeAddress = new InetSocketAddress(nameNodeIPCAddres.getAddress(), port); return RPC.getProtocolProxy(NameNodeBackupRPC.class, RPC.getProtocolVersion(NameNodeBackupRPC.class), nameNodeAddress, ugi, conf, NetUtils.getDefaultSocketFactory(conf)).getProxy(); }
From source file:com.alibaba.wasp.ipc.WaspRPC.java
License:Apache License
/** * Construct a client-side proxy object with the default SocketFactory * * @param protocol/* w w w . jav a 2 s. c o m*/ * interface * @param clientVersion * version we are expecting * @param addr * remote address * @param conf * configuration * @param rpcTimeout * timeout for each RPC * @return a proxy instance * @throws java.io.IOException * e */ public static VersionedProtocol getProxy(Class<? extends VersionedProtocol> protocol, long clientVersion, InetSocketAddress addr, Configuration conf, int rpcTimeout) throws IOException { return getProxy(protocol, clientVersion, addr, conf, NetUtils.getDefaultSocketFactory(conf), rpcTimeout); }
From source file:com.datatorrent.stram.RecoverableRpcProxy.java
License:Apache License
private void connect() throws IOException { FSRecoveryHandler fsrh = new FSRecoveryHandler(appPath, conf); String uriStr = fsrh.readConnectUri(); if (!uriStr.equals(lastConnectURI)) { // reset timeout LOG.debug("Got new RPC connect address {}", uriStr); lastCompletedCallTms = System.currentTimeMillis(); lastConnectURI = uriStr;/* www . j a v a2s . c o m*/ } URI heartbeatUri = URI.create(uriStr); String queryStr = heartbeatUri.getQuery(); List<NameValuePair> queryList = null; if (queryStr != null) { queryList = URLEncodedUtils.parse(queryStr, Charset.defaultCharset()); } if (queryList != null) { for (NameValuePair pair : queryList) { String value = pair.getValue(); String key = pair.getName(); if (QP_rpcTimeout.equals(key)) { this.rpcTimeout = Integer.parseInt(value); } else if (QP_retryTimeoutMillis.equals(key)) { this.retryTimeoutMillis = Long.parseLong(value); } else if (QP_retryDelayMillis.equals(key)) { this.retryDelayMillis = Long.parseLong(value); } } } InetSocketAddress address = NetUtils.createSocketAddrForHost(heartbeatUri.getHost(), heartbeatUri.getPort()); umbilical = RPC.getProxy(StreamingContainerUmbilicalProtocol.class, StreamingContainerUmbilicalProtocol.versionID, address, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), rpcTimeout); }
From source file:com.hortonworks.hbase.replication.bridge.HBaseClient.java
License:Apache License
/** * Construct an IPC client with the default SocketFactory * @param valueClass value class/* w ww. ja va2s. co m*/ * @param conf configuration */ public HBaseClient(Class<? extends Writable> valueClass, Configuration conf) { this(valueClass, conf, NetUtils.getDefaultSocketFactory(conf)); }
From source file:com.splunk.shuttl.prototype.symlink.HadoopFileLocationPrototypeTest.java
License:Apache License
/** Create {@link ClientDatanodeProtocol} proxy using kerberos ticket */ public static ClientDatanodeProtocol createClientDatanodeProtocolProxy(DatanodeID datanodeid, Configuration conf, int socketTimeout) throws IOException { InetSocketAddress addr = NetUtils.createSocketAddr(datanodeid.getHost() + ":" + datanodeid.getIpcPort()); if (ClientDatanodeProtocol.LOG.isDebugEnabled()) { ClientDatanodeProtocol.LOG.info("ClientDatanodeProtocol addr=" + addr); }//from w w w . j a v a 2s . c o m return (ClientDatanodeProtocol) RPC.getProxy(ClientDatanodeProtocol.class, ClientDatanodeProtocol.versionID, addr, conf, NetUtils.getDefaultSocketFactory(conf), socketTimeout); }
From source file:com.sun.grid.herd.HerdLoadSensor.java
License:Open Source License
/** * Create a connection to the namenode./*from ww w. ja v a2 s.co m*/ * @param conf the Hadoop configuration * @return a handle to the namenode * @throws IOException Thrown if there is an error while communicating * with the namenode. */ private static NamenodeProtocol createNamenode(Configuration conf) throws IOException { InetSocketAddress address = NameNode.getAddress(conf); RetryPolicy timeoutPolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(3, 200, TimeUnit.MILLISECONDS); Map<String, RetryPolicy> policyMap = Collections.singletonMap("getBlocks", timeoutPolicy); UserGroupInformation info = null; try { info = UnixUserGroupInformation.login(conf); } catch (LoginException e) { throw new IOException(StringUtils.stringifyException(e)); } VersionedProtocol proxy = RPC.getProxy(NamenodeProtocol.class, NamenodeProtocol.versionID, address, info, conf, NetUtils.getDefaultSocketFactory(conf)); NamenodeProtocol ret = (NamenodeProtocol) RetryProxy.create(NamenodeProtocol.class, proxy, policyMap); return ret; }
From source file:com.taobao.adfs.distributed.rpc.Client.java
License:Apache License
/** * Construct an IPC client with the default SocketFactory * // w w w . j a va2s.co m * @param valueClass * @param conf */ public Client(Class<? extends Writable> valueClass, Configuration conf) { this(valueClass, conf, NetUtils.getDefaultSocketFactory(conf)); }
From source file:com.taobao.adfs.distributed.rpc.RPC.java
License:Apache License
/** * Construct a client-side proxy object with the default SocketFactory * /*from w w w. jav a 2s .c o m*/ * @param protocol * @param clientVersion * @param addr * @param conf * @return a proxy instance * @throws IOException */ public static VersionedProtocol getProxy(Class<?> protocol, long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException { return getProxy(protocol, clientVersion, addr, conf, NetUtils.getDefaultSocketFactory(conf)); }
From source file:com.thinkbiganalytics.nifi.security.ApplySecurityPolicy.java
License:Apache License
protected void checkHdfsUriForTimeout(Configuration config) throws IOException { URI hdfsUri = FileSystem.getDefaultUri(config); String address = hdfsUri.getAuthority(); int port = hdfsUri.getPort(); if (address == null || address.isEmpty() || port < 0) { return;/*from w ww . jav a 2 s. c o m*/ } InetSocketAddress namenode = NetUtils.createSocketAddr(address, port); SocketFactory socketFactory = NetUtils.getDefaultSocketFactory(config); Socket socket = null; try { socket = socketFactory.createSocket(); NetUtils.connect(socket, namenode, 1000); // 1 second timeout } finally { IOUtils.closeQuietly(socket); } }