java.lang.Object | |
↳ | com.mongodb.MongoOptions |
Various settings for the driver. Not thread safe.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
autoConnectRetry | If true, the driver will keep trying to connect to the same server in case that the socket cannot be established. | ||||||||||
connectTimeout | The connection timeout in milliseconds. | ||||||||||
connectionsPerHost | The maximum number of connections allowed per host for this Mongo instance. | ||||||||||
dbDecoderFactory | Override the DBCallback factory. | ||||||||||
dbEncoderFactory | Override the encoding factory. | ||||||||||
description | The description for |
||||||||||
fsync | The "fsync" value of the global WriteConcern. | ||||||||||
j | The "j" value of the global WriteConcern. | ||||||||||
maxAutoConnectRetryTime | The maximum amount of time in MS to spend retrying to open connection to the same server. | ||||||||||
maxWaitTime | The maximum wait time in milliseconds that a thread may wait for a connection to become available. | ||||||||||
safe | If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations. | ||||||||||
slaveOk | This field is deprecated. Replaced in MongoDB 2.0/Java Driver 2.7 with ReadPreference.SECONDARY | ||||||||||
socketFactory | sets the socket factory for creating sockets to mongod Default is SocketFactory.getDefault() | ||||||||||
socketKeepAlive | This flag controls the socket keep alive feature that keeps a connection alive through firewalls setKeepAlive(boolean)
Default is false. |
||||||||||
socketTimeout | The socket timeout in milliseconds
It is used for I/O socket read and write operations setSoTimeout(int)
Default is 0 and means no timeout. |
||||||||||
threadsAllowedToBlockForConnectionMultiplier | 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. | ||||||||||
w | The "w" value, (number of writes), of the global WriteConcern. | ||||||||||
wtimeout | The "wtimeout" value of the global WriteConcern. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Helper method to return the appropriate WriteConcern instance based
on the current related options settings.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
If true, the driver will keep trying to connect to the same server in case that the socket cannot be established. There is maximum amount of time to keep retrying, which is 15s by default. This can be useful to avoid some exceptions being thrown when a server is down temporarily by blocking the operations. It also can be useful to smooth the transition to a new master (so that a new master is elected within the retry time). Note that when using this flag: - for a replica set, the driver will trying to connect to the old master for that time, instead of failing over to the new one right away - this does not prevent exception from being thrown in read/write operations on the socket, which must be handled by application Even if this flag is false, the driver already has mechanisms to automatically recreate broken connections and retry the read operations. Default is false.
The connection timeout in milliseconds.
It is used solely when establishing a new connection connect(java.net.SocketAddress, int)
Default is 0 and means no timeout.
The maximum number of connections allowed per host for this Mongo instance. Those connections will be kept in a pool when idle. Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection. Default is 10.
Override the DBCallback factory. Default is for the standard Mongo Java driver configuration.
Override the encoding factory. Default is for the standard Mongo Java driver configuration.
The description for Mongo
instances created with these options. This is used in various places like logging.
The "fsync" value of the global WriteConcern. true indicates writes should wait for data to be written to server data file Default is false.
The "j" value of the global WriteConcern. true indicates writes should wait for a journaling group commit Default is false.
The maximum amount of time in MS to spend retrying to open connection to the same server. Default is 0, which means to use the default 15s if autoConnectRetry is on.
The maximum wait time in milliseconds that a thread may wait for a connection to become available. Default is 120,000. A value of 0 means that it will not wait. A negative value means to wait indefinitely.
If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations. If w, wtimeout, fsync or j are specified, this setting is ignored. Default is false.
This field is deprecated.
Replaced in MongoDB 2.0/Java Driver 2.7 with ReadPreference.SECONDARY
This flag specifies if the driver is allowed to read from secondary (slave) servers. Specifically in the current implementation, the driver will avoid reading from the primary server and round robin requests to secondaries. Driver also factors in the latency to secondaries when choosing a server. Note that reading from secondaries can increase performance and reliability, but it may result in temporary inconsistent results. Default is false.
sets the socket factory for creating sockets to mongod Default is SocketFactory.getDefault()
This flag controls the socket keep alive feature that keeps a connection alive through firewalls setKeepAlive(boolean)
Default is false.
The socket timeout in milliseconds
It is used for I/O socket read and write operations setSoTimeout(int)
Default is 0 and means no timeout.
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. All further threads will get an exception right away. For example if connectionsPerHost is 10 and threadsAllowedToBlockForConnectionMultiplier is 5, then up to 50 threads can wait for a connection. Default is 5.
The "w" value, (number of writes), of the global WriteConcern. Default is 0.
The "wtimeout" value of the global WriteConcern. Default is 0.
Mongo
instances created with these options
Helper method to return the appropriate WriteConcern instance based on the current related options settings.
retry | sets keep trying connection flag |
---|
timeoutMS | set the connection timeout in milliseconds. |
---|
connections | sets the maximum number of connections allowed per host for this Mongo instance |
---|
factory | sets the DBCallback decoding factory |
---|
factory | sets the encoding factory |
---|
desc | The description for Mongo instances created with these options
|
---|
sync | sets global write concern's fsync safe value |
---|
safe | sets global write concern's journal safe value |
---|
retryTimeMS | set max time in MS to retrying open connection |
---|
timeMS | set the maximum time in milliseconds that threads wait for a connection |
---|
isSafe | true if driver uses WriteConcern.SAFE for all operations. |
---|
factory | sets the socket factory for creating sockets to mongod |
---|
keepAlive | set connection keep-alive flag |
---|
timeoutMS | set the socket timeout in milliseconds |
---|
val | set the number of writes of the global WriteConcern. |
---|
timeoutMS | sets timeout for write operation |
---|