public HiveMetastoreClient create(String host, int port)
throws TTransportException
{
TTransport transport;
if (socksProxy == null) {
transport = new TTransportWrapper(new TSocket(host, port, (int) timeout.toMillis()), host);
transport.open();
}
else {
SocketAddress address = InetSocketAddress.createUnresolved(socksProxy.getHostText(), socksProxy.getPort());
Socket socks = new Socket(new Proxy(Proxy.Type.SOCKS, address));
try {
socks.connect(InetSocketAddress.createUnresolved(host, port), (int) timeout.toMillis());
socks.setSoTimeout(Ints.checkedCast(timeout.toMillis()));
}
catch (IOException e) {
throw rewriteException(new TTransportException(e), host);
}
try {
transport = new TTransportWrapper(new TSocket(socks), host);
}
catch (TTransportException e) {
throw rewriteException(e, host);
}
}