/** * Create a transport that is not pooled * * @param address * Server address to open the transport to * @param context * RPC options */ public static TTransport createTransport(HostAndPort address, ClientContext context) throws TException { return createClientTransport(address, (int) context.getClientTimeoutInMillis(), context.getClientSslParams(), context.getSaslParams()); }
private TTransport createNewTransport(ThriftTransportKey cacheKey) throws TTransportException { TTransport transport = ThriftUtil.createClientTransport(cacheKey.getServer(), (int) cacheKey.getTimeout(), cacheKey.getSslParams(), cacheKey.getSaslParams()); log.trace("Creating new connection to connection to {}", cacheKey.getServer()); CachedTTransport tsc = new CachedTTransport(transport, cacheKey); CachedConnection cc = new CachedConnection(tsc); cc.reserve(); try { synchronized (this) { CachedConnections cachedConns = getCache().get(cacheKey); if (cachedConns == null) { cachedConns = new CachedConnections(); getCache().put(cacheKey, cachedConns); } cachedConns.reserved.put(cc.transport, cc); } } catch (TransportPoolShutdownException e) { cc.transport.close(); throw e; } return cc.transport; }
/** * Create a transport that is not pooled * * @param address * Server address to open the transport to * @param context * RPC options */ public static TTransport createTransport(HostAndPort address, ClientContext context) throws TException { return createClientTransport(address, (int) context.getClientTimeoutInMillis(), context.getClientSslParams(), context.getSaslParams()); }
private TTransport createNewTransport(ThriftTransportKey cacheKey) throws TTransportException { TTransport transport = ThriftUtil.createClientTransport(cacheKey.getServer(), (int) cacheKey.getTimeout(), cacheKey.getSslParams(), cacheKey.getSaslParams()); log.trace("Creating new connection to connection to {}", cacheKey.getServer()); CachedTTransport tsc = new CachedTTransport(transport, cacheKey); CachedConnection cc = new CachedConnection(tsc); cc.reserve(); try { synchronized (this) { CachedConnections cachedConns = getCache().get(cacheKey); if (cachedConns == null) { cachedConns = new CachedConnections(); getCache().put(cacheKey, cachedConns); } cachedConns.reserved.put(cc.transport, cc); } } catch (TransportPoolShutdownException e) { cc.transport.close(); throw e; } return cc.transport; }