Class DefaultCoreEnvironment.Builder<SELF extends DefaultCoreEnvironment.Builder<SELF>>

  • Enclosing class:
    DefaultCoreEnvironment

    public static class DefaultCoreEnvironment.Builder<SELF extends DefaultCoreEnvironment.Builder<SELF>>
    extends Object
    • Constructor Detail

      • Builder

        protected Builder()
    • Method Detail

      • self

        protected SELF self()
      • sslKeystoreFile

        public SELF sslKeystoreFile​(String sslKeystoreFile)
        Defines the location of the SSL Keystore file (default value null, none). If this method is used without also specifying sslTruststoreFile(String) this keystore will be used to initialize both the key factory as well as the trust factory with java SSL. This needs to be the case for backwards compatibility, but if you do not need X.509 client cert authentication you might as well just use sslTruststoreFile(String) alone.
      • sslTruststoreFile

        public SELF sslTruststoreFile​(String sslTruststoreFile)
        Defines the location of the SSL TrustStore keystore file (default value null, none). If this method is used without also specifying sslKeystoreFile(String) this keystore will be used to initialize both the key factory as well as the trust factory with java SSL. Prefer this method over the sslKeystoreFile(String) if you do not need X.509 client auth and just need server side certificate checking.
      • sslKeystorePassword

        public SELF sslKeystorePassword​(String sslKeystorePassword)
        Sets the SSL Keystore password to be used with the Keystore file (default value null, none).
        See Also:
        sslKeystoreFile(String)
      • sslTruststorePassword

        public SELF sslTruststorePassword​(String sslTruststorePassword)
        Sets the SSL TrustStore password to be used with the Keystore file (default value null, none).
        See Also:
        sslKeystoreFile(String)
      • sslKeystore

        public SELF sslKeystore​(KeyStore sslKeystore)
        Sets the SSL Keystore directly and not indirectly via filepath. If this method is used without also specifying sslTruststore(KeyStore) this keystore will be used to initialize both the key factory as well as the trust factory with java SSL. This needs to be the case for backwards compatibility, but if you do not need X.509 client cert authentication you might as well just use sslTruststore(KeyStore) alone.
        Parameters:
        sslKeystore - the keystore to use.
      • sslTruststore

        public SELF sslTruststore​(KeyStore sslTruststore)
        Sets the SSL Keystore for the TrustStore directly and not indirectly via filepath. If this method is used without also specifying sslKeystore(KeyStore) this keystore will be used to initialize both the key factory as well as the trust factory with java SSL. Prefer this method over the sslKeystore(KeyStore) if you do not need X.509 client auth and just need server side certificate checking.
        Parameters:
        sslTruststore - the keystore to use.
      • sslHostnameVerificationEnabled

        public SELF sslHostnameVerificationEnabled​(boolean sslHostnameVerificationEnabled)
        Allows to enable SSL hostname verification.
        Parameters:
        sslHostnameVerificationEnabled - true if it should be enabled.
      • bootstrapHttpEnabled

        public SELF bootstrapHttpEnabled​(boolean bootstrapHttpEnabled)
        Toggles bootstrap via Http (default value true).
      • bootstrapCarrierEnabled

        public SELF bootstrapCarrierEnabled​(boolean bootstrapCarrierEnabled)
        Toggles bootstrap via carrier publication (default value true).
      • bootstrapHttpDirectPort

        public SELF bootstrapHttpDirectPort​(int bootstrapHttpDirectPort)
        If Http bootstrap is enabled and not SSL, sets the port to use (default value 8091).
      • bootstrapHttpSslPort

        public SELF bootstrapHttpSslPort​(int bootstrapHttpSslPort)
        If Http bootstrap and SSL are enabled, sets the port to use (default value 18091).
      • bootstrapCarrierDirectPort

        public SELF bootstrapCarrierDirectPort​(int bootstrapCarrierDirectPort)
        If carrier publication bootstrap is enabled and not SSL, sets the port to use (default value 11210).
      • bootstrapCarrierSslPort

        public SELF bootstrapCarrierSslPort​(int bootstrapCarrierSslPort)
        If carrier publication bootstrap and SSL are enabled, sets the port to use (default value 11207).
      • ioPoolSize

        public SELF ioPoolSize​(int ioPoolSize)
        Sets the pool size (number of threads to use) for I/O operations (default value is the number of CPUs). If there is more nodes in the cluster than the defined ioPoolSize, multiplexing will automatically happen.
      • computationPoolSize

        public SELF computationPoolSize​(int computationPoolSize)
        Sets the pool size (number of threads to use) for all non blocking operations in the core and clients (default value is the number of CPUs). Don't size it too small since it would significantly impact performance.
      • requestBufferSize

        public SELF requestBufferSize​(int requestBufferSize)
        Sets the size of the RingBuffer structure that queues requests (default value 16384). This is an advanced parameter that usually shouldn't need to be changed.
      • responseBufferSize

        public SELF responseBufferSize​(int responseBufferSize)
        Sets the size of the RingBuffer structure that queues responses (default value 16384). This is an advanced parameter that usually shouldn't need to be changed
      • kvEndpoints

        public SELF kvEndpoints​(int kvEndpoints)
        Deprecated.
        Sets the number of Key/Value endpoints to open per nodes in the cluster (default value 1). Only tune to more if IO has been identified as the most probable bottleneck, since it can reduce batching on the tcp/network level.
      • viewEndpoints

        public SELF viewEndpoints​(int viewEndpoints)
        Deprecated.
        Please use viewServiceConfig(ViewServiceConfig) going forward.
        Sets the number of View endpoints to open per node in the cluster (default value 12). Setting this to a higher number is advised in heavy view workloads.
      • queryEndpoints

        public SELF queryEndpoints​(int queryEndpoints)
        Deprecated.
        Please use queryServiceConfig(QueryServiceConfig) going forward.
        Sets the number of Query (N1QL) endpoints to open per node in the cluster (default value 12). Setting this to a higher number is advised in heavy query workloads.
      • searchEndpoints

        public SELF searchEndpoints​(int searchEndpoints)
        Deprecated.
        Sets the number of Search (CBFT) endpoints to open per node in the cluster (default value 12). Setting this to a higher number is advised in heavy query workloads.
      • packageNameAndVersion

        public SELF packageNameAndVersion​(String packageNameAndVersion)
        Sets the String to be used as identifier for the library namespace and version. (should usually not be tweaked, default value is computed at build time from VCS tags/commits). This is used in DefaultCoreEnvironment.userAgent() notably.
      • observeIntervalDelay

        public SELF observeIntervalDelay​(Delay observeIntervalDelay)
        Sets the Delay for Observe poll operations (default value is a delay growing exponentially between 10us and 100ms).
      • reconnectDelay

        public SELF reconnectDelay​(Delay reconnectDelay)
        Sets the Delay for node reconnects (default value is a delay growing exponentially between 32ms and 4096ms).
      • retryDelay

        public SELF retryDelay​(Delay retryDelay)
        Sets the Delay for retries of requests (default value is a delay growing exponentially between 100us and 100ms).
      • ioPool

        public SELF ioPool​(EventLoopGroup group,
                           ShutdownHook shutdownHook)
        Sets the I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • kvIoPool

        public SELF kvIoPool​(EventLoopGroup group,
                             ShutdownHook shutdownHook)
        Sets the KV I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • viewIoPool

        public SELF viewIoPool​(EventLoopGroup group,
                               ShutdownHook shutdownHook)
        Sets the View I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • queryIoPool

        public SELF queryIoPool​(EventLoopGroup group,
                                ShutdownHook shutdownHook)
        Sets the Query I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • searchIoPool

        public SELF searchIoPool​(EventLoopGroup group,
                                 ShutdownHook shutdownHook)
        Sets the Search I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • analyticsIoPool

        public SELF analyticsIoPool​(EventLoopGroup group,
                                    ShutdownHook shutdownHook)
        Sets the Analytics I/O Pool implementation for the underlying IO framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • scheduler

        @Deprecated
        public SELF scheduler​(rx.Scheduler scheduler)
        Deprecated.
        use ioPool(EventLoopGroup, ShutdownHook) to also provide a shutdown hook.
        Sets the Scheduler implementation for the underlying computation framework. This is an advanced configuration that should only be used if you know what you are doing.
      • scheduler

        public SELF scheduler​(rx.Scheduler scheduler,
                              ShutdownHook shutdownHook)
        Sets the Scheduler implementation for the underlying computation framework, along with the action to execute when this environment is shut down. This is an advanced configuration that should only be used if you know what you are doing.
      • maxRequestLifetime

        public SELF maxRequestLifetime​(long maxRequestLifetime)
        Sets the maximum time in milliseconds a request is allowed to live. If the best effort retry strategy is used, the request will still be cancelled after this period to make sure that requests are not sticking around forever. Make sure it is longer than any timeout you potentially have configured. Default is 75s.
      • keepAliveInterval

        public SELF keepAliveInterval​(long keepAliveIntervalMilliseconds)
        Sets the time of inactivity, in milliseconds, after which some services will issue a form of keep-alive request to their corresponding server/nodes (default is 30s, values <= 0 deactivate the idle check).
      • autoreleaseAfter

        public SELF autoreleaseAfter​(long autoreleaseAfter)
        Sets the time after which any non-consumed buffers will be automatically released. Setting this to a higher value than a few seconds is not recommended since this may lead to increased garbage collection.
      • eventBus

        public SELF eventBus​(EventBus eventBus)
        Sets the event bus to an alternative implementation. This setting should only be tweaked in advanced cases.
      • bufferPoolingEnabled

        public SELF bufferPoolingEnabled​(boolean bufferPoolingEnabled)
        Forcefully disable buffer pooling by setting the value to false. This should not be used in general because buffer pooling is in place to reduce GC pressure during workloads. It is implemented to be used as a "last resort" if the client is suspect to a buffer leak which can terminate the application. Until a solution is found to the leak buffer pooling can be disabled at the cost of higher GC.
      • tcpNodelayEnabled

        public SELF tcpNodelayEnabled​(boolean tcpNodelayEnabled)
        If TCP_NODELAY is manually disabled, Nagle'ing will take effect on both the client and (if supported) the server side.
      • mutationTokensEnabled

        public SELF mutationTokensEnabled​(boolean mutationTokensEnabled)
        If mutation tokens are enabled, they can be used for advanced durability requirements, as well as optimized RYOW consistency. Note that just enabling it here won't help if the server does not support it as well. Use at least Couchbase Server 4.0. Also, consider the additional overhead of 16 bytes per mutation response (8 byte for the vbucket uuid and 8 byte for the sequence number).
      • runtimeMetricsCollectorConfig

        public SELF runtimeMetricsCollectorConfig​(MetricsCollectorConfig metricsCollectorConfig)
        Sets a custom configuration for the RuntimeMetricsCollector.
        Parameters:
        metricsCollectorConfig - the custom configuration
      • defaultMetricsLoggingConsumer

        public SELF defaultMetricsLoggingConsumer​(boolean enabled,
                                                  CouchbaseLogLevel level)
      • socketConnectTimeout

        public SELF socketConnectTimeout​(int socketConnectTimeout)
        Sets a custom socket connect timeout.
        Parameters:
        socketConnectTimeout - the socket connect timeout in milliseconds.
      • callbacksOnIoPool

        public SELF callbacksOnIoPool​(boolean callbacksOnIoPool)
        Set to true if the Observable callbacks should be completed on the IO event loops. Note: this is an advanced option and must be used with care. It can be used to improve performance since it removes additional scheduling overhead on the response path, but any blocking calls in the callbacks will lead to more work on the event loops itself and eventually stall them. USE WITH CARE!
      • disconnectTimeout

        public SELF disconnectTimeout​(long disconnectTimeout)
        Sets a custom disconnect timeout.
        Parameters:
        disconnectTimeout - the disconnect timeout in milliseconds.
      • requestBufferWaitStrategy

        @Experimental
        @Public
        public SELF requestBufferWaitStrategy​(WaitStrategyFactory waitStrategy)
        Sets a custom waiting strategy for requests. Default is BlockingWaitStrategy.
        Parameters:
        waitStrategy - waiting strategy
      • memcachedHashingStrategy

        public SELF memcachedHashingStrategy​(MemcachedHashingStrategy memcachedHashingStrategy)
        Sets a custom memcached node hashing strategy, mainly used for compatibility with other clients.
        Parameters:
        memcachedHashingStrategy - the strategy to use.
      • keyValueServiceConfig

        public SELF keyValueServiceConfig​(KeyValueServiceConfig keyValueServiceConfig)
        Allows to set a custom configuration for the KV service. See KeyValueServiceConfig for more information on the possible options.
        Parameters:
        keyValueServiceConfig - the config to apply.
      • viewServiceConfig

        public SELF viewServiceConfig​(ViewServiceConfig viewServiceConfig)
        Allows to set a custom configuration for the View service. See ViewServiceConfig for more information on the possible options.
        Parameters:
        viewServiceConfig - the config to apply.
      • queryServiceConfig

        public SELF queryServiceConfig​(QueryServiceConfig queryServiceConfig)
        Allows to set a custom configuration for the Query service. See QueryServiceConfig for more information on the possible options.
        Parameters:
        queryServiceConfig - the config to apply.
      • searchServiceConfig

        public SELF searchServiceConfig​(SearchServiceConfig searchServiceConfig)
        Allows to set a custom configuration for the Search service. See SearchServiceConfig for more information on the possible options.
        Parameters:
        searchServiceConfig - the config to apply.
      • analyticsServiceConfig

        public SELF analyticsServiceConfig​(AnalyticsServiceConfig analyticsServiceConfig)
        Allows to set a custom configuration for the Analytics service. See AnalyticsServiceConfig for more information on the possible options.
        Parameters:
        analyticsServiceConfig - the config to apply.
      • configPollInterval

        @Committed
        @Public
        public SELF configPollInterval​(long configPollInterval)
        Allows to set the configuration poll interval which polls the server cluster configuration proactively. Note that the interval cannot be set lower than the floor interval defined in configPollFloorInterval(long).
        Parameters:
        configPollInterval - the interval in milliseconds, 0 deactivates the polling.
      • configPollFloorInterval

        @Committed
        @Public
        public SELF configPollFloorInterval​(long configPollFloorInterval)
        Allows to set the minimum config polling interval. Note that the configPollInterval(long) obviously needs to be equal or larger than this setting, otherwise intervals will be skipped.
        Parameters:
        configPollFloorInterval - the interval in milliseconds.
      • certAuthEnabled

        @Uncommitted
        @Public
        public SELF certAuthEnabled​(boolean certAuthEnabled)
        Allows to enable X.509 client certificate authentication. Needs to be used in combination with sslEnabled(boolean) and related methods of course.
      • continuousKeepAliveEnabled

        @Public
        @Uncommitted
        public SELF continuousKeepAliveEnabled​(boolean continuousKeepAliveEnabled)
        Allows to enable or disable the continous emitting of keepalive messages.
      • keepAliveErrorThreshold

        @Public
        @Uncommitted
        public SELF keepAliveErrorThreshold​(long keepAliveErrorThreshold)
        Allows to customize the errors on keepalive messages threshold after which the connection will be recycled.
      • keepAliveTimeout

        @Public
        @Uncommitted
        public SELF keepAliveTimeout​(long keepAliveTimeout)
        Allows to customize the timeout used for keepalive operations.
      • forceSaslPlain

        @Public
        @Committed
        public SELF forceSaslPlain​(boolean forceSaslPlain)
        Allows to forcre the KeyValue SASL authentication method to PLAIN which is used to allow authentication against LDAP-based users.
        Parameters:
        forceSaslPlain - true if plain should be forced, false otherwise.
      • operationTracingEnabled

        @Committed
        public SELF operationTracingEnabled​(boolean operationTracingEnabled)
        Allows to enable/disable the tracing support. Note that it is enabled by default, but only activated once opentracing is on the classpath!
        Parameters:
        operationTracingEnabled - enable or disable the tracing.
        Returns:
        this builder for chaining purposes.
      • operationTracingServerDurationEnabled

        @Committed
        public SELF operationTracingServerDurationEnabled​(boolean operationTracingServerDurationEnabled)
        Allows to enable/disable the negotiation of server duration-enabled tracing. Note that this is enabled by default, but depending on the server version may or may not be available (it is negotiated at runtime)!
        Parameters:
        operationTracingServerDurationEnabled - enable or disable the server duration.
        Returns:
        this builder for chaining purposes.
      • tracer

        @Committed
        public SELF tracer​(io.opentracing.Tracer tracer)
        Allows to specify a custom tracer.
        Parameters:
        tracer - the tracer to use.
        Returns:
        this builder for chaining purposes.
      • compressionMinSize

        @Public
        @Uncommitted
        public SELF compressionMinSize​(int compressionMinSize)
        Allows to adjust the minimum size of a document to be considered for compression - in bytes.
        Parameters:
        compressionMinSize - min compression size in bytes.
        Returns:
        the builder for chaining purposes.
      • compressionMinRatio

        @Public
        @Uncommitted
        public SELF compressionMinRatio​(double compressionMinRatio)
        Allows to adjust the ratio over which the document is sent compressed over the wire - in percent.
        Parameters:
        compressionMinRatio - the compression ratio in percent.
        Returns:
        the builder for chaining purposes.
      • compressionEnabled

        @Public
        @Uncommitted
        public SELF compressionEnabled​(boolean compressionEnabled)
        Allows to enable/disable compression completely, enabled by default.
        Parameters:
        compressionEnabled - if compression should be enabled or disabled.
        Returns:
        the builder for chaining purposes.
      • orphanResponseReportingEnabled

        @Public
        @Committed
        public SELF orphanResponseReportingEnabled​(boolean orphanResponseReportingEnabled)
      • networkResolution

        @Public
        @Uncommitted
        public SELF networkResolution​(NetworkResolution networkResolution)
        Allows to tune the network resolution setting, pinning it to either internal or external instead of relying on the automatic mechanism.
        Parameters:
        networkResolution - the network resolution to use.
        Returns:
        the builder for chaining purposes.