@Immutable public class MongoClientOptions extends Object
MongoClient
.
Note: This class is a replacement for MongoOptions
, to be used with MongoClient
. The main difference
in behavior is that the default write concern is WriteConcern.ACKNOWLEDGED
.MongoClient
Modifier and Type | Class and Description |
---|---|
static class |
MongoClientOptions.Builder
A builder for MongoClientOptions so that MongoClientOptions can be immutable, and to support easier
construction through chaining.
|
Modifier and Type | Method and Description |
---|---|
static MongoClientOptions.Builder |
builder()
Create a new Builder instance.
|
boolean |
equals(Object o) |
int |
getAcceptableLatencyDifference()
Gets the acceptable latency difference.
|
int |
getConnectionsPerHost()
The maximum number of connections allowed per host for this MongoClient instance.
|
int |
getConnectTimeout()
The connection timeout in milliseconds.
|
DBDecoderFactory |
getDbDecoderFactory()
Override the decoder factory.
|
DBEncoderFactory |
getDbEncoderFactory()
Override the encoder factory.
|
String |
getDescription()
Gets the description for this MongoClient, which is used in various places like logging and JMX.
|
int |
getHeartbeatConnectRetryFrequency()
Gets the heartbeat connect retry frequency.
|
int |
getHeartbeatConnectTimeout()
Gets the heartbeat connect timeout.
|
int |
getHeartbeatFrequency()
Gets the heartbeat frequency.
|
int |
getHeartbeatSocketTimeout()
Gets the heartbeat socket timeout.
|
int |
getHeartbeatThreadCount()
Gets the heartbeat thread count.
|
long |
getMaxAutoConnectRetryTime()
Deprecated.
There is no replacement for this method. Use the connectTimeout property to control connection timeout.
|
int |
getMaxConnectionIdleTime()
The maximum idle time of a pooled connection.
|
int |
getMaxConnectionLifeTime()
The maximum life time of a pooled connection.
|
int |
getMaxWaitTime()
The maximum wait time in milliseconds that a thread may wait for a connection to become available.
|
int |
getMinConnectionsPerHost()
The minimum number of connections per host for this MongoClient instance.
|
ReadPreference |
getReadPreference()
The read preference to use for queries, map-reduce, aggregation, and count.
|
String |
getRequiredReplicaSetName()
Gets the required replica set name.
|
SocketFactory |
getSocketFactory()
The socket factory for creating sockets to the mongo server.
|
int |
getSocketTimeout()
The socket timeout in milliseconds.
|
int |
getThreadsAllowedToBlockForConnectionMultiplier()
this multiplier, multiplied with the connectionsPerHost setting, gives the maximum number of threads that
may be waiting for a connection to become available from the pool.
|
WriteConcern |
getWriteConcern()
The write concern to use.
|
int |
hashCode() |
boolean |
isAlwaysUseMBeans()
Gets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is
Java 6 or greater.
|
boolean |
isAutoConnectRetry()
Deprecated.
There is no replacement for this method. Use the connectTimeout property to control connection timeout.
|
boolean |
isCursorFinalizerEnabled()
Gets whether there is a a finalize method created that cleans up instances of DBCursor that the client
does not close.
|
boolean |
isSocketKeepAlive()
This flag controls the socket keep alive feature that keeps a connection alive through firewalls
Socket.setKeepAlive(boolean)
* Default is false. |
String |
toString() |
public static MongoClientOptions.Builder builder()
new MongoClientOptions.Builder()
.public String getDescription()
public int getMinConnectionsPerHost()
public int getConnectionsPerHost()
getThreadsAllowedToBlockForConnectionMultiplier()
public int getThreadsAllowedToBlockForConnectionMultiplier()
public int getMaxWaitTime()
public int getMaxConnectionIdleTime()
public int getMaxConnectionLifeTime()
public int getConnectTimeout()
Socket.connect(java.net.SocketAddress, int)
Default is 10,000.public int getSocketTimeout()
Socket.setSoTimeout(int)
Default is 0 and means no timeout.public boolean isSocketKeepAlive()
Socket.setKeepAlive(boolean)
* Default is false.@Deprecated public boolean isAutoConnectRetry()
@Deprecated public long getMaxAutoConnectRetryTime()
public ReadPreference getReadPreference()
ReadPreference.primary()
.ReadPreference.primary()
public DBDecoderFactory getDbDecoderFactory()
public DBEncoderFactory getDbEncoderFactory()
public WriteConcern getWriteConcern()
WriteConcern.ACKNOWLEDGED
.WriteConcern.ACKNOWLEDGED
public SocketFactory getSocketFactory()
public boolean isCursorFinalizerEnabled()
DBCursor
,
DBCursor.close()
public boolean isAlwaysUseMBeans()
Default is false.
public int getHeartbeatFrequency()
The default value is 5,000 milliseconds.
public int getHeartbeatConnectRetryFrequency()
The default value is 10 milliseconds.
public int getHeartbeatConnectTimeout()
The default value is 20,000 milliseconds.
public int getHeartbeatSocketTimeout()
The default value is 20,000 milliseconds.
public int getHeartbeatThreadCount()
The default value is the number of servers in the seed list.
public int getAcceptableLatencyDifference()
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 an acceptable latency difference of 5 milliseconds,
the client will send the query to either server1 or server2 (randomly selecting between the two).
The default value is 15 milliseconds.
public String getRequiredReplicaSetName()
1. Connect in replica set mode, and discover all members of the set based on the given servers
2. Make sure that the set name reported by all members matches the required set name.
3. Refuse to service any requests if any member of the seed list is not part of a replica set with the required name.