Package org.elasticsearch.transport
Class RemoteClusterConnection
- java.lang.Object
-
- org.elasticsearch.transport.RemoteClusterConnection
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,TransportConnectionListener
public final class RemoteClusterConnection extends java.lang.Object implements TransportConnectionListener, java.io.Closeable
Represents a connection to a single remote cluster. In contrast to a local cluster a remote cluster is not joined such that the current node is part of the cluster and it won't receive cluster state updates from the remote cluster. Remote clusters are also not fully connected with the current node. From a connection perspective a local cluster forms a bi-directional star network while in the remote case we only connect to a subset of the nodes in the cluster in an uni-directional fashion. This class also handles the discovery of nodes from the remote cluster. The initial list of seed nodes is only used to discover all nodes in the remote cluster and connects to all eligible nodes, for details seeRemoteClusterService.REMOTE_NODE_ATTRIBUTE
. In the case of a disconnection, this class will issue a re-connect task to establish at mostRemoteClusterService.REMOTE_CONNECTIONS_PER_CLUSTER
until either all eligible nodes are exhausted or the maximum number of connections per cluster has been reached.
-
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Integer>
REMOTE_MAX_PENDING_CONNECTION_LISTENERS
-
Method Summary
Modifier and Type Method Description void
close()
void
ensureConnected(ActionListener<java.lang.Void> voidActionListener)
Ensures that this cluster is connected.void
fetchSearchShards(ClusterSearchShardsRequest searchRequest, ActionListener<ClusterSearchShardsResponse> listener)
Fetches all shards for the search request from this remote connection.void
getConnectionInfo(ActionListener<RemoteConnectionInfo> listener)
Fetches connection info for this connectionjava.lang.String
getProxyAddress()
java.util.List<Tuple<java.lang.String,java.util.function.Supplier<DiscoveryNode>>>
getSeedNodes()
boolean
isClosed()
void
onNodeDisconnected(DiscoveryNode node)
Called once a node connection is closed and unregistered.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.transport.TransportConnectionListener
onConnectionClosed, onConnectionOpened, onNodeConnected
-
-
-
-
Field Detail
-
REMOTE_MAX_PENDING_CONNECTION_LISTENERS
public static final Setting<java.lang.Integer> REMOTE_MAX_PENDING_CONNECTION_LISTENERS
-
-
Method Detail
-
onNodeDisconnected
public void onNodeDisconnected(DiscoveryNode node)
Description copied from interface:TransportConnectionListener
Called once a node connection is closed and unregistered.- Specified by:
onNodeDisconnected
in interfaceTransportConnectionListener
-
fetchSearchShards
public void fetchSearchShards(ClusterSearchShardsRequest searchRequest, ActionListener<ClusterSearchShardsResponse> listener)
Fetches all shards for the search request from this remote connection. This is used to later run the search on the remote end.
-
ensureConnected
public void ensureConnected(ActionListener<java.lang.Void> voidActionListener)
Ensures that this cluster is connected. If the cluster is connected this operation will invoke the listener immediately.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
-
getProxyAddress
public java.lang.String getProxyAddress()
-
getSeedNodes
public java.util.List<Tuple<java.lang.String,java.util.function.Supplier<DiscoveryNode>>> getSeedNodes()
-
getConnectionInfo
public void getConnectionInfo(ActionListener<RemoteConnectionInfo> listener)
Fetches connection info for this connection
-
-