Package com.cloudera.cdp.client
Class CdpClientConfigurationBuilder
java.lang.Object
com.cloudera.cdp.client.CdpClientConfigurationBuilder
Class used to build an CdpClientConfiguration object.
-
Method Summary
Modifier and TypeMethodDescriptionaddRequestHeader
(String name, String value) Adds the request header.addTrustedCertificate
(X509Certificate trustedCertificate) Adds the trusted certificate.build()
Builds an CdpClientConfiguration object based on current settings.Gets an CdpClientConfigurationBuilder object with all the default values set.Returns the client application name if set optionally by a customer or a partner application.Returns the maximum amount of time that an idle connection may sit in the connection pool and still be eligible for reuse.Gets the connection timeout of the underlying HTTP connection.boolean
Gets the switch to ignore HTTPS verification errors.int
Returns the maximum number of allowed open HTTP connections.Gets the current proxy password.Gets the current proxy URI.Gets the current proxy username.Gets the read timeout on the underlying HTTP client.Gets the request headers.Gets the current value of the retryHandler property.Gets the trusted certificates.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.toString()
Builds an string representation of the CdpClientConfiguration object based on current settings.withClientApplicationName
(String clientApplicationName) Sets the client application name.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.withConnectionTimeout
(Duration connectionTimeout) Sets the connection timeout on the underlying HTTP client.withIgnoreTls
(boolean ignoreTls) Sets the switch to ignore HTTPS verification errors.withMaxConnections
(int maxConnections) Sets the maximum number of allowed open HTTP connections.withProxyPassword
(String proxyPassword) Sets the value of the proxy password.withProxyUri
(String proxyUri) Sets the value of the proxy URI.withProxyUsername
(String proxyUsername) Sets the value of the proxy username.withReadTimeout
(Duration readTimeout) Sets the read timeout on the underlying HTTP client.withRequestHeaders
(Map<String, String> requestHeaders) Sets the request headers.withRetryHandler
(RetryHandler retryHandler) Sets the value for RetryHandler.withTrustedCertificates
(List<X509Certificate> trustedCertificates) Sets the trusted certificates.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.
-
Method Details
-
withMaxConnections
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
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
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
Sets the connection timeout on the underlying HTTP client.- Parameters:
connectionTimeout
- the connection timeout- Returns:
- the builder.
-
getConnectionTimeout
Gets the connection timeout of the underlying HTTP connection.- Returns:
- the connection timeout
-
withReadTimeout
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
Gets the read timeout on the underlying HTTP client.- Returns:
- the read timeout
-
withConnectionMaxIdle
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
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
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 aNoHttpResponseException
. 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
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 aNoHttpResponseException
. 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
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
Gets the current value of the retryHandler property.- Returns:
- a RetryHandler object with the current value of the retryHandler property
-
withProxyUri
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
Gets the current proxy URI.- Returns:
- the proxy URI
-
withProxyUsername
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
Gets the current proxy username.- Returns:
- the proxy username
-
withProxyPassword
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
Gets the current proxy password.- Returns:
- the proxy password
-
withIgnoreTls
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
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
Gets the trusted certificates.- Returns:
- the trusted certificates
-
withRequestHeaders
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
Adds the request header.- Parameters:
name
- The request header namevalue
- The request header value- Returns:
- a reference to the CdpClientConfiguration object so that method calls can be chained together
-
getRequestHeaders
Gets the request headers.- Returns:
- the request headers
-
defaultBuilder
Gets an CdpClientConfigurationBuilder object with all the default values set.- Returns:
- an CdpClientConfiguration object with default values for each property
-
build
Builds an CdpClientConfiguration object based on current settings.- Returns:
- an CdpClientConfiguration object with current settings
-
toString
Builds an string representation of the CdpClientConfiguration object based on current settings.
-