Class HttpClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,PeerStatusProvider
,SiteToSiteClient
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.nifi.remote.client.SiteToSiteClient
SiteToSiteClient.Builder, SiteToSiteClient.StandardSiteToSiteClientConfig
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Set
<HttpClientTransaction> private static final org.slf4j.Logger
private final PeerSelector
private final ScheduledExecutorService
Fields inherited from class org.apache.nifi.remote.client.AbstractSiteToSiteClient
config, siteInfoProvider
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
createTransaction
(TransferDirection direction) Creates a new Transaction that can be used to either send data to a remote NiFi instance or receive data from a remote NiFi instance, depending on the value passed for thedirection
argument.fetchRemotePeerStatuses
(PeerDescription peerDescription) Fetch peer statuses from a remote NiFi cluster.private Set
<PeerStatus> fetchRemotePeerStatuses
(SiteToSiteRestApiClient apiClient) Returns a PeerDescription instance, which represents a bootstrap remote NiFi node.Returns the remote instance URIs.Returns the transport protocol being used.boolean
isSecure()
In order to determine whether the server is configured for secure communications, the client may have to query the server's RESTful interface.private String
resolveNodeApiUrl
(PeerDescription description) Methods inherited from class org.apache.nifi.remote.client.AbstractSiteToSiteClient
getConfig
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
taskExecutor
-
peerSelector
-
activeTransactions
-
-
Constructor Details
-
HttpClient
-
-
Method Details
-
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
-
fetchRemotePeerStatuses
private Set<PeerStatus> fetchRemotePeerStatuses(SiteToSiteRestApiClient apiClient) throws IOException - Throws:
IOException
-
createTransaction
Description copied from interface:SiteToSiteClient
Creates a new Transaction that can be used to either send data to a remote NiFi instance or receive data from a remote NiFi instance, depending on the value passed for the
direction
argument.Note: If all of the nodes are penalized (See
SiteToSiteClient.Builder.nodePenalizationPeriod(long, TimeUnit)
), then this method will returnnull
.- Specified by:
createTransaction
in interfaceSiteToSiteClient
- Parameters:
direction
- specifies which direction the data should be transferred. A value ofTransferDirection.SEND
indicates that this Transaction will send data to the remote instance; a value ofTransferDirection.RECEIVE
indicates that this Transaction will be used to receive data from the remote instance.- Returns:
- a Transaction to use for sending or receiving data, or
null
if all nodes are penalized. - Throws:
IOException
- ioe
-
resolveNodeApiUrl
-
isSecure
Description copied from interface:SiteToSiteClient
In order to determine whether the server is configured for secure communications, the client may have to query the server's RESTful interface. Doing so could result in an IOException.
- Specified by:
isSecure
in interfaceSiteToSiteClient
- Returns:
true
if site-to-site communications with the remote instance are secure,false
if site-to-site communications with the remote instance are not secure. Whether or not communications are secure depends on the server, not the client- Throws:
IOException
- if unable to query the remote instance's RESTful interface or if the remote instance is not configured to allow site-to-site communications
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getTransportProtocol
Description copied from interface:PeerStatusProvider
Returns the transport protocol being used.- Specified by:
getTransportProtocol
in interfacePeerStatusProvider
- Returns:
- the transport protocol
-