public class MongoOptions
extends java.lang.Object
MongoClientOptions
,
MongoClient
Modifier and Type | Field and Description |
---|---|
boolean |
alwaysUseMBeans
Sets whether JMX beans registered by the driver should always be MBeans, regardless of whether the VM is
Java 6 or greater.
|
boolean |
autoConnectRetry
If true, the driver will keep trying to connect to the same server in case that the socket cannot be established.
|
int |
connectionsPerHost
The maximum number of connections allowed per host for this Mongo instance.
|
int |
connectTimeout
The connection timeout in milliseconds.
|
boolean |
cursorFinalizerEnabled
Sets whether there is a a finalize method created that cleans up instances of DBCursor that the client
does not close.
|
DBDecoderFactory |
dbDecoderFactory
Override the DBCallback factory.
|
DBEncoderFactory |
dbEncoderFactory
Override the encoding factory.
|
java.lang.String |
description
The description for
Mongo instances created with these options. |
boolean |
fsync
The "fsync" value of the global WriteConcern.
|
boolean |
j
The "j" value of the global WriteConcern.
|
long |
maxAutoConnectRetryTime
The maximum amount of time in MS to spend retrying to open connection to the same server.
|
int |
maxWaitTime
The maximum wait time in milliseconds that a thread may wait for a connection to become available.
|
ReadPreference |
readPreference
Specifies the read preference.
|
boolean |
safe
If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations.
|
boolean |
slaveOk
Deprecated.
Replaced with
ReadPreference.secondaryPreferred() |
javax.net.SocketFactory |
socketFactory
sets the socket factory for creating sockets to mongod
Default is SocketFactory.getDefault()
|
boolean |
socketKeepAlive
This flag controls the socket keep alive feature that keeps a connection alive through firewalls
Socket.setKeepAlive(boolean)
Default is false. |
int |
socketTimeout
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 |
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.
|
int |
w
The "w" value, (number of writes), of the global WriteConcern.
|
WriteConcern |
writeConcern
Sets the write concern.
|
int |
wtimeout
The "wtimeout" value of the global WriteConcern.
|
Constructor and Description |
---|
MongoOptions()
Deprecated.
|
MongoOptions(MongoClientOptions options)
Deprecated.
Replaced by
MongoClientOptions |
Modifier and Type | Method and Description |
---|---|
MongoOptions |
copy() |
boolean |
equals(java.lang.Object o) |
int |
getConnectionsPerHost() |
int |
getConnectTimeout() |
DBDecoderFactory |
getDbDecoderFactory() |
DBEncoderFactory |
getDbEncoderFactory() |
java.lang.String |
getDescription() |
long |
getMaxAutoConnectRetryTime() |
int |
getMaxWaitTime() |
ReadPreference |
getReadPreference() |
javax.net.SocketFactory |
getSocketFactory() |
int |
getSocketTimeout() |
int |
getThreadsAllowedToBlockForConnectionMultiplier() |
int |
getW() |
WriteConcern |
getWriteConcern()
Helper method to return the appropriate WriteConcern instance based on the current related options settings.
|
int |
getWtimeout() |
int |
hashCode() |
boolean |
isAlwaysUseMBeans() |
boolean |
isAutoConnectRetry() |
boolean |
isCursorFinalizerEnabled() |
boolean |
isFsync() |
boolean |
isJ() |
boolean |
isSafe() |
boolean |
isSocketKeepAlive() |
void |
reset() |
void |
setAlwaysUseMBeans(boolean alwaysUseMBeans) |
void |
setAutoConnectRetry(boolean retry) |
void |
setConnectionsPerHost(int connections) |
void |
setConnectTimeout(int timeoutMS) |
void |
setCursorFinalizerEnabled(boolean cursorFinalizerEnabled) |
void |
setDbDecoderFactory(DBDecoderFactory factory) |
void |
setDbEncoderFactory(DBEncoderFactory factory) |
void |
setDescription(java.lang.String desc) |
void |
setFsync(boolean sync) |
void |
setJ(boolean safe) |
void |
setMaxAutoConnectRetryTime(long retryTimeMS) |
void |
setMaxWaitTime(int timeMS) |
void |
setReadPreference(ReadPreference readPreference) |
void |
setSafe(boolean isSafe) |
void |
setSocketFactory(javax.net.SocketFactory factory) |
void |
setSocketKeepAlive(boolean keepAlive) |
void |
setSocketTimeout(int timeoutMS) |
void |
setThreadsAllowedToBlockForConnectionMultiplier(int threads) |
void |
setW(int val) |
void |
setWriteConcern(WriteConcern writeConcern) |
void |
setWtimeout(int timeoutMS) |
java.lang.String |
toString() |
public java.lang.String description
The description for Mongo
instances created with these options. This is used in various places like logging.
public int connectionsPerHost
MongoOptions#threadsAllowedToBlockForConnectionMultiplier}
public int threadsAllowedToBlockForConnectionMultiplier
public int maxWaitTime
public int connectTimeout
Socket.connect(java.net.SocketAddress, int)
Default is 10,000.public int socketTimeout
Socket.setSoTimeout(int)
Default is 0 and means no timeout.public boolean socketKeepAlive
Socket.setKeepAlive(boolean)
Default is false.public boolean autoConnectRetry
public long maxAutoConnectRetryTime
@Deprecated public boolean slaveOk
ReadPreference.secondaryPreferred()
ReadPreference.secondaryPreferred()
public ReadPreference readPreference
public DBDecoderFactory dbDecoderFactory
public DBEncoderFactory dbEncoderFactory
public boolean safe
public int w
public int wtimeout
public boolean fsync
public boolean j
public javax.net.SocketFactory socketFactory
public boolean cursorFinalizerEnabled
Default is true.
public WriteConcern writeConcern
public boolean alwaysUseMBeans
Default is false.
@Deprecated public MongoOptions()
@Deprecated public MongoOptions(MongoClientOptions options)
MongoClientOptions
public void reset()
public MongoOptions copy()
public WriteConcern getWriteConcern()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getDescription()
MongoClient
instances created with these optionspublic void setDescription(java.lang.String desc)
desc
- The description for Mongo
instances created with these optionspublic int getConnectionsPerHost()
public void setConnectionsPerHost(int connections)
connections
- sets the maximum number of connections allowed per host for this Mongo instancepublic int getThreadsAllowedToBlockForConnectionMultiplier()
public void setThreadsAllowedToBlockForConnectionMultiplier(int threads)
threads
- multiplied with connectionsPerHost, sets the maximum number of threads that
may be waiting for a connectionpublic int getMaxWaitTime()
public void setMaxWaitTime(int timeMS)
timeMS
- set the maximum time in milliseconds that threads wait for a connectionpublic int getConnectTimeout()
public void setConnectTimeout(int timeoutMS)
timeoutMS
- set the connection timeout in milliseconds.public int getSocketTimeout()
public void setSocketTimeout(int timeoutMS)
timeoutMS
- set the socket timeout in millisecondspublic boolean isSocketKeepAlive()
public void setSocketKeepAlive(boolean keepAlive)
keepAlive
- set connection keep-alive flagpublic boolean isAutoConnectRetry()
public void setAutoConnectRetry(boolean retry)
retry
- sets keep trying connection flagpublic long getMaxAutoConnectRetryTime()
public void setMaxAutoConnectRetryTime(long retryTimeMS)
retryTimeMS
- set max time in MS to retrying open connectionpublic DBDecoderFactory getDbDecoderFactory()
public void setDbDecoderFactory(DBDecoderFactory factory)
factory
- sets the DBCallback decoding factorypublic DBEncoderFactory getDbEncoderFactory()
public void setDbEncoderFactory(DBEncoderFactory factory)
factory
- sets the encoding factorypublic boolean isSafe()
public void setSafe(boolean isSafe)
isSafe
- true if driver uses WriteConcern.SAFE for all operations.public int getW()
public void setW(int val)
val
- set the number of writes of the global WriteConcern.public int getWtimeout()
public void setWtimeout(int timeoutMS)
timeoutMS
- sets timeout for write operationpublic boolean isFsync()
public void setFsync(boolean sync)
sync
- sets global write concern's fsync safe valuepublic boolean isJ()
public void setJ(boolean safe)
safe
- sets global write concern's journal safe valuepublic void setWriteConcern(WriteConcern writeConcern)
writeConcern
- sets the write concernpublic javax.net.SocketFactory getSocketFactory()
public void setSocketFactory(javax.net.SocketFactory factory)
factory
- sets the socket factory for creating sockets to mongodpublic ReadPreference getReadPreference()
public void setReadPreference(ReadPreference readPreference)
readPreference
- the read preferencepublic boolean isCursorFinalizerEnabled()
public void setCursorFinalizerEnabled(boolean cursorFinalizerEnabled)
cursorFinalizerEnabled
- whether cursor finalizer is enabledpublic boolean isAlwaysUseMBeans()
public void setAlwaysUseMBeans(boolean alwaysUseMBeans)
alwaysUseMBeans
- sets whether the driver should always use MBeans, regardless of VMpublic java.lang.String toString()
toString
in class java.lang.Object