/** * Build the service. * * @param clusterSettings if non null, the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings * * updates for {@link TransportSettings#TRACE_LOG_EXCLUDE_SETTING} and {@link TransportSettings#TRACE_LOG_INCLUDE_SETTING}. */ public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor, Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings, Set<String> taskHeaders) { this(settings, transport, threadPool, transportInterceptor, localNodeFactory, clusterSettings, taskHeaders, new ConnectionManager(settings, transport, threadPool)); }
public void addConnectionListener(TransportConnectionListener listener) { connectionManager.addListener(listener); }
/** * 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; } connectionManager.connectToNode(node, connectionProfile, connectionValidator(node)); }
/** * Returns a connection to the remote cluster, preferably a direct connection to the provided {@link DiscoveryNode}. * If such node is not connected, the returned connection will be a proxy connection that redirects to it. */ Transport.Connection getConnection(DiscoveryNode remoteClusterNode) { if (connectionManager.nodeConnected(remoteClusterNode)) { return connectionManager.getConnection(remoteClusterNode); } DiscoveryNode discoveryNode = getAnyConnectedNode(); Transport.Connection connection = connectionManager.getConnection(discoveryNode); return new ProxyConnection(connection, remoteClusterNode); }
final TransportService.HandshakeResponse handshakeResponse; ConnectionProfile profile = ConnectionProfile.buildSingleChannelProfile(TransportRequestOptions.Type.REG); Transport.Connection connection = manager.openConnection(seedNode, profile); boolean success = false; try { try { ConnectionProfile connectionProfile = connectionManager.getConnectionProfile(); handshakeResponse = transportService.handshake(connection, connectionProfile.getHandshakeTimeout().millis(), (c) -> remoteClusterName.get() == null ? true : c.equals(remoteClusterName.get())); manager.connectToNode(handshakeNode, null, transportService.connectionValidator(handshakeNode)); if (remoteClusterName.get() == null) { assert handshakeResponse.getClusterName().value() != null;
ensureOpen(); try (Releasable ignored = connectionLock.acquire(node.getId())) { Transport.Connection connection = connectedNodes.get(node); connection = internalOpenConnection(node, resolvedProfile); connectionValidator.accept(connection, resolvedProfile);
/** * Returns either a real transport connection or a local node connection if we are using the local node optimization. * @throws NodeNotConnectedException if the given node is not connected */ public Transport.Connection getConnection(DiscoveryNode node) { if (isLocalNode(node)) { return localNodeConnection; } else { return connectionManager.getConnection(node); } }
proxyAddress); final TransportService.HandshakeResponse handshakeResponse; Transport.Connection connection = manager.openConnection(seedNode, ConnectionProfile.buildSingleChannelProfile(TransportRequestOptions.Type.REG, null, null)); boolean success = false; manager.connectToNode(handshakeNode, remoteProfile, transportService.connectionValidator(handshakeNode)); if (remoteClusterName.get() == null) { assert handshakeResponse.getClusterName().value() != null;
/** * Returns <code>true</code> iff the given node is already connected. */ public boolean nodeConnected(DiscoveryNode node) { return isLocalNode(node) || connectionManager.nodeConnected(node); }
public void disconnectFromNode(DiscoveryNode node) { if (isLocalNode(node)) { return; } connectionManager.disconnectFromNode(node); }
/** * Establishes and returns a new connection to the given node. The connection is NOT maintained by this service, it's the callers * responsibility to close the connection once it goes out of scope. * @param node the node to connect to * @param connectionProfile the connection profile to use */ public Transport.Connection openConnection(final DiscoveryNode node, ConnectionProfile connectionProfile) throws IOException { if (isLocalNode(node)) { return localNodeConnection; } else { return connectionManager.openConnection(node, connectionProfile); } }
public Transport.Connection openConnection(DiscoveryNode node, ConnectionProfile connectionProfile) { ConnectionProfile resolvedProfile = ConnectionProfile.resolveConnectionProfile(connectionProfile, defaultProfile); return internalOpenConnection(node, resolvedProfile); }
public void removeConnectionListener(TransportConnectionListener listener) { connectionManager.removeListener(listener); }
ensureOpen(); try (Releasable ignored = connectionLock.acquire(node.getId())) { Transport.Connection connection = connectedNodes.get(node); connection = internalOpenConnection(node, resolvedProfile); connectionValidator.accept(connection, resolvedProfile);
Transport.Connection getConnection() { return connectionManager.getConnection(getAnyConnectedNode()); }
/** * Returns a connection to the remote cluster, preferably a direct connection to the provided {@link DiscoveryNode}. * If such node is not connected, the returned connection will be a proxy connection that redirects to it. */ Transport.Connection getConnection(DiscoveryNode remoteClusterNode) { if (connectionManager.nodeConnected(remoteClusterNode)) { return connectionManager.getConnection(remoteClusterNode); } DiscoveryNode discoveryNode = getAnyConnectedNode(); Transport.Connection connection = connectionManager.getConnection(discoveryNode); return new ProxyConnection(connection, remoteClusterNode); }
final DiscoveryNode seedNode = seedNodes.next(); final TransportService.HandshakeResponse handshakeResponse; Transport.Connection connection = transportService.openConnection(seedNode, ConnectionProfile.buildSingleChannelProfile(TransportRequestOptions.Type.REG, null, null)); boolean success = false; transportService.connectToNode(handshakeNode, getRemoteProfile(handshakeResponse.getClusterName())); if (remoteClusterName.get() == null) { assert handshakeResponse.getClusterName().value() != null;
/** * Returns <code>true</code> iff the given node is already connected. */ public boolean nodeConnected(DiscoveryNode node) { return isLocalNode(node) || transport.nodeConnected(node); }
public void disconnectFromNode(DiscoveryNode node) { if (isLocalNode(node)) { return; } transport.disconnectFromNode(node); }
/** * Establishes and returns a new connection to the given node. The connection is NOT maintained by this service, it's the callers * responsibility to close the connection once it goes out of scope. * @param node the node to connect to * @param connectionProfile the connection profile to use */ public Transport.Connection openConnection(final DiscoveryNode node, ConnectionProfile connectionProfile) throws IOException { if (isLocalNode(node)) { return localNodeConnection; } else { return connectionManager.openConnection(node, connectionProfile); } }