public OutboundTcpConnectionPool getConnectionPool(InetAddress to) { OutboundTcpConnectionPool cp = connectionManagers.get(to); if (cp == null) { cp = new OutboundTcpConnectionPool(to); OutboundTcpConnectionPool existingPool = connectionManagers.putIfAbsent(to, cp); if (existingPool != null) cp = existingPool; else cp.start(); } cp.waitForStarted(); return cp; }
public void destroyConnectionPool(InetAddress to) { OutboundTcpConnectionPool cp = connectionManagers.get(to); if (cp == null) return; cp.close(); connectionManagers.remove(to); }
private void reconnect(InetAddress publicAddress, InetAddress localAddress) { if (snitch.getDatacenter(publicAddress).equals(localDc) && !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress)) { MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress); logger.debug(String.format("Intiated reconnect to an Internal IP %s for the %s", localAddress, publicAddress)); } }
/** * called from gossiper when it notices a node is not responding. */ public void convict(InetAddress ep) { logger.trace("Resetting pool for {}", ep); getConnectionPool(ep).reset(); }
public Map<String, Long> getTimeoutsPerHost() { Map<String, Long> result = new HashMap<String, Long>(connectionManagers.size()); for (Map.Entry<InetAddress, OutboundTcpConnectionPool> entry: connectionManagers.entrySet()) { String ip = entry.getKey().getHostAddress(); long recent = entry.getValue().getTimeouts(); result.put(ip, recent); } return result; }
public OutboundTcpConnection getConnection(InetAddress to, MessageOut msg) { return getConnectionPool(to).getConnection(msg); }
@SuppressWarnings("resource") // Closing the socket will close the underlying channel. public static Socket newSocket(InetAddress endpoint) throws IOException { // zero means 'bind on any available port.' if (isEncryptedChannel(endpoint)) { return SSLFactory.getSocket(DatabaseDescriptor.getServerEncryptionOptions(), endpoint, DatabaseDescriptor.getSSLStoragePort()); } else { SocketChannel channel = SocketChannel.open(); channel.connect(new InetSocketAddress(endpoint, DatabaseDescriptor.getStoragePort())); return channel.socket(); } }
try socket = OutboundTcpConnectionPool.newSocket(peer); socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout()); socket.setKeepAlive(true);
private void reconnect(InetAddress publicAddress, InetAddress localAddress) { if (snitch.getDatacenter(publicAddress).equals(localDc) && !MessagingService.instance().getConnectionPool(publicAddress).endPoint().equals(localAddress)) { MessagingService.instance().getConnectionPool(publicAddress).reset(localAddress); logger.debug("Initiated reconnect to an Internal IP {} for the {}", localAddress, publicAddress); } }
/** * called from gossiper when it notices a node is not responding. */ public void convict(InetAddress ep) { logger.trace("Resetting pool for {}", ep); getConnectionPool(ep).reset(); }
public Map<String, Long> getTimeoutsPerHost() { Map<String, Long> result = new HashMap<String, Long>(connectionManagers.size()); for (Map.Entry<InetAddress, OutboundTcpConnectionPool> entry: connectionManagers.entrySet()) { String ip = entry.getKey().getHostAddress(); long recent = entry.getValue().getTimeouts(); result.put(ip, recent); } return result; }
public OutboundTcpConnection getConnection(InetAddress to, MessageOut msg) { return getConnectionPool(to).getConnection(msg); }
@SuppressWarnings("resource") // Closing the socket will close the underlying channel. public static Socket newSocket(InetAddress endpoint) throws IOException { // zero means 'bind on any available port.' if (isEncryptedChannel(endpoint)) { return SSLFactory.getSocket(DatabaseDescriptor.getServerEncryptionOptions(), endpoint, DatabaseDescriptor.getSSLStoragePort()); } else { SocketChannel channel = SocketChannel.open(); channel.connect(new InetSocketAddress(endpoint, DatabaseDescriptor.getStoragePort())); return channel.socket(); } }
Socket socket = OutboundTcpConnectionPool.newSocket(peer); socket.setSoTimeout(DatabaseDescriptor.getStreamingSocketTimeout()); socket.setKeepAlive(true);
public OutboundTcpConnectionPool getConnectionPool(InetAddress to) { OutboundTcpConnectionPool cp = connectionManagers.get(to); if (cp == null) { cp = new OutboundTcpConnectionPool(to, backPressure.newState(to)); OutboundTcpConnectionPool existingPool = connectionManagers.putIfAbsent(to, cp); if (existingPool != null) cp = existingPool; else cp.start(); } cp.waitForStarted(); return cp; }