Class ConnectionParams.Builder

java.lang.Object
com.yahoo.vespa.http.client.config.ConnectionParams.Builder
Enclosing class:
ConnectionParams

public static final class ConnectionParams.Builder extends Object
Builder for ConnectionParams.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • setUseTlsConfigFromEnvironment

      public ConnectionParams.Builder setUseTlsConfigFromEnvironment(boolean useTlsConfigFromEnvironment)
      Use TLS configuration through the standard Vespa environment variables. Setting this to 'true' will override any other TLS/HTTPS related configuration.
    • setSslContext

      public ConnectionParams.Builder setSslContext(SSLContext sslContext)
      Sets the SSLContext for the connection to the gateway when SSL is enabled for Endpoint. Default null (no ssl). See also Endpoint configuration.
      Parameters:
      sslContext - sslContext for connection to gateway.
      Returns:
      pointer to builder.
    • setHostnameVerifier

      public ConnectionParams.Builder setHostnameVerifier(HostnameVerifier hostnameVerifier)
      Sets the HostnameVerifier for the connection to the gateway when SSL is enabled for Endpoint. Defaults to instance returned by SSLConnectionSocketFactory.getDefaultHostnameVerifier().
      Parameters:
      hostnameVerifier - hostname verifier for connection to gateway.
      Returns:
      pointer to builder.
    • setCertificateAndPrivateKey

      public ConnectionParams.Builder setCertificateAndPrivateKey(Path privateKey, Path certificate)
      Set path to private key and certificate files. Both the private key and certificate must be PEM-encoded.
    • setCaCertificates

      public ConnectionParams.Builder setCaCertificates(Path caCertificates)
      Set path a PEM file containing the CA certificates.
    • addHeader

      public ConnectionParams.Builder addHeader(String key, String value)
      Set custom headers to be used
      Parameters:
      key - header name
      value - header value
      Returns:
      pointer to builder.
    • addDynamicHeader

      public ConnectionParams.Builder addDynamicHeader(String headerName, ConnectionParams.HeaderProvider provider)
      Adds a header provider for dynamic headers; headers where the value may change during a feeding session (e.g. security tokens with limited life time). Only one ConnectionParams.HeaderProvider is allowed for a given header name.
      Parameters:
      provider - A provider for a dynamic header
      Returns:
      pointer to builder.
      Throws:
      IllegalArgumentException - if a provider is already registered for the given header name
    • setNumPersistentConnectionsPerEndpoint

      public ConnectionParams.Builder setNumPersistentConnectionsPerEndpoint(int numPersistentConnectionsPerEndpoint)
      The number of connections between the http client and the gateways. A very low number can result in the network not fully utilized and the round-trip time can be a limiting factor. A low number can cause skew in distribution of load between gateways. A too high number will cause many threads to run, more context switching and potential more memory usage. We recommend using about 16 connections per gateway.
      Parameters:
      numPersistentConnectionsPerEndpoint - number of channels per endpoint
      Returns:
      pointer to builder.
    • setProxyHost

      public ConnectionParams.Builder setProxyHost(String proxyHost)
      Sets the HTTP proxy host name to use.
      Parameters:
      proxyHost - host name for proxy.
      Returns:
      pointer to builder.
    • setProxyPort

      public ConnectionParams.Builder setProxyPort(int proxyPort)
      Sets the HTTP proxy host port to use.
      Parameters:
      proxyPort - host port for proxy.
      Returns:
      pointer to builder.
    • setUseCompression

      public ConnectionParams.Builder setUseCompression(boolean useCompression)
      Set whether compression of document operations during communication to server should be enabled.
      Parameters:
      useCompression - true if compression should be enabled.
      Returns:
      pointer to builder.
    • setMaxRetries

      public ConnectionParams.Builder setMaxRetries(int maxRetries)
      Set how many times to retry sending an operation to a gateway when encountering transient problems.
      Parameters:
      maxRetries - max number of retries
      Returns:
      pointer to builder.
    • setDryRun

      public ConnectionParams.Builder setDryRun(boolean dryRun)
      Set to true to skip making network connections and instead let requests complete successfully with no effect.
    • setRunThreads

      public ConnectionParams.Builder setRunThreads(boolean runThreads)
      Set to false to skip starting io threads, such that any operation must be driven by a calling thread. Useful for testing.
    • setMinTimeBetweenRetries

      public ConnectionParams.Builder setMinTimeBetweenRetries(long minTimeBetweenRetries, TimeUnit unit)
      Set the min time between retries when temporarily failing against a gateway.
      Parameters:
      minTimeBetweenRetries - the min time value
      unit - the unit of the min time.
      Returns:
      pointer to builder.
    • getMinTimeBetweenRetriesMs

      public long getMinTimeBetweenRetriesMs()
    • setTraceLevel

      public ConnectionParams.Builder setTraceLevel(int traceLevel)
      Sets the trace level for tracing messagebus. 0 means to tracing.
      Parameters:
      traceLevel - tracelevel, larger value means more tracing.
      Returns:
      pointer to builder.
    • setTraceEveryXOperation

      public ConnectionParams.Builder setTraceEveryXOperation(int traceEveryXOperation)
      How often to trace messages in client. Please note that this does not affect tracing with messagebus
      Parameters:
      traceEveryXOperation - if zero, no tracing, 1 = every message, and so on.
      Returns:
      pointer to builder.
    • setPrintTraceToStdErr

      public ConnectionParams.Builder setPrintTraceToStdErr(boolean printTraceToStdErr)
      If enabled will write internal trace to stderr.
      Parameters:
      printTraceToStdErr - if value is true it is enabled.
      Returns:
      pointer to builder.
    • setConnectionTimeToLive

      public ConnectionParams.Builder setConnectionTimeToLive(Duration connectionTimeToLive)
      Set the maximum time to live for persistent connections
    • build

      public ConnectionParams build()
    • getNumPersistentConnectionsPerEndpoint

      public int getNumPersistentConnectionsPerEndpoint()
    • getProxyHost

      public String getProxyHost()
    • isDryRun

      public boolean isDryRun()
    • runThreads

      public boolean runThreads()
    • getMaxRetries

      public int getMaxRetries()
    • getTraceLevel

      public int getTraceLevel()
    • getTraceEveryXOperation

      public int getTraceEveryXOperation()
    • getPrintTraceToStdErr

      public boolean getPrintTraceToStdErr()
    • getProxyPort

      public int getProxyPort()
    • getSslContext

      public SSLContext getSslContext()
    • getHostnameVerifier

      public HostnameVerifier getHostnameVerifier()
    • useTlsConfigFromEnvironment

      public boolean useTlsConfigFromEnvironment()
    • getConnectionTimeToLive

      public Duration getConnectionTimeToLive()
    • getPrivateKey

      public Path getPrivateKey()
    • getCertificate

      public Path getCertificate()
    • getCaCertificates

      public Path getCaCertificates()