com.mongodb
Class DBTCPConnector

java.lang.Object
  extended by com.mongodb.DBTCPConnector
All Implemented Interfaces:
DBConnector

public class DBTCPConnector
extends Object
implements DBConnector


Constructor Summary
DBTCPConnector(Mongo m, List<ServerAddress> all)
           
DBTCPConnector(Mongo m, ServerAddress... all)
           
DBTCPConnector(Mongo m, ServerAddress addr)
           
 
Method Summary
 com.mongodb.Response call(DB db, DBCollection coll, com.mongodb.OutMessage m, ServerAddress hostNeeded, DBDecoder decoder)
          does a read operation on the database
 com.mongodb.Response call(DB db, DBCollection coll, com.mongodb.OutMessage m, ServerAddress hostNeeded, int retries)
          does a read operation on the database
 com.mongodb.Response call(DB db, DBCollection coll, com.mongodb.OutMessage m, ServerAddress hostNeeded, int retries, ReadPreference readPref, DBDecoder decoder)
          does a read operation on the database
 void close()
           
 String debugString()
           
 ServerAddress getAddress()
           
 List<ServerAddress> getAllAddress()
          Gets the list of seed server addresses
 String getConnectPoint()
           
 DBPortPool getDBPortPool(ServerAddress addr)
          Gets the DBPortPool associated with a ServerAddress.
 int getMaxBsonObjectSize()
          Gets the maximum size for a BSON object supported by the current master server.
 ReplicaSetStatus getReplicaSetStatus()
           
 List<ServerAddress> getServerAddressList()
          Gets the list of server addresses currently seen by the connector.
 boolean isOpen()
          returns true if the connector is in a usable state
 void requestDone()
          End the current "request", if this thread is in one.
 void requestEnsureConnection()
          Ensures that a connection exists for the "consistent request"
 void requestStart()
          Start a "request".
 WriteResult say(DB db, com.mongodb.OutMessage m, WriteConcern concern)
          does a write operation
 WriteResult say(DB db, com.mongodb.OutMessage m, WriteConcern concern, ServerAddress hostNeeded)
          does a write operation
 void start()
           
 void updatePortPool(ServerAddress addr)
          Assigns a new DBPortPool for a given ServerAddress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBTCPConnector

public DBTCPConnector(Mongo m,
                      ServerAddress addr)
Parameters:
m -
addr -
Throws:
MongoException

DBTCPConnector

public DBTCPConnector(Mongo m,
                      ServerAddress... all)
Parameters:
m -
all -
Throws:
MongoException

DBTCPConnector

public DBTCPConnector(Mongo m,
                      List<ServerAddress> all)
Parameters:
m -
all -
Throws:
MongoException
Method Detail

start

public void start()

requestStart

public void requestStart()
Start a "request". A "request" is a group of operations in which order matters. Examples include inserting a document and then performing a query which expects that document to have been inserted, or performing an operation and then using com.mongodb.Mongo.getLastError to perform error-checking on that operation. When a thread performs operations in a "request", all operations will be performed on the same socket, so they will be correctly ordered.

Specified by:
requestStart in interface DBConnector

requestDone

public void requestDone()
End the current "request", if this thread is in one. By ending a request when it is safe to do so the built-in connection- pool is allowed to reassign requests to different sockets in order to more effectively balance load. See requestStart for more information.

Specified by:
requestDone in interface DBConnector

requestEnsureConnection

public void requestEnsureConnection()
Description copied from interface: DBConnector
Ensures that a connection exists for the "consistent request"

Specified by:
requestEnsureConnection in interface DBConnector
Throws:
MongoException

say

public WriteResult say(DB db,
                       com.mongodb.OutMessage m,
                       WriteConcern concern)
Description copied from interface: DBConnector
does a write operation

Specified by:
say in interface DBConnector
Parameters:
db -
m -
concern -
Returns:
Throws:
MongoException

say

public WriteResult say(DB db,
                       com.mongodb.OutMessage m,
                       WriteConcern concern,
                       ServerAddress hostNeeded)
Description copied from interface: DBConnector
does a write operation

Specified by:
say in interface DBConnector
Parameters:
db -
m -
concern -
hostNeeded -
Returns:
Throws:
MongoException

call

public com.mongodb.Response call(DB db,
                                 DBCollection coll,
                                 com.mongodb.OutMessage m,
                                 ServerAddress hostNeeded,
                                 DBDecoder decoder)
Description copied from interface: DBConnector
does a read operation on the database

Specified by:
call in interface DBConnector
Parameters:
db -
coll -
m -
hostNeeded -
decoder -
Returns:
Throws:
MongoException

call

public com.mongodb.Response call(DB db,
                                 DBCollection coll,
                                 com.mongodb.OutMessage m,
                                 ServerAddress hostNeeded,
                                 int retries)
Description copied from interface: DBConnector
does a read operation on the database

Specified by:
call in interface DBConnector
Parameters:
db -
coll -
m -
hostNeeded -
retries -
Returns:
Throws:
MongoException

call

public com.mongodb.Response call(DB db,
                                 DBCollection coll,
                                 com.mongodb.OutMessage m,
                                 ServerAddress hostNeeded,
                                 int retries,
                                 ReadPreference readPref,
                                 DBDecoder decoder)
Description copied from interface: DBConnector
does a read operation on the database

Specified by:
call in interface DBConnector
Parameters:
db -
coll -
m -
hostNeeded -
readPref -
decoder -
retries - number of retries in case of error
Returns:
Throws:
MongoException

getAddress

public ServerAddress getAddress()

getAllAddress

public List<ServerAddress> getAllAddress()
Gets the list of seed server addresses

Returns:

getServerAddressList

public List<ServerAddress> getServerAddressList()
Gets the list of server addresses currently seen by the connector. This includes addresses auto-discovered from a replica set.

Returns:
Throws:
MongoException

getReplicaSetStatus

public ReplicaSetStatus getReplicaSetStatus()

getConnectPoint

public String getConnectPoint()

debugString

public String debugString()

close

public void close()

updatePortPool

public void updatePortPool(ServerAddress addr)
Assigns a new DBPortPool for a given ServerAddress. This is used to obtain a new pool when the resolved IP of a host changes, for example. User application should not have to call this method directly.

Parameters:
addr -

getDBPortPool

public DBPortPool getDBPortPool(ServerAddress addr)
Gets the DBPortPool associated with a ServerAddress.

Parameters:
addr -
Returns:

isOpen

public boolean isOpen()
Description copied from interface: DBConnector
returns true if the connector is in a usable state

Specified by:
isOpen in interface DBConnector
Returns:

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.

Returns:
the maximum size, or 0 if not obtained from servers yet.