@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 |
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.
|
long |
getMaxAutoConnectRetryTime()
The maximum amount of time in MS to spend retrying to open connection to the same server.
|
int |
getMaxWaitTime()
The maximum wait time in milliseconds that a thread may wait for a connection to become available.
|
ReadPreference |
getReadPreference()
The read preference to use for queries, map-reduce, aggregation, and count.
|
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()
If true, the driver will keep trying to connect to the same server in case that the socket cannot be established.
|
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. |
public static MongoClientOptions.Builder builder()
new MongoClientOptions.Builder()
.public String getDescription()
public int getConnectionsPerHost()
getThreadsAllowedToBlockForConnectionMultiplier()
public int getThreadsAllowedToBlockForConnectionMultiplier()
public int getMaxWaitTime()
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.public boolean isAutoConnectRetry()
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.