Class Client.Builder
- Enclosing class:
Client
Client
creation.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticator
(Authenticator authenticator) bootstrapTimeout
(Duration bootstrapTimeout) Time to wait for first configuration during bootstrap.The name of the bucket to use.bufferAckWatermark
(int watermark) The buffer acknowledge watermark in percent.build()
Create the client instance ready to use.collectionIds
(long... collectionIds) Configures the client to stream only from the collections identified by the given IDs.collectionIds
(Collection<Long> collectionIds) Configures the client to stream only from the collections identified by the given IDs.collectionNames
(String... qualifiedCollectionNames) collectionNames
(Collection<String> qualifiedCollectionNames) collectionsAware
(boolean enable) Controls whether the client operates in collections-aware mode (defaults to false).compression
(CompressionMode compressionMode) Sets the compression mode for message values sent by Couchbase Server.configRefreshInterval
(Duration configRefreshInterval) When connecting to versions of Couchbase Server older than 5.5, the DCP client polls the server for cluster topology config changes at the specified interval.connectionNameGenerator
(ConnectionNameGenerator connectionNameGenerator) If specific names for DCP connections should be generated, a custom one can be provided.connectionString
(com.couchbase.client.core.util.ConnectionString connectionString) connectionString
(String connectionString) Connection string to bootstrap with.controlParam
(DcpControl.Names name, Object value) Sets a DCP control parameter.controlParam
(String name, Object value) Sets an arbitrary DCP control parameter.credentials
(String username, String password) credentialsProvider
(CredentialsProvider credentialsProvider) dcpChannelsReconnectDelay
(Delay ignored) Deprecated.Doesn't do anything.dcpChannelsReconnectMaxAttempts
(int dcpChannelsReconnectMaxAttempts) The maximum number of reconnect attempts for DCP channelsSets the event bus to an alternative implementation.eventLoopGroup
(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup) Sets a custom event loop group.flowControl
(int bufferSizeInBytes) Enables flow control with the specified buffer size (in bytes) and a reasonable default buffer ACK threshold.Deprecated.useseedNodes(String...)
instead.Deprecated.useseedNodes(Collection)
instead.meterRegistry
(io.micrometer.core.instrument.MeterRegistry meterRegistry) Specifies the registry the client should use when tracking metrics.mitigateRollbacks
(long persistencePollingInterval, TimeUnit unit) Enables rollback mitigation with the specified persistence polling interval.networkResolution
(com.couchbase.client.core.env.NetworkResolution nr) Network selection strategy for connecting to clusters whose nodes have alternate hostnames.noValue
(boolean noValue) If the argument is true, configures the client to receive only document keys and metadata (no contents).optionalControlParam
(String name, Object value) Sets an arbitrary DCP control parameter.optionalStreamFlags
(Set<StreamFlag> flags) Sets the flags to use for all "open stream" and "add stream" requests.poolBuffers
(boolean pool) If buffer pooling should be enabled (yes by default).scopeId
(long scopeId) Configures the client to stream only from the scope identified by the given ID.Configures the client to stream only from the scope identified by the given ID.securityConfig
(SecurityConfig securityConfig) Deprecated.Please usesecurityConfig(Consumer)
instead.securityConfig
(SecurityConfig.Builder securityConfigBuilder) Deprecated.Please usesecurityConfig(Consumer)
instead.securityConfig
(Consumer<SecurityConfig.Builder> configurator) Sets the addresses of the Couchbase Server nodes to bootstrap against.seedNodes
(Collection<String> addresses) Sets the addresses of the Couchbase Server nodes to bootstrap against.socketConnectTimeout
(long socketConnectTimeout) Sets a custom socket connect timeout.Enables fine-grained trace logging to the "com.couchbase.client.dcp.trace" category.Sets the product information to include in the DCP client's User Agent string.xattrs
(boolean xattrs) If the argument is true, configures the client to receive extended attributes (XATTRS).
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
noValue
If the argument is true, configures the client to receive only document keys and metadata (no contents).Defaults to false.
- Returns:
- this
Client.Builder
for nice chainability.
-
xattrs
If the argument is true, configures the client to receive extended attributes (XATTRS).Defaults to false.
If set to true, users of the low-level API may call
MessageUtil.getContentAndXattrs(ByteBuf)
to parse the content and XATTRs of mutation requests. Users of the high-level API may view XATTRs by callingDocumentChange.getXattrs()
.- Returns:
- this
Client.Builder
for nice chainability.
-
optionalStreamFlags
Sets the flags to use for all "open stream" and "add stream" requests.Silently ignores any flags not supported by the server.
-
bufferAckWatermark
The buffer acknowledge watermark in percent.- Parameters:
watermark
- between 0 and 100, needs to be > 0 if flow control is enabled.- Returns:
- this
Client.Builder
for nice chainability.
-
seedNodes
Sets the addresses of the Couchbase Server nodes to bootstrap against.If a port is specified, it must be the KV service port.
The port may be omitted if Couchbase is listening on the standard KV ports (11210 and 11207 for insecure and TLS connections, respectively).
- Parameters:
addresses
- seed nodes.- Returns:
- this
Client.Builder
for nice chainability.
-
seedNodes
Sets the addresses of the Couchbase Server nodes to bootstrap against.If a port is specified, it must be the KV service port.
The port may be omitted if Couchbase is listening on the standard KV ports (11210 and 11207 for insecure and TLS connections, respectively).
- Parameters:
addresses
- seed nodes.- Returns:
- this
Client.Builder
for nice chainability.
-
hostnames
Deprecated.useseedNodes(Collection)
instead. -
hostnames
Deprecated.useseedNodes(String...)
instead. -
connectionString
Connection string to bootstrap with.Note: it overrides list of addresses defined by
seedNodes(Collection)
.Connection string specification defined in SDK-RFC-11: https://github.com/couchbaselabs/sdk-rfcs/blob/master/rfc/0011-connection-string.md
- Parameters:
connectionString
- seed nodes.- Returns:
- this
Client.Builder
for nice chainability.
-
connectionString
public Client.Builder connectionString(com.couchbase.client.core.util.ConnectionString connectionString) -
networkResolution
Network selection strategy for connecting to clusters whose nodes have alternate hostnames. This usually only matters if Couchbase is running in a containerized environment and you're connecting from outside that environment.Defaults to
NetworkResolution.AUTO
which attempts to infer the correct network name by comparing the hostnames reported by Couchbase against the hostnames used to connect to the cluster. -
eventLoopGroup
public Client.Builder eventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.EventLoopGroup eventLoopGroup) Sets a custom event loop group.If more than one client is initialized and runs at the same time, you may see better performance if you create a single event loop group for the clients to share.
- Parameters:
eventLoopGroup
- the group that should be used.- Returns:
- this
Client.Builder
for nice chainability.
-
bucket
The name of the bucket to use.- Parameters:
bucket
- name of the bucket- Returns:
- this
Client.Builder
for nice chainability.
-
collectionsAware
Controls whether the client operates in collections-aware mode (defaults to false).A client that is not collections-aware only receives events from the default collection.
A collections-aware client receives events from all collections (or the subset specified by the collections/scope filter, configured separately). In this mode, users of the low-level API are responsible for handling "DCP System Event" and "DCP Seqno Advanced" events in their
ControlEventHandler
. Users of the high-level API should implementDatabaseChangeListener.onSeqnoAdvanced(com.couchbase.client.dcp.highlevel.SeqnoAdvanced)
.It is fine to enable collections awareness even when connecting to a server that does not support collections, as long as no collections/scope filter is configured.
- Returns:
- this
Client.Builder
for nice chainability. - See Also:
-
trace
Enables fine-grained trace logging to the "com.couchbase.client.dcp.trace" category.- Parameters:
level
- level at which to log the trace messagesdocumentIdIsInteresting
- (nullable) tests a document ID and returns true if events related to this document ID should be logged. Null means log events for all documents.
-
collectionNames
-
collectionNames
-
collectionIds
Configures the client to stream only from the collections identified by the given IDs.- Parameters:
collectionIds
- IDs of the collections to stream.- Returns:
- this
Client.Builder
for nice chainability.
-
collectionIds
Configures the client to stream only from the collections identified by the given IDs.- Parameters:
collectionIds
- IDs of the collections to stream.- Returns:
- this
Client.Builder
for nice chainability.
-
scopeName
Configures the client to stream only from the scope identified by the given ID.- Parameters:
scopeName
- name of the scope to stream (may be null, in which case this method has no effect)- Returns:
- this
Client.Builder
for nice chainability.
-
scopeId
Configures the client to stream only from the scope identified by the given ID.- Parameters:
scopeId
- IDs of the scope to stream.- Returns:
- this
Client.Builder
for nice chainability.
-
credentials
-
credentialsProvider
-
authenticator
-
userAgent
Sets the product information to include in the DCP client's User Agent string. The User Agent will be part of the DCP connection name, which appears in the Couchbase Server logs for log entries associated with this client.The product name may consist of alphanumeric ASCII characters, plus the following special characters:
!#$%&'*+-.^_`|~
Invalid characters will be converted to underscores.
Comments may optionally convey additional context, such as the name of the bucket being streamed or some other information about the client.
- Returns:
- this
Client.Builder
for nice chainability.
-
connectionNameGenerator
If specific names for DCP connections should be generated, a custom one can be provided.- Parameters:
connectionNameGenerator
- custom generator.- Returns:
- this
Client.Builder
for nice chainability.
-
controlParam
Sets a DCP control parameter.See
DcpControl.Names
for more information.- Parameters:
name
- the name of the paramvalue
- the value of the param- Returns:
- this
Client.Builder
for nice chainability.
-
controlParam
Sets an arbitrary DCP control parameter.- Parameters:
name
- the name of the paramvalue
- the value of the param- Returns:
- this
Client.Builder
for nice chainability.
-
optionalControlParam
Sets an arbitrary DCP control parameter.Because the control is optional, the connection will not fail if the server does not recognize the control name or value.
-
compression
Sets the compression mode for message values sent by Couchbase Server. If not specified, defaults toCompressionMode.ENABLED
. -
poolBuffers
If buffer pooling should be enabled (yes by default).- Parameters:
pool
- enable or disable buffer pooling.- Returns:
- this
Client.Builder
for nice chainability.
-
socketConnectTimeout
Sets a custom socket connect timeout.- Parameters:
socketConnectTimeout
- the socket connect timeout in milliseconds.
-
bootstrapTimeout
Time to wait for first configuration during bootstrap. -
configRefreshInterval
When connecting to versions of Couchbase Server older than 5.5, the DCP client polls the server for cluster topology config changes at the specified interval.When connecting to modern versions of Couchbase Server, calling this method has no effect.
- Parameters:
configRefreshInterval
- time between config refresh requests. Must be between 1 second and 2 minutes (inclusive).
-
dcpChannelsReconnectMaxAttempts
The maximum number of reconnect attempts for DCP channels- Parameters:
dcpChannelsReconnectMaxAttempts
-
-
dcpChannelsReconnectDelay
Deprecated.Doesn't do anything.Delay between retry attempts for DCP channels -
eventBus
Sets the event bus to an alternative implementation.This setting should only be tweaked in advanced cases.
-
securityConfig
Deprecated.Please usesecurityConfig(Consumer)
instead.Sets the TLS configuration options. -
securityConfig
-
securityConfig
Deprecated.Please usesecurityConfig(Consumer)
instead.Sets the TLS configuration options (from a builder, for convenience) -
mitigateRollbacks
Enables rollback mitigation with the specified persistence polling interval. Must be accompanied by a call toflowControl(int)
.When rollback mitigation is enabled, stream events will not be propagated to the
DataEventHandler
orControlEventHandler
until the event has been persisted to disk on the active and all replica nodes.To observe persistence, the client will poll each node at the given interval.
If a partition instance becomes unavailable, event propagation will pause until the cluster stabilizes. Because recovery may take a long time, flow control is required so the client need not buffer an indeterminately large number of events. -
flowControl
Enables flow control with the specified buffer size (in bytes) and a reasonable default buffer ACK threshold. To specify a custom threshold, chain this method withbufferAckWatermark(int)
.- Parameters:
bufferSizeInBytes
- The amount of data the server will send before requiring an ACK- See Also:
-
meterRegistry
Specifies the registry the client should use when tracking metrics. If not called, defaults to Micrometer's global registry. -
build
Create the client instance ready to use.- Returns:
- the built client instance.
-