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 SummaryNested classes/interfaces inherited from interface org.elasticsearch.transport.ConnectionManagerConnectionManager.ConnectionValidator, ConnectionManager.DelegatingNodeConnectionListener
- 
Constructor SummaryConstructorsConstructorDescriptionClusterConnectionManager(Settings settings, Transport transport, ThreadContext threadContext) ClusterConnectionManager(ConnectionProfile connectionProfile, Transport transport, ThreadContext threadContext) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddListener(TransportConnectionListener listener) voidclose()voidvoidconnectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<Releasable> listener) Connects to the given node, or acquires another reference to an existing connection to the given node if a connection already exists.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- 
ClusterConnectionManagerpublic ClusterConnectionManager(Settings settings, Transport transport, ThreadContext threadContext) 
- 
ClusterConnectionManagerpublic ClusterConnectionManager(ConnectionProfile connectionProfile, Transport transport, ThreadContext threadContext) 
 
- 
- 
Method Details- 
addListener- Specified by:
- addListenerin interface- ConnectionManager
 
- 
removeListener- Specified by:
- removeListenerin interface- ConnectionManager
 
- 
openConnectionpublic void openConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener) - Specified by:
- openConnectionin interface- ConnectionManager
 
- 
connectToNodepublic void connectToNode(DiscoveryNode node, @Nullable ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<Releasable> listener) throws ConnectTransportException Connects to the given node, or acquires another reference to an existing connection to the given node if a connection already exists.- Specified by:
- connectToNodein interface- ConnectionManager
- Parameters:
- connectionProfile- the profile to use if opening a new connection. Only used in tests, this is- nullin production.
- connectionValidator- a callback to validate the connection before it is exposed (e.g. to- nodeConnected(org.elasticsearch.cluster.node.DiscoveryNode)).
- listener- completed on the calling thread or by the- ConnectionManager.ConnectionValidator; in production the- ConnectionManager.ConnectionValidatorwill complete the listener on the generic thread pool (see- TransportService.connectionValidator(org.elasticsearch.cluster.node.DiscoveryNode)). If successful, completed with a- Releasablewhich will release this connection (and close it if no other references to it are held).
- Throws:
- ConnectTransportException
 
- 
getConnectionReturns 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 interface- ConnectionManager
- Throws:
- NodeNotConnectedException- if the node is not connected
- See Also:
 
- 
nodeConnectedReturnstrueif the node is connected.- Specified by:
- nodeConnectedin interface- ConnectionManager
 
- 
disconnectFromNodeDisconnected from the given node, if not connected, will do nothing.- Specified by:
- disconnectFromNodein interface- ConnectionManager
 
- 
sizepublic int size()Returns the number of nodes this manager is connected to.- Specified by:
- sizein interface- ConnectionManager
 
- 
getAllConnectedNodes- Specified by:
- getAllConnectedNodesin interface- ConnectionManager
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- ConnectionManager
 
- 
closeNoBlockpublic void closeNoBlock()- Specified by:
- closeNoBlockin interface- ConnectionManager
 
- 
getConnectionProfile- Specified by:
- getConnectionProfilein interface- ConnectionManager
 
 
-