@Immutable public final class ClusterSettings extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
ClusterSettings.Builder |
A builder for the cluster settings.
|
Modifier and Type | Method | Description |
---|---|---|
static ClusterSettings.Builder |
builder() |
Get a builder for this class.
|
static ClusterSettings.Builder |
builder(ClusterSettings clusterSettings) |
Creates a builder instance.
|
boolean |
equals(Object o) |
|
List<ClusterListener> |
getClusterListeners() |
Gets the cluster listeners.
|
String |
getDescription() |
Gets the user defined description of the MongoClient.
|
List<ServerAddress> |
getHosts() |
Gets the seed list of hosts for the cluster.
|
long |
getLocalThreshold(TimeUnit timeUnit) |
Gets the local threshold.
|
int |
getMaxWaitQueueSize() |
This is the maximum number of threads that may be waiting for a connection to become available from the pool.
|
ClusterConnectionMode |
getMode() |
Gets the mode.
|
ClusterType |
getRequiredClusterType() |
Gets the required cluster type
|
String |
getRequiredReplicaSetName() |
Gets the required replica set name.
|
long |
getServerSelectionTimeout(TimeUnit timeUnit) |
Gets the timeout to apply when selecting a server.
|
ServerSelector |
getServerSelector() |
Gets the server selector.
|
String |
getShortDescription() |
Returns a short, pretty description for these ClusterSettings.
|
int |
hashCode() |
|
String |
toString() |
public static ClusterSettings.Builder builder()
public static ClusterSettings.Builder builder(ClusterSettings clusterSettings)
clusterSettings
- existing ClusterSettings to default the builder settings on.public String getDescription()
public List<ServerAddress> getHosts()
public ClusterConnectionMode getMode()
public ClusterType getRequiredClusterType()
public String getRequiredReplicaSetName()
public ServerSelector getServerSelector()
The server selector augments the normal server selection rules applied by the driver when determining
which server to send an operation to. At the point that it's called by the driver, the
ClusterDescription
which is passed to it contains a list of
ServerDescription
instances which satisfy either the configured ReadPreference
for any read operation or ones that can take writes (e.g. a standalone, mongos, or replica set primary).
The server selector can then filter the ServerDescription
list using whatever criteria that is required by the
application.
After this selector executes, two additional selectors are applied by the driver:
To skip the latency window selector, an application can:
Cluster.selectServer(com.mongodb.selector.ServerSelector)
public long getServerSelectionTimeout(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.
timeUnit
- the time unitpublic long getLocalThreshold(TimeUnit timeUnit)
For example, let's say that the client is choosing a server to send a query when the read preference is
ReadPreference.secondary()
, and that there are three secondaries, server1, server2, and server3, whose ping times are 10, 15, and 16
milliseconds, respectively. With a local threshold of 5 milliseconds, the client will send the query to either
server1 or server2 (randomly selecting between the two).
Default is 15 milliseconds.
timeUnit
- the time unitpublic int getMaxWaitQueueSize()
This is the maximum number of threads that may be waiting for a connection to become available from the pool. All further threads will get an exception immediately.
Default is 500.
public List<ClusterListener> getClusterListeners()
public String getShortDescription()