public class

DBTCPConnector

extends Object
implements DBConnector
java.lang.Object
   ↳ com.mongodb.DBTCPConnector

Summary

Public Constructors
DBTCPConnector(Mongo m, ServerAddress addr)
DBTCPConnector(Mongo m, ServerAddress... all)
DBTCPConnector(Mongo m, List<ServerAddress> all)
Public Methods
Response call(DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, int retries)
does a read operation on the database
Response call(DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, DBDecoder decoder)
does a read operation on the database
Response call(DB db, DBCollection coll, 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, OutMessage m, WriteConcern concern, ServerAddress hostNeeded)
does a write operation
WriteResult say(DB db, OutMessage m, WriteConcern concern)
does a write operation
void start()
void updatePortPool(ServerAddress addr)
Assigns a new DBPortPool for a given ServerAddress.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.mongodb.DBConnector

Public Constructors

public DBTCPConnector (Mongo m, ServerAddress addr)

public DBTCPConnector (Mongo m, ServerAddress... all)

public DBTCPConnector (Mongo m, List<ServerAddress> all)

Public Methods

public Response call (DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, int retries)

does a read operation on the database

Parameters
db the database
coll the collection
m the request message
hostNeeded specific server to connect to
retries the number of retries in case of an error
Returns
  • the read result

public Response call (DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, DBDecoder decoder)

does a read operation on the database

Parameters
db the database
coll the collection
m the request message
hostNeeded specific server to connect to
decoder the decoder to use
Returns
  • the read result

public Response call (DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, int retries, ReadPreference readPref, DBDecoder decoder)

does a read operation on the database

Parameters
db the database
coll the collection
m the request message
hostNeeded specific server to connect to
retries number of retries in case of error
readPref the read preferences
decoder the decoder to use
Returns
  • the read result

public void close ()

public String debugString ()

public ServerAddress getAddress ()

public List<ServerAddress> getAllAddress ()

Gets the list of seed server addresses

public String getConnectPoint ()

public DBPortPool getDBPortPool (ServerAddress addr)

Gets the DBPortPool associated with a ServerAddress.

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.

public ReplicaSetStatus getReplicaSetStatus ()

public List<ServerAddress> getServerAddressList ()

Gets the list of server addresses currently seen by the connector. This includes addresses auto-discovered from a replica set.

public boolean isOpen ()

returns true if the connector is in a usable state

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.

public void requestEnsureConnection ()

Ensures that a connection exists for the "consistent request"

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.

public WriteResult say (DB db, OutMessage m, WriteConcern concern, ServerAddress hostNeeded)

does a write operation

Parameters
db the database
m the request message
concern the write concern
hostNeeded specific server to connect to
Returns
  • the write result

public WriteResult say (DB db, OutMessage m, WriteConcern concern)

does a write operation

Parameters
db the database
m the request message
concern the write concern
Returns
  • the write result

public void start ()

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.