Class ClusterSettings
- java.lang.Object
-
- io.vertx.mongo.connection.ClusterSettings
-
public class ClusterSettings extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ClusterSettings()
ClusterSettings(JsonObject json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ServerAddress>
getHosts()
java.lang.Long
getLocalThreshold()
Gets the local threshold.ClusterConnectionMode
getMode()
Gets the mode.ClusterType
getRequiredClusterType()
Gets the required cluster typejava.lang.String
getRequiredReplicaSetName()
Gets the required replica set name.java.lang.Long
getServerSelectionTimeout()
Gets the timeout to apply when selecting a server.java.lang.String
getSrvHost()
Gets the host name from which to lookup SRV record for the seed listClusterSettings
setHosts(java.util.List<ServerAddress> hosts)
Sets the hosts for the cluster.ClusterSettings
setLocalThreshold(java.lang.Long localThreshold)
Sets the local threshold.ClusterSettings
setMode(ClusterConnectionMode mode)
Sets the mode for this cluster.ClusterSettings
setRequiredClusterType(ClusterType requiredClusterType)
Sets the required cluster type for the cluster.ClusterSettings
setRequiredReplicaSetName(java.lang.String requiredReplicaSetName)
Sets the required replica set name for the cluster.ClusterSettings
setServerSelectionTimeout(java.lang.Long serverSelectionTimeout)
Sets the timeout to apply when selecting a server.ClusterSettings
setSrvHost(java.lang.String srvHost)
Sets the host name to use in order to look up an SRV DNS record to find the MongoDB hosts.JsonObject
toJson()
-
-
-
Constructor Detail
-
ClusterSettings
public ClusterSettings()
-
ClusterSettings
public ClusterSettings(JsonObject json)
-
-
Method Detail
-
toJson
public JsonObject toJson()
-
setSrvHost
public ClusterSettings setSrvHost(java.lang.String srvHost)
Sets the host name to use in order to look up an SRV DNS record to find the MongoDB hosts.Note that when setting srvHost via
ClusterSettings.Builder
, the driver will NOT process any associated TXT records associated with the host. In order to enable the processing of TXT records while still usingMongoClientSettings
, specify the SRV host via connection string and apply the connection string to the settings, e.g.MongoClientSettings.builder().applyConnectionString(new ConnectionString("mongodb+srv://host1.acme.com"))
.- Parameters:
srvHost
- the SRV host name- Returns:
- this
- See Also:
MongoClientSettings.Builder.applyConnectionString(ConnectionString)
,ClusterSettings.Builder.applyConnectionString(ConnectionString)
-
getSrvHost
public java.lang.String getSrvHost()
Gets the host name from which to lookup SRV record for the seed list- Returns:
- the SRV host, or null if none specified
- Since:
- 3.10
-
setHosts
public ClusterSettings setHosts(java.util.List<ServerAddress> hosts)
Sets the hosts for the cluster. Any duplicate server addresses are removed from the list.- Parameters:
hosts
- the seed list of hosts- Returns:
- this
-
getHosts
public java.util.List<ServerAddress> getHosts()
-
setMode
public ClusterSettings setMode(ClusterConnectionMode mode)
Sets the mode for this cluster.- Parameters:
mode
- the cluster connection mode- Returns:
- this;
-
getMode
public ClusterConnectionMode getMode()
Gets the mode.- Returns:
- the mode
-
setRequiredReplicaSetName
public ClusterSettings setRequiredReplicaSetName(java.lang.String requiredReplicaSetName)
Sets the required replica set name for the cluster.- Parameters:
requiredReplicaSetName
- the required replica set name.- Returns:
- this
-
getRequiredReplicaSetName
public java.lang.String getRequiredReplicaSetName()
Gets the required replica set name.- Returns:
- the required replica set name
-
setRequiredClusterType
public ClusterSettings setRequiredClusterType(ClusterType requiredClusterType)
Sets the required cluster type for the cluster.- Parameters:
requiredClusterType
- the required cluster type- Returns:
- this
-
getRequiredClusterType
public ClusterType getRequiredClusterType()
Gets the required cluster type- Returns:
- the required cluster type
-
setLocalThreshold
public ClusterSettings setLocalThreshold(java.lang.Long localThreshold)
Sets the local threshold.- Parameters:
localThreshold
- the acceptable latency difference, in milliseconds, which must be >= 0 (in milliseconds)- Returns:
- this
- Throws:
java.lang.IllegalArgumentException
- iflocalThreshold < 0
- Since:
- 3.7
-
getLocalThreshold
public java.lang.Long getLocalThreshold()
Gets the local threshold. When choosing among multiple MongoDB servers to send a request, the MongoClient will only send that request to a server whose ping time is less than or equal to the server with the fastest ping time plus the local threshold.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.
- Returns:
- the local threshold in the given timeunit.
- Since:
- 3.7
- MongoDB documentation
- Local Threshold
-
setServerSelectionTimeout
public ClusterSettings setServerSelectionTimeout(java.lang.Long serverSelectionTimeout)
Sets the timeout to apply when selecting a server. If the timeout expires before a server is found to handle a request, aMongoTimeoutException
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.
- Parameters:
serverSelectionTimeout
- the timeout (in milliseconds)- Returns:
- this
-
getServerSelectionTimeout
public java.lang.Long getServerSelectionTimeout()
Gets the timeout to apply when selecting a server. If the timeout expires before a server is found to handle a request, aMongoTimeoutException
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.
- Returns:
- the timeout (in milliseconds)
-
-