Class SiteToSiteClient.Builder

java.lang.Object
org.apache.nifi.remote.client.SiteToSiteClient.Builder
All Implemented Interfaces:
Serializable
Enclosing interface:
SiteToSiteClient

public static class SiteToSiteClient.Builder extends Object implements Serializable

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 Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • urls

      private Set<String> urls
    • timeoutNanos

      private long timeoutNanos
    • penalizationNanos

      private long penalizationNanos
    • idleExpirationNanos

      private long idleExpirationNanos
    • contentsCacheExpirationMillis

      private long contentsCacheExpirationMillis
    • sslContext

      private SSLContext sslContext
    • keystoreFilename

      private String keystoreFilename
    • keystorePass

      private String keystorePass
    • keystoreType

      private KeystoreType keystoreType
    • truststoreFilename

      private String truststoreFilename
    • truststorePass

      private String truststorePass
    • truststoreType

      private KeystoreType truststoreType
    • eventReporter

      private EventReporter eventReporter
    • peerPersistenceFile

      private File peerPersistenceFile
    • stateManager

      private StateManager stateManager
    • useCompression

      private boolean useCompression
    • portName

      private String portName
    • portIdentifier

      private String portIdentifier
    • batchCount

      private int batchCount
    • batchSize

      private long batchSize
    • batchNanos

      private long batchNanos
    • localAddress

      private InetAddress localAddress
    • transportProtocol

      private SiteToSiteTransportProtocol transportProtocol
    • httpProxy

      private HttpProxy 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

      public SiteToSiteClient.Builder url(String 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

      public SiteToSiteClient.Builder localAddress(InetAddress localAddress)

      Specifies the local address to use when communicating with the remote NiFi instance.

      Parameters:
      localAddress - the local address to use, or null to use anyLocal address.
      Returns:
      the builder
    • urls

      public SiteToSiteClient.Builder urls(Set<String> 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

      public SiteToSiteClient.Builder timeout(long timeout, TimeUnit unit)
      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 instances
      unit - unit of time over which to interpret the given timeout
      Returns:
      the builder
    • cacheExpiration

      public SiteToSiteClient.Builder 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.
      Parameters:
      expirationPeriod - the amount of time that an entry in the cache should expire
      unit - unit of time over which to interpret the given expirationPeriod
      Returns:
      the builder
    • idleExpiration

      public SiteToSiteClient.Builder 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. The default value is 30 seconds.
      Parameters:
      timeout - to use when interacting with remote instances
      unit - unit of time over which to interpret the given timeout
      Returns:
      the builder
    • nodePenalizationPeriod

      public SiteToSiteClient.Builder 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. 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 attempts
      unit - over which to evaluate the given period
      Returns:
      the builder
    • sslContext

      public SiteToSiteClient.Builder sslContext(SSLContext 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, the keystoreFilename(String), keystorePass(String), keystoreType, truststoreFilename, truststorePass(String), and truststoreType(KeystoreType) methods must be used instead.
      Parameters:
      sslContext - the context
      Returns:
      the builder
    • getKeystoreFilename

      public String getKeystoreFilename()
      Returns:
      the filename to use for the Keystore in order to communicate securely with the remote instance of NiFi
    • keystoreFilename

      public SiteToSiteClient.Builder keystoreFilename(String 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

      public String getKeystorePass()
      Returns:
      the password to use for the Keystore in order to communicate securely with the remote instance of NiFi
    • keystorePass

      public SiteToSiteClient.Builder keystorePass(String 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

      public KeystoreType getKeystoreType()
      Returns:
      the type of Keystore to use in order to communicate securely with the remote instance of NiFi
    • keystoreType

      public SiteToSiteClient.Builder keystoreType(KeystoreType 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

      public String getTruststoreFilename()
      Returns:
      the filename to use for the Truststore in order to communicate securely with the remote instance of NiFi
    • truststoreFilename

      public SiteToSiteClient.Builder truststoreFilename(String 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

      public String getTruststorePass()
      Returns:
      the password to use for the Truststore in order to communicate securely with the remote instance of NiFi
    • truststorePass

      public SiteToSiteClient.Builder truststorePass(String 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

      public KeystoreType getTruststoreType()
      Returns:
      the type of the Truststore to use in order to communicate securely with the remote instance of NiFi
    • truststoreType

      public SiteToSiteClient.Builder truststoreType(KeystoreType 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

      public SiteToSiteClient.Builder 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. The EventReporter provided must be threadsafe.
      Parameters:
      eventReporter - reporter
      Returns:
      the builder
    • peerPersistenceFile

      public SiteToSiteClient.Builder 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. 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

      public SiteToSiteClient.Builder 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. 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

      public SiteToSiteClient.Builder useCompression(boolean compress)
      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

      public SiteToSiteClient.Builder transportProtocol(SiteToSiteTransportProtocol transportProtocol)
      Specifies the protocol to use for site to site data transport.
      Parameters:
      transportProtocol - transport protocol
      Returns:
      the builder
    • portName

      public SiteToSiteClient.Builder portName(String 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

      public SiteToSiteClient.Builder portIdentifier(String 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

      public SiteToSiteClient.Builder requestBatchCount(int count)
      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 DataPackets to include in a Transaction.
      Parameters:
      count - client preferred batch size
      Returns:
      the builder
    • requestBatchSize

      public SiteToSiteClient.Builder requestBatchSize(long bytes)
      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

      public SiteToSiteClient.Builder requestBatchDuration(long value, TimeUnit unit)
      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 duration
      unit - client preferred batch duration unit
      Returns:
      the builder
    • buildConfig

      public SiteToSiteClientConfig buildConfig()
      Returns:
      a SiteToSiteClientConfig for the configured values but does not create a SiteToSiteClient
    • build

      public 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

      public String getUrl()
      Returns:
      the configured URL for the remote NiFi instance
    • getTimeout

      public long getTimeout(TimeUnit timeUnit)
      Parameters:
      timeUnit - unit over which to interpret the timeout
      Returns:
      the communications timeout
    • getIdleConnectionExpiration

      public long getIdleConnectionExpiration(TimeUnit timeUnit)
      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

      public long getPenalizationPeriod(TimeUnit timeUnit)
      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

      public SSLContext getSslContext()
      Returns:
      the SSL Context that is configured for this builder
    • getEventReporter

      public EventReporter getEventReporter()
      Returns:
      the EventReporter that is to be used by clients to report events
    • getPeerPersistenceFile

      public File 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

      public SiteToSiteTransportProtocol getTransportProtocol()
      Returns:
      the transport protocol to use, defaults to RAW
    • getPortName

      public String getPortName()
      Returns:
      the name of the port that the client is to communicate with
    • getPortIdentifier

      public String getPortIdentifier()
      Returns:
      the identifier of the port that the client is to communicate with
    • httpProxy

      public SiteToSiteClient.Builder httpProxy(HttpProxy 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

      public HttpProxy getHttpProxy()