Package com.mongodb

Class MongoOptions

java.lang.Object
com.mongodb.MongoOptions

@Deprecated public class MongoOptions extends Object
Deprecated.
Please use MongoClientOptions instead.
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

    Fields
    Modifier and Type
    Field
    Description
    boolean
    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 for Mongo 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.
    If true 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 firewalls Socket.setKeepAlive(boolean) Default is false.
    int
    Deprecated.
    The socket timeout in milliseconds It is used for I/O socket read and write operations Socket.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
    Constructor
    Description
    Deprecated.
    Deprecated.
  • Method Summary

    Modifier and Type
    Method
    Description
    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 for Mongo 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
    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
    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
    Deprecated.
    Gets the "fsync" value of the global WriteConcern.
    boolean
    isJ()
    Deprecated.
    Gets the "j" value of the global WriteConcern.
    boolean
    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
    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
    Deprecated.
    Override the DBCallback factory.
    void
    Deprecated.
    Override the encoding factory.
    void
    Deprecated.
    Sets the description for Mongo 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
    Deprecated.
    Specifies the read preference.
    void
    setSafe(boolean isSafe)
    Deprecated.
    If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations.
    void
    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 firewalls Socket.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
    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
    Deprecated.
    Sets the write concern.
    void
    setWtimeout(int timeoutMS)
    Deprecated.
    Sets the "wtimeout" value of the global WriteConcern.
    Deprecated.
     

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • description

      public String description
      Deprecated.
      The description for Mongo instances created with these options. This is used in various places like logging.
    • connectionsPerHost

      public int connectionsPerHost
      Deprecated.
      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 threadsAllowedToBlockForConnectionMultiplier
      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. 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 maxWaitTime
      Deprecated.
      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 connectTimeout
      Deprecated.
      The connection timeout in milliseconds. A value of 0 means no timeout. It is used solely when establishing a new connection Socket.connect(java.net.SocketAddress, int) Default is 10,000.
    • socketTimeout

      public int socketTimeout
      Deprecated.
      The socket timeout in milliseconds It is used for I/O socket read and write operations Socket.setSoTimeout(int) Default is 0 and means no timeout.
    • socketKeepAlive

      public boolean socketKeepAlive
      Deprecated.
      This flag controls the socket keep alive feature that keeps a connection alive through firewalls Socket.setKeepAlive(boolean) Default is false.
    • readPreference

      public ReadPreference readPreference
      Deprecated.
      Specifies the read preference.
    • dbDecoderFactory

      public DBDecoderFactory dbDecoderFactory
      Deprecated.
      Override the DBCallback factory. Default is for the standard Mongo Java driver configuration.
    • dbEncoderFactory

      public DBEncoderFactory dbEncoderFactory
      Deprecated.
      Override the encoding factory. Default is for the standard Mongo Java driver configuration.
    • safe

      public boolean safe
      Deprecated.
      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.
    • w

      public int w
      Deprecated.
      The "w" value, (number of writes), of the global WriteConcern. Default is 0.
    • wtimeout

      public int wtimeout
      Deprecated.
      The "wtimeout" value of the global WriteConcern. Default is 0.
    • fsync

      public boolean fsync
      Deprecated.
      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 j
      Deprecated.
      The "j" value of the global WriteConcern. true indicates writes should wait for a journaling group commit Default is false.
    • socketFactory

      public SocketFactory socketFactory
      Deprecated.
      Sets the socket factory for creating sockets to mongod Default is SocketFactory.getDefault()
    • cursorFinalizerEnabled

      public 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.

      See Also:
    • writeConcern

      public WriteConcern 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 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.

  • Constructor Details

  • Method Details

    • reset

      public void reset()
      Deprecated.
      Reset all settings to the default.
    • copy

      public MongoOptions copy()
      Deprecated.
      Copy this MongoOptions instance into a new instance.
      Returns:
      the new MongoOptions with the same settings as this instance.
    • getWriteConcern

      public WriteConcern 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

      public void setWriteConcern(WriteConcern 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.
      Parameters:
      writeConcern - sets the write concern
    • getSocketFactory

      public SocketFactory 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

      public void setSocketFactory(SocketFactory factory)
      Deprecated.
      Sets the socket factory for creating sockets to mongod.
      Parameters:
      factory - sets the socket factory for creating sockets to mongod
    • getDescription

      public String getDescription()
      Deprecated.
      Gets the description for Mongo instances created with these options.
      Returns:
      The description for MongoClient instances created with these options
    • setDescription

      public void setDescription(String desc)
      Deprecated.
      Sets the description for Mongo instances created with these options. This is used in various places like logging.
      Parameters:
      desc - The description for Mongo 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 connection Socket.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 firewalls Socket.setKeepAlive(boolean) Default is false.
      Parameters:
      keepAlive - set connection keep-alive flag
    • getDbDecoderFactory

      public DBDecoderFactory getDbDecoderFactory()
      Deprecated.
      Gets the DBCallback factory.
      Returns:
      the DBCallback decoding factory
    • setDbDecoderFactory

      public void setDbDecoderFactory(DBDecoderFactory factory)
      Deprecated.
      Override the DBCallback factory. Default is for the standard Mongo Java driver configuration.
      Parameters:
      factory - sets the DBCallback decoding factory
    • getDbEncoderFactory

      public DBEncoderFactory getDbEncoderFactory()
      Deprecated.
      Gets the encoding factory.
      Returns:
      the encoding factory
    • setDbEncoderFactory

      public void setDbEncoderFactory(DBEncoderFactory factory)
      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.
      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.
      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

      public ReadPreference getReadPreference()
      Deprecated.
      Gets the read preference.
      Returns:
      the read preference
    • setReadPreference

      public void setReadPreference(ReadPreference readPreference)
      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

      public String 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

      public boolean equals(Object o)
      Deprecated.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Deprecated.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object