Class CdpClientConfigurationBuilder


  • public class CdpClientConfigurationBuilder
    extends Object
    Class used to build an CdpClientConfiguration object.
    • Method Detail

      • withMaxConnections

        public CdpClientConfigurationBuilder withMaxConnections​(int maxConnections)
        Sets the maximum number of allowed open HTTP connections.
        Parameters:
        maxConnections - The maximum number of allowed open HTTP connections.
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together.
      • getMaxConnections

        public int getMaxConnections()
        Returns the maximum number of allowed open HTTP connections.
        Returns:
        The maximum number of allowed open HTTP connections.
      • withClientApplicationName

        public CdpClientConfigurationBuilder withClientApplicationName​(String clientApplicationName)
        Sets the client application name.
        Parameters:
        clientApplicationName - - Name of the the client application.
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together.
      • getClientApplicationName

        public String getClientApplicationName()
        Returns the client application name if set optionally by a customer or a partner application. This client application name would be used by Cloudera to derive metrics around CDP SDK adoption by different customers and partners.
        Returns:
        the client application name, if set, otherwise returns "" (empty string) by default
      • withConnectionTimeout

        public CdpClientConfigurationBuilder withConnectionTimeout​(Duration connectionTimeout)
        Sets the connection timeout on the underlying HTTP client.
        Parameters:
        connectionTimeout - the connection timeout
        Returns:
        the builder.
      • getConnectionTimeout

        public Duration getConnectionTimeout()
        Gets the connection timeout of the underlying HTTP connection.
        Returns:
        the connection timeout
      • withReadTimeout

        public CdpClientConfigurationBuilder withReadTimeout​(Duration readTimeout)
        Sets the read timeout on the underlying HTTP client.
        Parameters:
        readTimeout - the read timeout
        Returns:
        Returns a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getReadTimeout

        public Duration getReadTimeout()
        Gets the read timeout on the underlying HTTP client.
        Returns:
        the read timeout
      • withConnectionMaxIdle

        public CdpClientConfigurationBuilder withConnectionMaxIdle​(Duration connectionMaxIdle)
        Sets the maximum amount of time that an idle connection may sit in the connection pool and still be eligible for reuse. When retrieving a connection from the pool to make a request, the amount of time the connection has been idle is compared against this value. Connections which have been idle for longer are discarded, and if needed a new connection is created. Tuning this setting down reduces the likelihood of a race condition (wherein you begin sending a request down a connection which appears to be healthy, but before it arrives the service decides the connection has been idle for too long and closes it) at the cost of having to re-establish new connections more frequently. A non positive value disables this check.
        Parameters:
        connectionMaxIdle - the connectionMaxIdle value
        Returns:
        the builder.
      • getConnectionMaxIdle

        public Duration getConnectionMaxIdle()
        Returns the maximum amount of time that an idle connection may sit in the connection pool and still be eligible for reuse. When retrieving a connection from the pool to make a request, the amount of time the connection has been idle is compared against this value. Connections which have been idle for longer are discarded, and if needed a new connection is created. Tuning this setting down reduces the likelihood of a race condition (wherein you begin sending a request down a connection which appears to be healthy, but before it arrives the service decides the connection has been idle for too long and closes it) at the cost of having to re-establish new connections more frequently.
        Returns:
        the connection maximum idle time
      • withValidateAfterInactivity

        public CdpClientConfigurationBuilder withValidateAfterInactivity​(Duration validateAfterInactivity)
        Sets the amount of time that a connection can be idle in the connection pool before it must be validated to ensure it's still open. This "stale connection check" adds a small bit of overhead to validate the connection. Setting this value to larger values may increase the likelihood that the connection is not usable, potentially resulting in a NoHttpResponseException. Lowering this setting increases the overhead when leasing connections from the connection pool. A non positive value disables validation of connections.
        Parameters:
        validateAfterInactivity - the validateAfterInactivity value
        Returns:
        the builder.
      • getValidateAfterInactivity

        public Duration getValidateAfterInactivity()
        Returns the amount of time that a connection can be idle in the connection pool before it must be validated to ensure it's still open. This "stale connection check" adds a small bit of overhead to validate the connection. Setting this value to larger values may increase the likelihood that the connection is not usable, potentially resulting in a NoHttpResponseException. Lowering this setting increases the overhead when leasing connections from the connection pool. A non positive value disables validation of connections.
        Returns:
        the validate after inactivity duration
      • withRetryHandler

        public CdpClientConfigurationBuilder withRetryHandler​(RetryHandler retryHandler)
        Sets the value for RetryHandler. If none is set the SimpleRetryHandler is used. The retry handler determines whether or not to retry service operations in the event of a failure or exception.
        Parameters:
        retryHandler - The retry handler to use
        Returns:
        the current value of the flag as a boolean
      • getRetryHandler

        public RetryHandler getRetryHandler()
        Gets the current value of the retryHandler property.
        Returns:
        a RetryHandler object with the current value of the retryHandler property
      • withProxyUri

        public CdpClientConfigurationBuilder withProxyUri​(@Nullable
                                                          String proxyUri)
        Sets the value of the proxy URI. If not set or explicitly set to null, then no proxy will be used for connections. The string should be of the form: http(s)://hostname:port/
        Parameters:
        proxyUri - The Proxy URI
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getProxyUri

        public String getProxyUri()
        Gets the current proxy URI.
        Returns:
        the proxy URI
      • withProxyUsername

        public CdpClientConfigurationBuilder withProxyUsername​(@Nullable
                                                               String proxyUsername)
        Sets the value of the proxy username. If not set or explicitly set to null, the connection to the proxy will not be authenticated
        Parameters:
        proxyUsername - The Proxy Username
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getProxyUsername

        public String getProxyUsername()
        Gets the current proxy username.
        Returns:
        the proxy username
      • withProxyPassword

        public CdpClientConfigurationBuilder withProxyPassword​(@Nullable
                                                               String proxyPassword)
        Sets the value of the proxy password.
        Parameters:
        proxyPassword - The Proxy Password
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getProxyPassword

        public String getProxyPassword()
        Gets the current proxy password.
        Returns:
        the proxy password
      • withIgnoreTls

        public CdpClientConfigurationBuilder withIgnoreTls​(boolean ignoreTls)
        Sets the switch to ignore HTTPS verification errors.
        Parameters:
        ignoreTls - The switch to ignore HTTPS verification errors
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getIgnoreTls

        public boolean getIgnoreTls()
        Gets the switch to ignore HTTPS verification errors.
        Returns:
        the switch to ignore HTTPS verification errors
      • withTrustedCertificates

        public CdpClientConfigurationBuilder withTrustedCertificates​(List<X509Certificate> trustedCertificates)
        Sets the trusted certificates.
        Parameters:
        trustedCertificates - The trusted certificates
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • addTrustedCertificate

        public CdpClientConfigurationBuilder addTrustedCertificate​(X509Certificate trustedCertificate)
        Adds the trusted certificate.
        Parameters:
        trustedCertificate - The trusted certificate
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getTrustedCertificates

        public List<X509Certificate> getTrustedCertificates()
        Gets the trusted certificates.
        Returns:
        the trusted certificates
      • withRequestHeaders

        public CdpClientConfigurationBuilder withRequestHeaders​(Map<String,​String> requestHeaders)
        Sets the request headers.
        Parameters:
        requestHeaders - The request headers
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • addRequestHeader

        public CdpClientConfigurationBuilder addRequestHeader​(String name,
                                                              String value)
        Adds the request header.
        Parameters:
        name - The request header name
        value - The request header value
        Returns:
        a reference to the CdpClientConfiguration object so that method calls can be chained together
      • getRequestHeaders

        public Map<String,​String> getRequestHeaders()
        Gets the request headers.
        Returns:
        the request headers
      • defaultBuilder

        public static CdpClientConfigurationBuilder defaultBuilder()
        Gets an CdpClientConfigurationBuilder object with all the default values set.
        Returns:
        an CdpClientConfiguration object with default values for each property
      • build

        public CdpClientConfiguration build()
        Builds an CdpClientConfiguration object based on current settings.
        Returns:
        an CdpClientConfiguration object with current settings
      • toString

        public String toString()
        Builds an string representation of the CdpClientConfiguration object based on current settings.
        Overrides:
        toString in class Object
        Returns:
        a string with current settings