public static TTransport getSocketTransport(String host, int port, int loginTimeout) { return new TSocket(host, port, loginTimeout); }
private static TTransport createRaw(HostAndPort address, Optional<SSLContext> sslContext, Optional<HostAndPort> socksProxy, int timeoutMillis) throws TTransportException { Proxy proxy = socksProxy .map(socksAddress -> new Proxy(SOCKS, InetSocketAddress.createUnresolved(socksAddress.getHost(), socksAddress.getPort()))) .orElse(Proxy.NO_PROXY); Socket socket = new Socket(proxy); try { socket.connect(new InetSocketAddress(address.getHost(), address.getPort()), timeoutMillis); socket.setSoTimeout(timeoutMillis); if (sslContext.isPresent()) { // SSL will connect to the SOCKS address when present HostAndPort sslConnectAddress = socksProxy.orElse(address); socket = sslContext.get().getSocketFactory().createSocket(socket, sslConnectAddress.getHost(), sslConnectAddress.getPort(), true); } return new TSocket(socket); } catch (Throwable t) { // something went wrong, close the socket and rethrow try { socket.close(); } catch (IOException e) { t.addSuppressed(e); } throw new TTransportException(t); } }
return new TSocket(socket); } catch (Exception e) { throw new FlumeException("Could not connect to " + host + " on port " + port, e);
this.endpointPort = endpointPort; constructorT = classT.getConstructor(TProtocol.class, TProtocol.class); transport = new TSocket(endpointHost, endpointPort); LOG.debug("ThriftClient sokcet to " + endpointHost + ":" + endpointPort + " created."); TProtocol protocol = new TBinaryProtocol(transport);
includeProtocols, excludeCipherSuites, includeCipherSuites); } else { tsocket = new TSocket(hostname, port);
private static TSocket getSSLSocketWithHttps(TSocket tSSLSocket) throws TTransportException { SSLSocket sslSocket = (SSLSocket) tSSLSocket.getSocket(); SSLParameters sslParams = sslSocket.getSSLParameters(); sslParams.setEndpointIdentificationAlgorithm("HTTPS"); sslSocket.setSSLParameters(sslParams); return new TSocket(sslSocket); } }
private static TSocket getSSLSocketWithHttps(TSocket tSSLSocket) throws TTransportException { SSLSocket sslSocket = (SSLSocket) tSSLSocket.getSocket(); SSLParameters sslParams = sslSocket.getSSLParameters(); sslParams.setEndpointIdentificationAlgorithm("HTTPS"); sslSocket.setSSLParameters(sslParams); return new TSocket(sslSocket); }
public synchronized void reconnect() { close(); try { TSocket socket = new TSocket(host, port); if (timeout != null) { socket.setTimeout(timeout); } else { // @@@ Todo // set the socket default Timeout as xxxx } // locate login configuration Configuration login_conf = AuthUtils.GetConfiguration(conf); // construct a transport plugin ITransportPlugin transportPlugin = AuthUtils.GetTransportPlugin(type, conf, login_conf); final TTransport underlyingTransport = socket; // TODO get this from type instead of hardcoding to Nimbus. // establish client-server transport via plugin // do retries if the connect fails TBackoffConnect connectionRetry = new TBackoffConnect(Utils.getInt(conf.get(Config.STORM_NIMBUS_RETRY_TIMES)), Utils.getInt(conf.get(Config.STORM_NIMBUS_RETRY_INTERVAL)), Utils.getInt(conf.get(Config.STORM_NIMBUS_RETRY_INTERVAL_CEILING))); _transport = connectionRetry.doConnectWithRetry(transportPlugin, underlyingTransport, host, asUser); } catch (IOException ex) { throw new RuntimeException(ex); } _protocol = null; if (_transport != null) { _protocol = new TBinaryProtocol(_transport); } }
/** * Connect to Thrift Server. * * @throws TException the t exception */ public void connect() throws TException { transport = new TSocket(host, port); TProtocol protocol = new TBinaryProtocol(transport); TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, KaaThriftService.KAA_NODE_SERVICE.getServiceName()); client = new CliClient(mp); transport.open(); remoteServerName = client.serverName(); remoteMode = true; }
boolean framed = false; TTransport transport = new TSocket(host, port, timeout); if (framed) { transport = new TFramedTransport(transport);
this.intpEventServerHost = intpEventServerHost; if (!isTest) { TTransport transport = new TSocket(intpEventServerHost, intpEventServerPort); transport.open(); TProtocol protocol = new TBinaryProtocol(transport);
private void run() throws Exception { TTransport transport = new TSocket(host, port);
socket = TSSLTransportFactory.getClientSocket(hostname, cfg.port, cfg.timeoutMS, params); } else { socket = new TSocket(hostname, cfg.port, cfg.timeoutMS);
transport = new TSocket(store.getHost(), store.getPort(), clientSocketTimeout);
protected synchronized TTransport connect(HiveConf conf) throws HiveSQLException, TTransportException { if (transport != null && transport.isOpen()) { transport.close(); } String host = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_BIND_HOST); int port = conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT); LOG.info("Connecting to " + host + ":" + port); transport = new TSocket(host, port); ((TSocket) transport).setTimeout((int) conf.getTimeVar(HiveConf.ConfVars.SERVER_READ_SOCKET_TIMEOUT, TimeUnit.SECONDS) * 1000); try { ((TSocket) transport).getSocket().setKeepAlive(conf.getBoolVar(HiveConf.ConfVars.SERVER_TCP_KEEP_ALIVE)); } catch (SocketException e) { LOG.error("Error setting keep alive to " + conf.getBoolVar(HiveConf.ConfVars.SERVER_TCP_KEEP_ALIVE), e); } String userName = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_USER); String passwd = conf.getVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_PASSWORD); try { transport = PlainSaslHelper.getPlainTransport(userName, passwd, transport); } catch (SaslException e) { LOG.error("Error creating plain SASL transport", e); } TProtocol protocol = new TBinaryProtocol(transport); transport.open(); base = new ThriftCLIServiceClient(new TCLIService.Client(protocol), conf); LOG.info("Connected!"); return transport; }
transport = new TSocket(host, port, clientSocketTimeout); } else { String trustStorePath = MetastoreConf.getVar(conf, MetastoreConf.ConfVars.SSL_TRUSTSTORE_PATH).trim();
@Override public Pair<THBaseService.Client, TTransport> getClient() throws IOException { TSocket sock = new TSocket(connection.getHost(), connection.getPort()); sock.setSocketTimeout(connection.getOperationTimeout()); sock.setConnectTimeout(connection.getConnectTimeout()); TTransport tTransport = sock; if (connection.isFramed()) { tTransport = new TFramedTransport(tTransport); } try { sock.open(); } catch (TTransportException e) { throw new IOException(e); } TProtocol prot; if (connection.isCompact()) { prot = new TCompactProtocol(tTransport); } else { prot = new TBinaryProtocol(tTransport); } THBaseService.Client client = new THBaseService.Client(prot); return new Pair<>(client, tTransport); }
protected void talkToThriftServer() throws Exception { TSocket sock = new TSocket(InetAddress.getLocalHost().getHostName(), port); TTransport transport = sock; if (specifyFramed || implType.isAlwaysFramed) { transport = new TFramedTransport(transport); } sock.open(); try { TProtocol prot; if (specifyCompact) { prot = new TCompactProtocol(transport); } else { prot = new TBinaryProtocol(transport); } Hbase.Client client = new Hbase.Client(prot); if (!tableCreated){ TestThriftServer.createTestTables(client); tableCreated = true; } TestThriftServer.checkTableList(client); } finally { sock.close(); } }
transport = new TSocket(store.getHost(), store.getPort(), clientSocketTimeout);
@Override protected void talkToThriftServer() throws Exception { TSocket sock = new TSocket(InetAddress.getLocalHost().getHostName(), port); TTransport transport = sock;