@Override public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, CheckedBiConsumer<Connection, ConnectionProfile, IOException> connectionValidator) throws ConnectTransportException { transport.connectToNode(node, connectionProfile, connectionValidator); }
public void connectToNode(DiscoveryNode node) throws ConnectTransportException { if (node.equals(localNode)) { return; } transport.connectToNode(node); }
@Override public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, CheckedBiConsumer<Connection, ConnectionProfile, IOException> connectionValidator) throws ConnectTransportException { getTransport(node).connectToNode(node, connectionProfile, connectionValidator); }
@Override public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, CheckedBiConsumer<Connection, ConnectionProfile, IOException> connectionValidator) throws ConnectTransportException { if (original.nodeConnected(node)) { // connecting to an already connected node is a no-op return; } TimeValue delay = getDelay(); if (delay.millis() <= 0) { original.connectToNode(node, connectionProfile, connectionValidator); return; } // TODO: Replace with proper setting TimeValue connectingTimeout = TcpTransport.TCP_CONNECT_TIMEOUT.getDefault(Settings.EMPTY); try { if (delay.millis() < connectingTimeout.millis()) { Thread.sleep(delay.millis()); original.connectToNode(node, connectionProfile, connectionValidator); } else { Thread.sleep(connectingTimeout.millis()); throw new ConnectTransportException(node, "UNRESPONSIVE: simulated"); } } catch (InterruptedException e) { throw new ConnectTransportException(node, "UNRESPONSIVE: simulated"); } }
/** * Connect to the specified node with the given connection profile * * @param node the node to connect to * @param connectionProfile the connection profile to use when connecting to this node */ public void connectToNode(final DiscoveryNode node, ConnectionProfile connectionProfile) { if (isLocalNode(node)) { return; } transport.connectToNode(node, connectionProfile, (newConnection, actualProfile) -> { // We don't validate cluster names to allow for tribe node connections. final DiscoveryNode remote = handshake(newConnection, actualProfile.getHandshakeTimeout().millis(), cn -> true); if (node.equals(remote) == false) { throw new ConnectTransportException(node, "handshake failed. unexpected remote node " + remote); } }); }