Class SiteToSiteClient.Builder
- All Implemented Interfaces:
Serializable
- Enclosing interface:
SiteToSiteClient
The Builder is the mechanism by which all configuration is passed to the
SiteToSiteClient. Once constructed, the SiteToSiteClient cannot be
reconfigured (i.e., it is immutable). If a change in configuration should
be desired, the client should be closed
and a
new client created.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private long
private long
private long
private EventReporter
private HttpProxy
private long
private String
private String
private KeystoreType
private InetAddress
private File
private long
private String
private String
private static final long
private SSLContext
private StateManager
private long
private SiteToSiteTransportProtocol
private String
private String
private KeystoreType
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
cacheExpiration
(long expirationPeriod, TimeUnit unit) Specifies how long the contents of a remote NiFi instance should be cached before making another web request to the remote instance.eventReporter
(EventReporter eventReporter) Provides an EventReporter that can be used by the client in order to report any events that could be of interest when communicating with the remote instance.fromConfig
(SiteToSiteClientConfig config) Populates the builder with values from the provided configlong
getIdleConnectionExpiration
(TimeUnit timeUnit) long
getPenalizationPeriod
(TimeUnit timeUnit) long
getTimeout
(TimeUnit timeUnit) getUrl()
Specify a HTTP proxy information to use with HTTP protocol of Site-to-Site communication.idleExpiration
(long timeout, TimeUnit unit) Specifies the amount of time that a connection can remain idle in the connection pool before it is "expired" and shutdown.boolean
keystoreFilename
(String keystoreFilename) Sets the filename to use for the Keystore in order to communicate securely with the remote instance of NiFikeystorePass
(String keystorePass) Sets the password to use for the Keystore in order to communicate securely with the remote instance of NiFikeystoreType
(KeystoreType keystoreType) Sets the type of the Keystore to use in order to communicate securely with the remote instance of NiFilocalAddress
(InetAddress localAddress) Specifies the local address to use when communicating with the remote NiFi instance.nodePenalizationPeriod
(long period, TimeUnit unit) If there is a problem communicating with a node (i.e., any node in the remote NiFi cluster or the remote instance of NiFi if it is standalone), specifies how long the client should wait before attempting to communicate with that node again.peerPersistenceFile
(File peerPersistenceFile) Specifies a file that the client can write to in order to persist the list of nodes in the remote cluster and recover the list of nodes upon restart.portIdentifier
(String portIdentifier) Specifies the unique identifier of the port to communicate with.Specifies the name of the port to communicate with.requestBatchCount
(int count) When pulling data from a NiFi instance, the sender chooses how large a Transaction is.requestBatchDuration
(long value, TimeUnit unit) When pulling data from a NiFi instance, the sender chooses how large a Transaction is.requestBatchSize
(long bytes) When pulling data from a NiFi instance, the sender chooses how large a Transaction is.sslContext
(SSLContext sslContext) Specifies the SSL Context to use when communicating with the remote NiFi instance(s).stateManager
(StateManager stateManager) Specifies StateManager that the client can persist the list of nodes in the remote cluster and recover the list of nodes upon restart.Specifies the communications timeouts to use when interacting with the remote instances.transportProtocol
(SiteToSiteTransportProtocol transportProtocol) Specifies the protocol to use for site to site data transport.truststoreFilename
(String truststoreFilename) Sets the filename to use for the Truststore in order to communicate securely with the remote instance of NiFitruststorePass
(String truststorePass) Sets the password to use for the Truststore in order to communicate securely with the remote instance of NiFitruststoreType
(KeystoreType truststoreType) Sets the password type of the Truststore to use in order to communicate securely with the remote instance of NiFiSpecifies the URL of the remote NiFi instance.Specifies the URLs of the remote NiFi instance.useCompression
(boolean compress) Specifies whether or not data should be compressed before being transferred to or from the remote instance.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
urls
-
timeoutNanos
private long timeoutNanos -
penalizationNanos
private long penalizationNanos -
idleExpirationNanos
private long idleExpirationNanos -
contentsCacheExpirationMillis
private long contentsCacheExpirationMillis -
sslContext
-
keystoreFilename
-
keystorePass
-
keystoreType
-
truststoreFilename
-
truststorePass
-
truststoreType
-
eventReporter
-
peerPersistenceFile
-
stateManager
-
useCompression
private boolean useCompression -
portName
-
portIdentifier
-
batchCount
private int batchCount -
batchSize
private long batchSize -
batchNanos
private long batchNanos -
localAddress
-
transportProtocol
-
httpProxy
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
fromConfig
Populates the builder with values from the provided config- Parameters:
config
- to start with- Returns:
- the builder
-
url
Specifies the URL of the remote NiFi instance.
If this URL points to a NiFi node in a NiFi cluster, data transfer to and from nodes will be automatically load balanced across the different nodes.
For better connectivity with a NiFi cluster, use
urls(Set)
instead.- Parameters:
url
- url of remote instance- Returns:
- the builder
-
localAddress
Specifies the local address to use when communicating with the remote NiFi instance.
- Parameters:
localAddress
- the local address to use, ornull
to useanyLocal
address.- Returns:
- the builder
-
urls
Specifies the URLs of the remote NiFi instance.
If this URL points to a NiFi node in a NiFi cluster, data transfer to and from nodes will be automatically load balanced across the different nodes.
Multiple urls provide better connectivity with a NiFi cluster, able to connect to the target cluster at long as one of the specified urls is accessible.
- Parameters:
urls
- urls of remote instance- Returns:
- the builder
-
timeout
Specifies the communications timeouts to use when interacting with the remote instances. The default value is 30 seconds.- Parameters:
timeout
- to use when interacting with remote instancesunit
- unit of time over which to interpret the given timeout- Returns:
- the builder
-
cacheExpiration
Specifies how long the contents of a remote NiFi instance should be cached before making another web request to the remote instance.- Parameters:
expirationPeriod
- the amount of time that an entry in the cache should expireunit
- unit of time over which to interpret the given expirationPeriod- Returns:
- the builder
-
idleExpiration
Specifies the amount of time that a connection can remain idle in the connection pool before it is "expired" and shutdown. The default value is 30 seconds.- Parameters:
timeout
- to use when interacting with remote instancesunit
- unit of time over which to interpret the given timeout- Returns:
- the builder
-
nodePenalizationPeriod
If there is a problem communicating with a node (i.e., any node in the remote NiFi cluster or the remote instance of NiFi if it is standalone), specifies how long the client should wait before attempting to communicate with that node again. While a particular node is penalized, all other nodes in the remote cluster (if any) will still be available for communication. The default value is 3 seconds.- Parameters:
period
- time to wait between communication attemptsunit
- over which to evaluate the given period- Returns:
- the builder
-
sslContext
Specifies the SSL Context to use when communicating with the remote NiFi instance(s). If not specified, communications will not be secure. The remote instance of NiFi always determines whether or not Site-to-Site communications are secure (i.e., the client will always use secure or non-secure communications, depending on what the server dictates). Note: The SSLContext provided by this method will be ignored if using a Serializable Configuration If a Serializable Configuration is required and communications are to be secure, thekeystoreFilename(String)
,keystorePass(String)
,keystoreType
,truststoreFilename
,truststorePass(String)
, andtruststoreType(KeystoreType)
methods must be used instead.- Parameters:
sslContext
- the context- Returns:
- the builder
-
getKeystoreFilename
- Returns:
- the filename to use for the Keystore in order to communicate securely with the remote instance of NiFi
-
keystoreFilename
Sets the filename to use for the Keystore in order to communicate securely with the remote instance of NiFi- Parameters:
keystoreFilename
- the filename to use for the Keystore in order to communicate securely with the remote instance of NiFi- Returns:
- the builder
-
getKeystorePass
- Returns:
- the password to use for the Keystore in order to communicate securely with the remote instance of NiFi
-
keystorePass
Sets the password to use for the Keystore in order to communicate securely with the remote instance of NiFi- Parameters:
keystorePass
- the password to use for the Keystore in order to communicate securely with the remote instance of NiFi- Returns:
- the builder
-
getKeystoreType
- Returns:
- the type of Keystore to use in order to communicate securely with the remote instance of NiFi
-
keystoreType
Sets the type of the Keystore to use in order to communicate securely with the remote instance of NiFi- Parameters:
keystoreType
- the type of the Keystore to use in order to communicate securely with the remote instance of NiFi- Returns:
- the builder
-
getTruststoreFilename
- Returns:
- the filename to use for the Truststore in order to communicate securely with the remote instance of NiFi
-
truststoreFilename
Sets the filename to use for the Truststore in order to communicate securely with the remote instance of NiFi- Parameters:
truststoreFilename
- the filename to use for the Truststore in order to communicate securely with the remote instance of NiFi- Returns:
- the builder
-
getTruststorePass
- Returns:
- the password to use for the Truststore in order to communicate securely with the remote instance of NiFi
-
truststorePass
Sets the password to use for the Truststore in order to communicate securely with the remote instance of NiFi- Parameters:
truststorePass
- the filename to use for the Truststore in order to communicate securely with the remote instance of NiFi
-
getTruststoreType
- Returns:
- the type of the Truststore to use in order to communicate securely with the remote instance of NiFi
-
truststoreType
Sets the password type of the Truststore to use in order to communicate securely with the remote instance of NiFi- Parameters:
truststoreType
- the type of the Truststore to use in order to communicate securely with the remote instance of NiFi- Returns:
- the builder
-
eventReporter
Provides an EventReporter that can be used by the client in order to report any events that could be of interest when communicating with the remote instance. The EventReporter provided must be threadsafe.- Parameters:
eventReporter
- reporter- Returns:
- the builder
-
peerPersistenceFile
Specifies a file that the client can write to in order to persist the list of nodes in the remote cluster and recover the list of nodes upon restart. This allows the client to function if the remote nodes specified by the urls are unavailable, even after a restart of the client software. If not specified, the list of nodes will not be persisted and a failure of the Cluster Manager will result in not being able to communicate with the remote instance if a new client is created.- Parameters:
peerPersistenceFile
- file- Returns:
- the builder
-
stateManager
Specifies StateManager that the client can persist the list of nodes in the remote cluster and recover the list of nodes upon restart. This allows the client to function if the remote nodes specified by the urls are unavailable, even after a restart of the client software. If not specified, the list of nodes will not be persisted and a failure of the Cluster Manager will result in not being able to communicate with the remote instance if a new client is created.
Using a StateManager is preferable over using a File to persist the list of nodes if the SiteToSiteClient is used by a NiFi component having access to a NiFi context. So that the list of nodes can be persisted in the same manner with other stateful information.
Since StateManager is not serializable, the specified StateManager will not be serialized, and a de-serialized SiteToSiteClientConfig instance will not have StateManager even if the original config has one. Use
peerPersistenceFile(File)
instead if the same SiteToSiteClientConfig needs to be distributed among multiple clients via serialization, and also persistent connectivity is required in case of having no available remote node specified by the urls when a client restarts.- Parameters:
stateManager
- state manager- Returns:
- the builder
-
useCompression
Specifies whether or not data should be compressed before being transferred to or from the remote instance.- Parameters:
compress
- true if should compress- Returns:
- the builder
-
transportProtocol
Specifies the protocol to use for site to site data transport.- Parameters:
transportProtocol
- transport protocol- Returns:
- the builder
-
portName
Specifies the name of the port to communicate with. Either the port name or the port identifier must be specified.- Parameters:
portName
- name of port- Returns:
- the builder
-
portIdentifier
Specifies the unique identifier of the port to communicate with. If it is known, this is preferred over providing the port name, as the port name may change.- Parameters:
portIdentifier
- identifier of port- Returns:
- the builder
-
requestBatchCount
When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, the client has the ability to request a particular batch size/duration. This method specifies the preferred number ofDataPacket
s to include in a Transaction.- Parameters:
count
- client preferred batch size- Returns:
- the builder
-
requestBatchSize
When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, the client has the ability to request a particular batch size/duration. This method specifies the preferred number of bytes to include in a Transaction.- Parameters:
bytes
- client preferred batch size- Returns:
- the builder
-
requestBatchDuration
When pulling data from a NiFi instance, the sender chooses how large a Transaction is. However, the client has the ability to request a particular batch size/duration. This method specifies the preferred amount of time that a Transaction should span.- Parameters:
value
- client preferred batch durationunit
- client preferred batch duration unit- Returns:
- the builder
-
buildConfig
- Returns:
- a
SiteToSiteClientConfig
for the configured values but does not create a SiteToSiteClient
-
build
- Returns:
- a new SiteToSiteClient that can be used to send and receive data with remote instances of NiFi
- Throws:
IllegalStateException
- if either the url is not set or neither the port name nor port identifier is set, or if the transport protocol is not supported.
-
getUrl
- Returns:
- the configured URL for the remote NiFi instance
-
getTimeout
- Parameters:
timeUnit
- unit over which to interpret the timeout- Returns:
- the communications timeout
-
getIdleConnectionExpiration
- Parameters:
timeUnit
- unit over which to interpret the time- Returns:
- the amount of of time that a connection can remain idle in the connection pool before being shutdown
-
getPenalizationPeriod
- Parameters:
timeUnit
- unit of reported time- Returns:
- the amount of time that a particular node will be ignored after a communications error with that node occurs
-
getSslContext
- Returns:
- the SSL Context that is configured for this builder
-
getEventReporter
- Returns:
- the EventReporter that is to be used by clients to report events
-
getPeerPersistenceFile
- Returns:
- the file that is to be used for persisting the nodes of a remote cluster, if any
-
isUseCompression
public boolean isUseCompression()- Returns:
- a boolean indicating whether or not compression will be used to transfer data to and from the remote instance
-
getTransportProtocol
- Returns:
- the transport protocol to use, defaults to RAW
-
getPortName
- Returns:
- the name of the port that the client is to communicate with
-
getPortIdentifier
- Returns:
- the identifier of the port that the client is to communicate with
-
httpProxy
Specify a HTTP proxy information to use with HTTP protocol of Site-to-Site communication.- Parameters:
httpProxy
- HTTP proxy information- Returns:
- the builder
-
getHttpProxy
-