Package com.mongodb
Class MongoOptions
java.lang.Object
com.mongodb.MongoOptions
Deprecated.
Various settings for a Mongo instance. Not thread safe, and superseded by MongoClientOptions. This class may be deprecated in a future
release.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
Deprecated.Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater.int
Deprecated.The maximum number of connections allowed per host for this Mongo instance.int
Deprecated.The connection timeout in milliseconds.boolean
Deprecated.Sets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close.Deprecated.Override the DBCallback factory.Deprecated.Override the encoding factory.Deprecated.The description forMongo
instances created with these options.boolean
Deprecated.The "fsync" value of the global WriteConcern.boolean
Deprecated.The "j" value of the global WriteConcern.int
Deprecated.The maximum wait time in milliseconds that a thread may wait for a connection to become available.Deprecated.Specifies the read preference.boolean
Deprecated.Iftrue
the driver will use a WriteConcern of WriteConcern.SAFE for all operations.Deprecated.Sets the socket factory for creating sockets to mongod Default is SocketFactory.getDefault()boolean
Deprecated.This flag controls the socket keep alive feature that keeps a connection alive through firewallsSocket.setKeepAlive(boolean)
Default is false.int
Deprecated.The socket timeout in milliseconds It is used for I/O socket read and write operationsSocket.setSoTimeout(int)
Default is 0 and means no timeout.int
Deprecated.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.int
Deprecated.The "w" value, (number of writes), of the global WriteConcern.Deprecated.Sets the write concern.int
Deprecated.The "wtimeout" value of the global WriteConcern. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Deprecated.Copy this MongoOptions instance into a new instance.boolean
Deprecated.int
Deprecated.Gets the maximum number of connections allowed per host for this Mongo instance.int
Deprecated.Gets the connection timeout in milliseconds.Deprecated.Gets the DBCallback factory.Deprecated.Gets the encoding factory.Deprecated.Gets the description forMongo
instances created with these options.int
Deprecated.Gets the maximum wait time in milliseconds that a thread may wait for a connection to become available.Deprecated.Gets the read preference.Deprecated.Gets the required replica set name that this client should be connecting to.Deprecated.Gets the socket factory for creating sockets to mongod.int
Deprecated.Gets the socket timeout in milliseconds.int
Deprecated.Gets the multiplier which, when multiplied with the connectionsPerHost setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool.int
getW()
Deprecated.Gets the "w" value, (number of writes), of the global WriteConcern.Deprecated.Helper method to return the appropriate WriteConcern instance based on the current related options settings.int
Deprecated.Gets the "wtimeout" value of the global WriteConcern.int
hashCode()
Deprecated.boolean
Deprecated.Gets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater.boolean
Deprecated.Gets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close.boolean
isFsync()
Deprecated.Gets the "fsync" value of the global WriteConcern.boolean
isJ()
Deprecated.Gets the "j" value of the global WriteConcern.boolean
isSafe()
Deprecated.Returns whether the driver will use a WriteConcern of WriteConcern.ACKNOWLEDGED for all operations.boolean
Deprecated.Gets the flag that controls the socket keep alive feature that keeps a connection alive through firewalls.void
reset()
Deprecated.Reset all settings to the default.void
setAlwaysUseMBeans
(boolean alwaysUseMBeans) Deprecated.Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater.void
setConnectionsPerHost
(int connections) Deprecated.Sets the maximum number of connections allowed per host for this Mongo instance.void
setConnectTimeout
(int timeoutMS) Deprecated.Sets the connection timeout in milliseconds.void
setCursorFinalizerEnabled
(boolean cursorFinalizerEnabled) Deprecated.Sets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close.void
setDbDecoderFactory
(DBDecoderFactory factory) Deprecated.Override the DBCallback factory.void
setDbEncoderFactory
(DBEncoderFactory factory) Deprecated.Override the encoding factory.void
setDescription
(String desc) Deprecated.Sets the description forMongo
instances created with these options.void
setFsync
(boolean sync) Deprecated.Sets the "fsync" value of the global WriteConcern.void
setJ
(boolean safe) Deprecated.Sets the "j" value of the global WriteConcern.void
setMaxWaitTime
(int timeMS) Deprecated.Sets the maximum wait time in milliseconds that a thread may wait for a connection to become available.void
setReadPreference
(ReadPreference readPreference) Deprecated.Specifies the read preference.void
setSafe
(boolean isSafe) Deprecated.Iftrue
the driver will use a WriteConcern of WriteConcern.SAFE for all operations.void
setSocketFactory
(SocketFactory factory) Deprecated.Sets the socket factory for creating sockets to mongod.void
setSocketKeepAlive
(boolean keepAlive) Deprecated.Sets the flag that controls the socket keep alive feature that keeps a connection alive through firewallsSocket.setKeepAlive(boolean)
Default is false.void
setSocketTimeout
(int timeoutMS) Deprecated.Sets the socket timeout in milliseconds It is used for I/O socket read and write operations(int)
Default is 0 and means no timeout.void
setThreadsAllowedToBlockForConnectionMultiplier
(int threads) Deprecated.Sets the multiplier which, when multiplied with the connectionsPerHost setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool.void
setW
(int val) Deprecated.Sets the "w" value, (number of writes), of the global WriteConcern.void
setWriteConcern
(WriteConcern writeConcern) Deprecated.Sets the write concern.void
setWtimeout
(int timeoutMS) Deprecated.Sets the "wtimeout" value of the global WriteConcern.toString()
Deprecated.
-
Field Details
-
description
Deprecated.The description forMongo
instances created with these options. This is used in various places like logging. -
connectionsPerHost
public int connectionsPerHostDeprecated.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.- See Also:
-
threadsAllowedToBlockForConnectionMultiplier
public int threadsAllowedToBlockForConnectionMultiplierDeprecated.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. -
maxWaitTime
public int maxWaitTimeDeprecated.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. -
connectTimeout
public int connectTimeoutDeprecated.The connection timeout in milliseconds. A value of 0 means no timeout. It is used solely when establishing a new connectionSocket.connect(java.net.SocketAddress, int)
Default is 10,000. -
socketTimeout
public int socketTimeoutDeprecated.The socket timeout in milliseconds It is used for I/O socket read and write operationsSocket.setSoTimeout(int)
Default is 0 and means no timeout. -
socketKeepAlive
public boolean socketKeepAliveDeprecated.This flag controls the socket keep alive feature that keeps a connection alive through firewallsSocket.setKeepAlive(boolean)
Default is false. -
readPreference
Deprecated.Specifies the read preference. -
dbDecoderFactory
Deprecated.Override the DBCallback factory. Default is for the standard Mongo Java driver configuration. -
dbEncoderFactory
Deprecated.Override the encoding factory. Default is for the standard Mongo Java driver configuration. -
safe
public boolean safeDeprecated.Iftrue
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. -
w
public int wDeprecated.The "w" value, (number of writes), of the global WriteConcern. Default is 0. -
wtimeout
public int wtimeoutDeprecated.The "wtimeout" value of the global WriteConcern. Default is 0. -
fsync
public boolean fsyncDeprecated.The "fsync" value of the global WriteConcern. true indicates writes should wait for data to be written to server data file Default is false. -
j
public boolean jDeprecated.The "j" value of the global WriteConcern. true indicates writes should wait for a journaling group commit Default is false. -
socketFactory
Deprecated.Sets the socket factory for creating sockets to mongod Default is SocketFactory.getDefault() -
cursorFinalizerEnabled
public boolean cursorFinalizerEnabledDeprecated.Sets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close. If you are careful to always call the close method of DBCursor, then this can safely be set to false.
Default is true.
- See Also:
-
writeConcern
Deprecated.Sets the write concern. If this is not set, the write concern defaults to the combination of settings of the other write concern-related fields. If set, this will override all of the other write concern-related fields.- See Also:
-
alwaysUseMBeans
public boolean alwaysUseMBeansDeprecated.Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater. If false, the driver will use MXBeans if the VM is Java 6 or greater, and use MBeans if the VM is Java 5.Default is false.
-
-
Constructor Details
-
MongoOptions
Deprecated.Creates a new defaultMongoOptions
. This class is deprecated, useMongoClientOptions
. -
MongoOptions
Deprecated.Creates a newMongoOptions
with the given options. This class is deprecated, useMongoClientOptions
.- Parameters:
options
- the MongoClientOptions to copy values from into the new MongoOptions.
-
-
Method Details
-
reset
public void reset()Deprecated.Reset all settings to the default. -
copy
Deprecated.Copy this MongoOptions instance into a new instance.- Returns:
- the new MongoOptions with the same settings as this instance.
-
getWriteConcern
Deprecated.Helper method to return the appropriate WriteConcern instance based on the current related options settings.- Returns:
- a WriteConcern for the current MongoOptions.
-
setWriteConcern
Deprecated.Sets the write concern. If this is not set, the write concern defaults to the combination of settings of the other write concern-related fields. If set, this will override all of the other write concern-related fields.- Parameters:
writeConcern
- sets the write concern
-
getSocketFactory
Deprecated.Gets the socket factory for creating sockets to mongod. Default is SocketFactory.getDefault()- Returns:
- the socket factory for creating sockets to mongod
-
setSocketFactory
Deprecated.Sets the socket factory for creating sockets to mongod.- Parameters:
factory
- sets the socket factory for creating sockets to mongod
-
getDescription
Deprecated.Gets the description forMongo
instances created with these options.- Returns:
- The description for
MongoClient
instances created with these options
-
setDescription
Deprecated.Sets the description forMongo
instances created with these options. This is used in various places like logging.- Parameters:
desc
- The description forMongo
instances created with these options
-
getConnectionsPerHost
public int getConnectionsPerHost()Deprecated.Gets the maximum number of connections allowed per host for this Mongo instance.- Returns:
- the maximum number of connections allowed per host for this Mongo instance
-
setConnectionsPerHost
public void setConnectionsPerHost(int connections) Deprecated.Sets 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.- Parameters:
connections
- sets the maximum number of connections allowed per host for this Mongo instance
-
getThreadsAllowedToBlockForConnectionMultiplier
public int getThreadsAllowedToBlockForConnectionMultiplier()Deprecated.Gets the multiplier which, when multiplied with the connectionsPerHost setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool.- Returns:
- the maximum number of threads that may be waiting for a connection
-
setThreadsAllowedToBlockForConnectionMultiplier
public void setThreadsAllowedToBlockForConnectionMultiplier(int threads) Deprecated.Sets the multiplier which, when 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.- Parameters:
threads
- multiplied with connectionsPerHost, sets the maximum number of threads that may be waiting for a connection
-
getMaxWaitTime
public int getMaxWaitTime()Deprecated.Gets the maximum wait time in milliseconds that a thread may wait for a connection to become available.- Returns:
- The maximum time in milliseconds that threads wait for a connection
-
setMaxWaitTime
public void setMaxWaitTime(int timeMS) Deprecated.Sets 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.- Parameters:
timeMS
- set the maximum time in milliseconds that threads wait for a connection
-
getConnectTimeout
public int getConnectTimeout()Deprecated.Gets the connection timeout in milliseconds. A value of 0 means no timeout.- Returns:
- the connection timeout in milliseconds.
-
setConnectTimeout
public void setConnectTimeout(int timeoutMS) Deprecated.Sets the connection timeout in milliseconds. A value of 0 means no timeout. It is used solely when establishing a new connectionSocket.connect(java.net.SocketAddress, int)
Default is 10,000.- Parameters:
timeoutMS
- set the connection timeout in milliseconds.
-
getSocketTimeout
public int getSocketTimeout()Deprecated.Gets the socket timeout in milliseconds. 0 means no timeout.- Returns:
- The socket timeout in milliseconds
-
setSocketTimeout
public void setSocketTimeout(int timeoutMS) Deprecated.Sets the socket timeout in milliseconds It is used for I/O socket read and write operations(int)
Default is 0 and means no timeout.- Parameters:
timeoutMS
- set the socket timeout in milliseconds
-
isSocketKeepAlive
public boolean isSocketKeepAlive()Deprecated.Gets the flag that controls the socket keep alive feature that keeps a connection alive through firewalls.- Returns:
- connection keep-alive flag
-
setSocketKeepAlive
public void setSocketKeepAlive(boolean keepAlive) Deprecated.Sets the flag that controls the socket keep alive feature that keeps a connection alive through firewallsSocket.setKeepAlive(boolean)
Default is false.- Parameters:
keepAlive
- set connection keep-alive flag
-
getDbDecoderFactory
Deprecated.Gets the DBCallback factory.- Returns:
- the DBCallback decoding factory
-
setDbDecoderFactory
Deprecated.Override the DBCallback factory. Default is for the standard Mongo Java driver configuration.- Parameters:
factory
- sets the DBCallback decoding factory
-
getDbEncoderFactory
Deprecated.Gets the encoding factory.- Returns:
- the encoding factory
-
setDbEncoderFactory
Deprecated.Override the encoding factory. Default is for the standard Mongo Java driver configuration.- Parameters:
factory
- sets the encoding factory
-
isSafe
public boolean isSafe()Deprecated.Returns whether the driver will use a WriteConcern of WriteConcern.ACKNOWLEDGED for all operations.- Returns:
- true if driver uses WriteConcern.SAFE for all operations.
-
setSafe
public void setSafe(boolean isSafe) Deprecated.Iftrue
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.- Parameters:
isSafe
- true if driver uses WriteConcern.SAFE for all operations.
-
getW
public int getW()Deprecated.Gets the "w" value, (number of writes), of the global WriteConcern.- Returns:
- value returns the number of writes of the global WriteConcern.
-
setW
public void setW(int val) Deprecated.Sets the "w" value, (number of writes), of the global WriteConcern. Default is 0.- Parameters:
val
- set the number of writes of the global WriteConcern.
-
getWtimeout
public int getWtimeout()Deprecated.Gets the "wtimeout" value of the global WriteConcern.- Returns:
- timeout in millis for write operation
-
setWtimeout
public void setWtimeout(int timeoutMS) Deprecated.Sets the "wtimeout" value of the global WriteConcern. Default is 0.- Parameters:
timeoutMS
- sets timeout in millis for write operation
-
isFsync
public boolean isFsync()Deprecated.Gets the "fsync" value of the global WriteConcern. True indicates writes should wait for data to be written to server data file- Returns:
- true if global write concern is set to fsync
-
setFsync
public void setFsync(boolean sync) Deprecated.Sets the "fsync" value of the global WriteConcern. True indicates writes should wait for data to be written to server data file Default is false.- Parameters:
sync
- sets global write concern's fsync safe value
-
isJ
public boolean isJ()Deprecated.Gets the "j" value of the global WriteConcern. True indicates writes should wait for a journaling group commit- Returns:
- true if global write concern is set to journal safe
-
setJ
public void setJ(boolean safe) Deprecated.Sets the "j" value of the global WriteConcern. True indicates writes should wait for a journaling group commit. Default is false.- Parameters:
safe
- sets global write concern's journal safe value
-
getReadPreference
Deprecated.Gets the read preference.- Returns:
- the read preference
-
setReadPreference
Deprecated.Specifies the read preference.- Parameters:
readPreference
- the read preference
-
isCursorFinalizerEnabled
public boolean isCursorFinalizerEnabled()Deprecated.Gets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close.- Returns:
- whether DBCursor finalizer is enabled
-
setCursorFinalizerEnabled
public void setCursorFinalizerEnabled(boolean cursorFinalizerEnabled) Deprecated.Sets whether there is a a finalize method created that cleans up instances of DBCursor that the client does not close. If you are careful to always call the close method of DBCursor, then this can safely be set to false. Default is true.- Parameters:
cursorFinalizerEnabled
- whether cursor finalizer is enabled
-
isAlwaysUseMBeans
public boolean isAlwaysUseMBeans()Deprecated.Gets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater. If false, the driver will use MXBeans if the VM is Java 6 or greater, and use MBeans if the VM is Java 5.- Returns:
- true if the driver should always use MBeans, regardless of VM
-
setAlwaysUseMBeans
public void setAlwaysUseMBeans(boolean alwaysUseMBeans) Deprecated.Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is Java 6 or greater. If false, the driver will use MXBeans if the VM is Java 6 or greater, and use MBeans if the VM is Java 5. Default is false.- Parameters:
alwaysUseMBeans
- sets whether the driver should always use MBeans, regardless of VM
-
getRequiredReplicaSetName
Deprecated.Gets the required replica set name that this client should be connecting to.- Returns:
- the required replica set name, or null if none is required
- Since:
- 2.12
-
equals
Deprecated. -
hashCode
public int hashCode()Deprecated. -
toString
Deprecated.
-
MongoClientOptions
instead.