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 interface
ConnectionManager.ConnectionValidator
-
Constructor Summary
Constructors Constructor Description ConnectionManager(Settings settings, Transport transport)
ConnectionManager(ConnectionProfile connectionProfile, Transport transport)
-
Method Summary
Modifier and Type Method Description void
addListener(TransportConnectionListener listener)
void
close()
void
closeNoBlock()
void
connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<java.lang.Void> listener)
Connects to a node with the given connection profile.void
disconnectFromNode(DiscoveryNode node)
Disconnected from the given node, if not connected, will do nothing.java.util.Set<DiscoveryNode>
getAllConnectedNodes()
Transport.Connection
getConnection(DiscoveryNode node)
Returns a connection for the given node if the node is connected.boolean
nodeConnected(DiscoveryNode node)
Returnstrue
if the node is connected.void
openConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener)
void
removeListener(TransportConnectionListener listener)
int
size()
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
Returnstrue
if 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
closeNoBlock
public void closeNoBlock()
-