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
ConstructorDescriptionClusterConnectionManager(Settings settings, Transport transport)
ClusterConnectionManager(ConnectionProfile connectionProfile, Transport transport)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener(TransportConnectionListener listener)
void
close()
void
void
connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, ConnectionManager.ConnectionValidator connectionValidator, ActionListener<Void> listener)
Connects to a node with the given connection profile.void
Disconnected 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.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
-
ClusterConnectionManager
-
ClusterConnectionManager
-
-
Method Details
-
addListener
- Specified by:
addListener
in interfaceConnectionManager
-
removeListener
- Specified by:
removeListener
in interfaceConnectionManager
-
openConnection
public void openConnection(DiscoveryNode node, ConnectionProfile connectionProfile, ActionListener<Transport.Connection> listener)- Specified by:
openConnection
in 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:
connectToNode
in 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:
getConnection
in interfaceConnectionManager
- Throws:
NodeNotConnectedException
- if the node is not connected- See Also:
connectToNode(DiscoveryNode, ConnectionProfile, ConnectionValidator, ActionListener)
-
nodeConnected
Returnstrue
if the node is connected.- Specified by:
nodeConnected
in interfaceConnectionManager
-
disconnectFromNode
Disconnected from the given node, if not connected, will do nothing.- Specified by:
disconnectFromNode
in interfaceConnectionManager
-
size
public int size()Returns the number of nodes this manager is connected to.- Specified by:
size
in interfaceConnectionManager
-
getAllConnectedNodes
- Specified by:
getAllConnectedNodes
in interfaceConnectionManager
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceConnectionManager
-
closeNoBlock
public void closeNoBlock()- Specified by:
closeNoBlock
in interfaceConnectionManager
-
getConnectionProfile
- Specified by:
getConnectionProfile
in interfaceConnectionManager
-