public class HttpClient extends AbstractSiteToSiteClient implements PeerStatusProvider
SiteToSiteClient.Builder, SiteToSiteClient.StandardSiteToSiteClientConfig| Modifier and Type | Field and Description |
|---|---|
private Set<HttpClientTransaction> |
activeTransactions |
private static org.slf4j.Logger |
logger |
private PeerSelector |
peerSelector |
private ScheduledExecutorService |
taskExecutor |
config, siteInfoProvider| Constructor and Description |
|---|
HttpClient(SiteToSiteClientConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
Transaction |
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 the
direction argument. |
Set<PeerStatus> |
fetchRemotePeerStatuses(PeerDescription peerDescription)
Fetch peer statuses from a remote NiFi cluster.
|
private Set<PeerStatus> |
fetchRemotePeerStatuses(SiteToSiteRestApiClient apiClient) |
PeerDescription |
getBootstrapPeerDescription()
Returns a PeerDescription instance, which represents a bootstrap remote NiFi node.
|
String |
getRemoteInstanceUris()
Returns the remote instance URIs.
|
SiteToSiteTransportProtocol |
getTransportProtocol()
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) |
getConfigprivate static final org.slf4j.Logger logger
private final ScheduledExecutorService taskExecutor
private final PeerSelector peerSelector
private final Set<HttpClientTransaction> activeTransactions
public HttpClient(SiteToSiteClientConfig config)
public PeerDescription getBootstrapPeerDescription() throws IOException
PeerStatusProviderReturns 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.
getBootstrapPeerDescription in interface PeerStatusProviderIOException - thrown when it fails to retrieve the bootstrap remote node informationpublic Set<PeerStatus> fetchRemotePeerStatuses(PeerDescription peerDescription) throws IOException
PeerStatusProviderfetchRemotePeerStatuses in interface PeerStatusProviderpeerDescription - a bootstrap node or one of query-able nodes lastly fetched successfullyIOException - thrown when it fails to fetch peer statuses of the remote cluster from the specified peerpublic String getRemoteInstanceUris()
PeerStatusProvidergetRemoteInstanceUris in interface PeerStatusProviderprivate Set<PeerStatus> fetchRemotePeerStatuses(SiteToSiteRestApiClient apiClient) throws IOException
IOExceptionpublic Transaction createTransaction(TransferDirection direction) throws IOException
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 return null.
createTransaction in interface SiteToSiteClientdirection - specifies which direction the data should be
transferred. A value of TransferDirection.SEND indicates that
this Transaction will send data to the remote instance; a value of
TransferDirection.RECEIVE indicates that this Transaction will be
used to receive data from the remote instance.null if all nodes are penalized.HandshakeException - hePortNotRunningException - pnreIOException - ioeUnknownPortException - upeprivate String resolveNodeApiUrl(PeerDescription description)
public boolean isSecure()
throws IOException
SiteToSiteClientIn 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.
isSecure in interface SiteToSiteClienttrue 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 clientIOException - if unable to query the remote instance's RESTful
interface or if the remote instance is not configured to allow
site-to-site communicationspublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic SiteToSiteTransportProtocol getTransportProtocol()
PeerStatusProvidergetTransportProtocol in interface PeerStatusProviderCopyright © 2023 Apache NiFi Project. All rights reserved.