Class EndpointConnectionPool
- All Implemented Interfaces:
PeerStatusProvider
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate class
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Set
<EndpointConnection> private int
private final ConcurrentMap
<PeerDescription, BlockingQueue<EndpointConnection>> private final EventReporter
private final int
private final InetAddress
private static final org.slf4j.Logger
private final PeerSelector
private final RemoteDestination
private boolean
private final SiteInfoProvider
private static final SocketPeerIdentityProvider
private final SSLContext
private final ScheduledExecutorService
-
Constructor Summary
ConstructorDescriptionEndpointConnectionPool
(RemoteDestination remoteDestination, int commsTimeoutMillis, int idleExpirationMillis, SSLContext sslContext, EventReporter eventReporter, PeerPersistence peerPersistence, SiteInfoProvider siteInfoProvider, InetAddress localAddress) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
cleanup
(SocketClientProtocol protocol, Peer peer) private void
private CommunicationsSession
establishSiteToSiteConnection
(String hostname, int port) private CommunicationsSession
establishSiteToSiteConnection
(PeerStatus peerStatus) fetchRemotePeerStatuses
(PeerDescription peerDescription) Fetch peer statuses from a remote NiFi cluster.Returns a PeerDescription instance, which represents a bootstrap remote NiFi node.getEndpointConnection
(TransferDirection direction) getEndpointConnection
(TransferDirection direction, SiteToSiteClientConfig config) private String
getPortIdentifier
(TransferDirection transferDirection) Returns the remote instance URIs.Returns the transport protocol being used.boolean
offer
(EndpointConnection endpointConnection) void
shutdown()
void
terminate
(EndpointConnection connection) toString()
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
socketPeerIdentityProvider
-
connectionQueueMap
-
activeConnections
-
eventReporter
-
sslContext
-
taskExecutor
-
idleExpirationMillis
private final int idleExpirationMillis -
remoteDestination
-
commsTimeout
private volatile int commsTimeout -
shutdown
private volatile boolean shutdown -
siteInfoProvider
-
peerSelector
-
localAddress
-
-
Constructor Details
-
EndpointConnectionPool
public EndpointConnectionPool(RemoteDestination remoteDestination, int commsTimeoutMillis, int idleExpirationMillis, SSLContext sslContext, EventReporter eventReporter, PeerPersistence peerPersistence, SiteInfoProvider siteInfoProvider, InetAddress localAddress)
-
-
Method Details
-
getPortIdentifier
- Throws:
IOException
-
getEndpointConnection
- Throws:
IOException
-
getEndpointConnection
public EndpointConnection getEndpointConnection(TransferDirection direction, SiteToSiteClientConfig config) throws IOException - Throws:
IOException
-
offer
-
cleanup
-
getBootstrapPeerDescription
Description copied from interface:PeerStatusProvider
Returns a PeerDescription instance, which represents a bootstrap remote NiFi node. The bootstrap node is always used to fetch remote peer statuses.
Once the PeerSelector successfully got remote peer statuses, it periodically fetches remote peer statuses, so that it can detect remote NiFi cluster topology changes such as addition or removal of nodes. To refresh remote peer statuses, PeerSelector calls
PeerStatusProvider.fetchRemotePeerStatuses(org.apache.nifi.remote.PeerDescription)
with one of query-able nodes lastly fetched from the remote NiFi cluster, until it gets a successful result, or throws IOException if none of them responds successfully.This mechanism lets PeerSelector works even if the bootstrap remote NiFi node goes down.
- Specified by:
getBootstrapPeerDescription
in interfacePeerStatusProvider
- Returns:
- peer description of a bootstrap remote NiFi node
- Throws:
IOException
- thrown when it fails to retrieve the bootstrap remote node information
-
fetchRemotePeerStatuses
Description copied from interface:PeerStatusProvider
Fetch peer statuses from a remote NiFi cluster. Implementation of this method should fetch peer statuses from the node represented by the passed PeerDescription using its transport protocol.- Specified by:
fetchRemotePeerStatuses
in interfacePeerStatusProvider
- Parameters:
peerDescription
- a bootstrap node or one of query-able nodes lastly fetched successfully- Returns:
- Remote peer statuses
- Throws:
IOException
- thrown when it fails to fetch peer statuses of the remote cluster from the specified peer
-
getRemoteInstanceUris
Description copied from interface:PeerStatusProvider
Returns the remote instance URIs.- Specified by:
getRemoteInstanceUris
in interfacePeerStatusProvider
- Returns:
- the instance URIs
-
establishSiteToSiteConnection
private CommunicationsSession establishSiteToSiteConnection(PeerStatus peerStatus) throws IOException - Throws:
IOException
-
establishSiteToSiteConnection
private CommunicationsSession establishSiteToSiteConnection(String hostname, int port) throws IOException - Throws:
IOException
-
cleanupExpiredSockets
private void cleanupExpiredSockets() -
shutdown
public void shutdown() -
terminate
-
toString
-
getTransportProtocol
Description copied from interface:PeerStatusProvider
Returns the transport protocol being used.- Specified by:
getTransportProtocol
in interfacePeerStatusProvider
- Returns:
- the transport protocol
-