Package org.elasticsearch.transport
Class ClusterConnectionManager
java.lang.Object
org.elasticsearch.transport.ClusterConnectionManager
- All Implemented Interfaces:
Closeable,AutoCloseable,ConnectionManager
This class manages node connections within a cluster. The connection is opened by the underlying transport.
Once the connection is opened, this class manages the connection. This includes closing the connection when
the connection manager is closed.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.transport.ConnectionManager
ConnectionManager.ConnectionValidator, ConnectionManager.DelegatingNodeConnectionListener -
Constructor Summary
ConstructorsConstructorDescriptionClusterConnectionManager(Settings settings, Transport transport)ClusterConnectionManager(ConnectionProfile connectionProfile, Transport transport) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(TransportConnectionListener listener)voidclose()voidvoidconnectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<Void> listener)Connects to a node with the given connection profile.voidDisconnected from the given node, if not connected, will do nothing.getConnection(DiscoveryNode node)Returns a connection for the given node if the node is connected.booleannodeConnected(DiscoveryNode node)Returnstrueif the node is connected.voidopenConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener)voidremoveListener(TransportConnectionListener listener)intsize()Returns the number of nodes this manager is connected to.
-
Constructor Details
-
ClusterConnectionManager
-
ClusterConnectionManager
-
-
Method Details
-
addListener
- Specified by:
addListenerin interfaceConnectionManager
-
removeListener
- Specified by:
removeListenerin interfaceConnectionManager
-
openConnection
public void openConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener)- Specified by:
openConnectionin interfaceConnectionManager
-
connectToNode
public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<Void> listener) throws ConnectTransportExceptionConnects to a node with the given connection profile. If the node is already connected this method has no effect. Once a successful is established, it can be validated before being exposed. The ActionListener will be called on the calling thread or the generic thread pool.- Specified by:
connectToNodein interfaceConnectionManager- Throws:
ConnectTransportException
-
getConnection
Returns a connection for the given node if the node is connected. Connections returned from this method must not be closed. The lifecycle of this connection is maintained by this connection manager- Specified by:
getConnectionin interfaceConnectionManager- Throws:
NodeNotConnectedException- if the node is not connected- See Also:
connectToNode(DiscoveryNode, ConnectionProfile, ConnectionValidator, ActionListener)
-
nodeConnected
Returnstrueif the node is connected.- Specified by:
nodeConnectedin interfaceConnectionManager
-
disconnectFromNode
Disconnected from the given node, if not connected, will do nothing.- Specified by:
disconnectFromNodein interfaceConnectionManager
-
size
public int size()Returns the number of nodes this manager is connected to.- Specified by:
sizein interfaceConnectionManager
-
getAllConnectedNodes
- Specified by:
getAllConnectedNodesin interfaceConnectionManager
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceConnectionManager
-
closeNoBlock
public void closeNoBlock()- Specified by:
closeNoBlockin interfaceConnectionManager
-
getConnectionProfile
- Specified by:
getConnectionProfilein interfaceConnectionManager
-