@NotThreadSafe public static final class ClusterSettings.Builder extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
ClusterSettings.Builder |
addClusterListener(ClusterListener clusterListener)
Adds a cluster listener.
|
ClusterSettings.Builder |
applyConnectionString(ConnectionString connectionString)
Takes the settings from the given
ConnectionString and applies them to the builder |
ClusterSettings.Builder |
applySettings(ClusterSettings clusterSettings)
Applies the clusterSettings to the builder
|
ClusterSettings |
build()
Build the settings from the builder.
|
ClusterSettings.Builder |
description(java.lang.String description)
Sets the user defined description of the MongoClient.
|
ClusterSettings.Builder |
hosts(java.util.List<ServerAddress> hosts)
Sets the hosts for the cluster.
|
ClusterSettings.Builder |
localThreshold(long localThreshold,
java.util.concurrent.TimeUnit timeUnit)
Sets the local threshold.
|
ClusterSettings.Builder |
maxWaitQueueSize(int maxWaitQueueSize)
This is the maximum number of concurrent operations allowed to wait for a server to become available.
|
ClusterSettings.Builder |
mode(ClusterConnectionMode mode)
Sets the mode for this cluster.
|
ClusterSettings.Builder |
requiredClusterType(ClusterType requiredClusterType)
Sets the required cluster type for the cluster.
|
ClusterSettings.Builder |
requiredReplicaSetName(java.lang.String requiredReplicaSetName)
Sets the required replica set name for the cluster.
|
ClusterSettings.Builder |
serverSelectionTimeout(long serverSelectionTimeout,
java.util.concurrent.TimeUnit timeUnit)
Sets the timeout to apply when selecting a server.
|
ClusterSettings.Builder |
serverSelector(ServerSelector serverSelector)
Adds a server selector for the cluster to apply before selecting a server.
|
public ClusterSettings.Builder applySettings(ClusterSettings clusterSettings)
Note: Overwrites all existing settings
clusterSettings
- the clusterSettingspublic ClusterSettings.Builder description(java.lang.String description)
description
- the user defined description of the MongoClientpublic ClusterSettings.Builder hosts(java.util.List<ServerAddress> hosts)
hosts
- the seed list of hostspublic ClusterSettings.Builder mode(ClusterConnectionMode mode)
mode
- the cluster connection modepublic ClusterSettings.Builder requiredReplicaSetName(java.lang.String requiredReplicaSetName)
requiredReplicaSetName
- the required replica set name.public ClusterSettings.Builder requiredClusterType(ClusterType requiredClusterType)
requiredClusterType
- the required cluster typepublic ClusterSettings.Builder localThreshold(long localThreshold, java.util.concurrent.TimeUnit timeUnit)
localThreshold
- the acceptable latency difference, in milliseconds, which must be >= 0timeUnit
- the time unitjava.lang.IllegalArgumentException
- if localThreshold < 0
public ClusterSettings.Builder serverSelector(ServerSelector serverSelector)
serverSelector
- the server selector to apply as selector.ClusterSettings.getServerSelector()
public ClusterSettings.Builder serverSelectionTimeout(long serverSelectionTimeout, java.util.concurrent.TimeUnit timeUnit)
MongoTimeoutException
will be thrown. The default value is 30 seconds.
A value of 0 means that it will timeout immediately if no server is available. A negative value means to wait indefinitely.
serverSelectionTimeout
- the timeouttimeUnit
- the time unitpublic ClusterSettings.Builder maxWaitQueueSize(int maxWaitQueueSize)
This is the maximum number of concurrent operations allowed to wait for a server to become available. All further operations will get an exception immediately.
Default is 500.
maxWaitQueueSize
- the number of threads that are allowed to be waiting for a connection.public ClusterSettings.Builder addClusterListener(ClusterListener clusterListener)
clusterListener
- the non-null cluster listenerpublic ClusterSettings.Builder applyConnectionString(ConnectionString connectionString)
ConnectionString
and applies them to the builderconnectionString
- the connection string containing details of how to connect to MongoDBpublic ClusterSettings build()
Copyright © 2010 - 2020 Adobe. All Rights Reserved