Package org.elasticsearch.transport
Class ConnectionManager
java.lang.Object
org.elasticsearch.transport.ConnectionManager
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ConnectionManager
extends java.lang.Object
implements java.io.Closeable
This class manages node connections. The connection is opened by the underlying transport. Once the
connection is opened, this class manages the connection. This includes keep-alive pings and closing
the connection when the connection manager is closed.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceConnectionManager.ConnectionValidator -
Constructor Summary
Constructors Constructor Description ConnectionManager(Settings settings, Transport transport)ConnectionManager(ConnectionProfile connectionProfile, Transport transport) -
Method Summary
Modifier and Type Method Description voidaddListener(TransportConnectionListener listener)voidclose()voidcloseNoBlock()voidconnectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<java.lang.Void> listener)Connects to a node with the given connection profile.voiddisconnectFromNode(DiscoveryNode node)Disconnected from the given node, if not connected, will do nothing.java.util.Set<DiscoveryNode>getAllConnectedNodes()Transport.ConnectiongetConnection(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
-
Method Details
-
addListener
-
removeListener
-
openConnection
public void openConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener) -
connectToNode
public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<java.lang.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.- 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- Throws:
NodeNotConnectedException- if the node is not connected- See Also:
connectToNode(DiscoveryNode, ConnectionProfile, ConnectionValidator, ActionListener)
-
nodeConnected
Returnstrueif the node is connected. -
disconnectFromNode
Disconnected from the given node, if not connected, will do nothing. -
size
public int size()Returns the number of nodes this manager is connected to. -
getAllConnectedNodes
-
close
public void close()- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
closeNoBlock
public void closeNoBlock()
-