@NotThreadSafe public static final class ClusterSettings.Builder extends Object
Modifier and Type | Method and Description |
---|---|
ClusterSettings.Builder |
addClusterListener(ClusterListener clusterListener)
Adds a cluster listener.
|
ClusterSettings.Builder |
applyConnectionString(ConnectionString connectionString)
Take the settings from the given ConnectionString and add them to the builder
|
ClusterSettings |
build()
Build the settings from the builder.
|
ClusterSettings.Builder |
description(String description)
Sets the user defined description of the MongoClient.
|
ClusterSettings.Builder |
hosts(List<ServerAddress> hosts)
Sets the hosts for the cluster.
|
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(String requiredReplicaSetName)
Sets the required replica set name for the cluster.
|
ClusterSettings.Builder |
serverSelectionTimeout(long serverSelectionTimeout,
TimeUnit timeUnit)
Sets the timeout to apply when selecting a server.
|
ClusterSettings.Builder |
serverSelector(ServerSelector serverSelector)
Sets the final server selector for the cluster to apply before selecting a server
|
public ClusterSettings.Builder description(String description)
description
- the user defined description of the MongoClientpublic ClusterSettings.Builder hosts(List<ServerAddress> hosts)
hosts
- the seed list of hostspublic ClusterSettings.Builder mode(ClusterConnectionMode mode)
mode
- the cluster connection modepublic ClusterSettings.Builder requiredReplicaSetName(String requiredReplicaSetName)
requiredReplicaSetName
- the required replica set name.public ClusterSettings.Builder requiredClusterType(ClusterType requiredClusterType)
requiredClusterType
- the required cluster typepublic ClusterSettings.Builder serverSelector(ServerSelector serverSelector)
serverSelector
- the server selector to apply as the final selector.public ClusterSettings.Builder serverSelectionTimeout(long serverSelectionTimeout, 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
- a URI containing details of how to connect to MongoDBpublic ClusterSettings build()