com.mongodb
Class Mongo

A database connection with internal pooling.
For most application, you should have 1 Mongo instance for the entire JVM.
The following are equivalent, and all connect to the
local database running on the default port:

Mongo instances have connection pooling built in - see the requestStart
and requestDone methods for more information.
http://www.mongodb.org/display/DOCS/Java+Driver+Concurrency

Connecting to a Replica Pair

You can connect to a
replica pair
using the Java driver by passing two DBAddresses to the Mongo constructor.
For example:

DBAddress left = new DBAddress("127.0.0.1:27017/test");
DBAddress right = new DBAddress("127.0.0.1:27018/test");
Mongo mongo = new Mongo(left, right);

If the master of a replica pair goes down, there will be a brief lag before
the slave becomes master. Thus, your application should be prepared to catch
the exceptions that might be thrown in such a case: IllegalArgumentException,
MongoException, and MongoException.Network (depending on when the connection
drops).

Once the slave becomes master, the driver will begin using that connection
as the master connection and the exceptions will stop being thrown.

Connecting to a Replica Set

You can connect to a
replica set
using the Java driver by passing several a list if ServerAddress to the
Mongo constructor.
For example:

getOptions

getMongoOptions

getMaxBsonObjectSize

public int getMaxBsonObjectSize()

Gets the maximum size for a BSON object supported by the current master server.
Note that this value may change over time depending on which server is master.
If the size is not known yet, a request may be sent to the master server