Interface SiteToSiteClient
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractSiteToSiteClient
,HttpClient
,SocketClient
The SiteToSiteClient provides a mechanism for sending data to a remote instance of NiFi (or NiFi cluster) and retrieving data from a remote instance of NiFi (or NiFi cluster).
When configuring the client via the SiteToSiteClient.Builder
, the
Builder must be provided the URL of the remote NiFi instance. If the URL
points to a standalone instance of NiFi, all interaction will take place with
that instance of NiFi. However, if the URL points to the NiFi Cluster Manager
of a cluster, the client will automatically handle load balancing the
transactions across the different nodes in the cluster.
The SiteToSiteClient provides a Transaction
through which all
interaction with the remote instance takes place. After data has been
exchanged or it is determined that no data is available, the Transaction can
then be canceled (via the Transaction.cancel(String)
method) or can
be completed (via the Transaction.complete()
method).
An instance of SiteToSiteClient can be obtained by constructing a new
instance of the SiteToSiteClient.Builder
class, calling the
appropriate methods to configured the client as desired, and then calling the
build()
method.
The SiteToSiteClient itself is immutable once constructed and is thread-safe.
Many threads can share access to the same client. However, the
Transaction
that is created by the client is not thread safe and
should not be shared among threads.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
The Builder is the mechanism by which all configuration is passed to the SiteToSiteClient.static class
-
Method Summary
Modifier and TypeMethodDescriptioncreateTransaction
(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.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.
-
Method Details
-
createTransaction
Transaction createTransaction(TransferDirection direction) throws HandshakeException, PortNotRunningException, ProtocolException, UnknownPortException, IOException 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
.- 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:
HandshakeException
- hePortNotRunningException
- pnreIOException
- ioeUnknownPortException
- upeProtocolException
-
isSecure
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.
- 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
-
getConfig
SiteToSiteClientConfig getConfig()- Returns:
- the configuration object that was built by the Builder
-