public class ClientImpl extends AbstractClient
Client interface which all requests to
the MongoDB servers pass.| Modifier and Type | Class and Description |
|---|---|
protected class |
ClientImpl.ConnectionListener
ConnectionListener provides the call back for events occurring on a
connection.
|
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
LOG
The logger for the
ClientImpl. |
static int |
MAX_CONNECTION_SCAN
The maximum number of connections to scan looking for idle/lightly used
connections.
|
MAX_DOCUMENT_SIZE| Constructor and Description |
|---|
ClientImpl(MongoClientConfiguration config)
Create a new ClientImpl.
|
ClientImpl(MongoClientConfiguration config,
ConnectionFactory connectionFactory)
Create a new ClientImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the client.
|
protected Connection |
findConnection(Message message1,
Message message2)
Locates a
Connection to send a message on. |
ClusterType |
getClusterType()
Returns the type of cluster the client is connected to.
|
MongoClientConfiguration |
getConfig()
Returns the configuration being used by the logical MongoDB connection.
|
int |
getConnectionCount()
Returns the current number of open connections.
|
Durability |
getDefaultDurability()
Returns the
Durability from the MongoClientConfiguration. |
ReadPreference |
getDefaultReadPreference()
Returns the
ReadPreference from the
MongoClientConfiguration. |
protected void |
handleConnectionClosed(Connection connection)
Tries to reconnect previously open
Connections. |
protected void |
reconnect(Connection connection)
Runs the reconnect logic for the connection.
|
send, sendpublic static final int MAX_CONNECTION_SCAN
protected static final Logger LOG
ClientImpl.public ClientImpl(MongoClientConfiguration config)
config - The configuration for interacting with MongoDB.public ClientImpl(MongoClientConfiguration config, ConnectionFactory connectionFactory)
config - The configuration for interacting with MongoDB.connectionFactory - The source of connection for the client.public void close()
Overridden to close all of the open connections.
Closeable.close()public ClusterType getClusterType()
Overridden to return the ClusterType of the
ConnectionFactory.
public MongoClientConfiguration getConfig()
Overridden to return the configuration used when the client was constructed.
public int getConnectionCount()
public Durability getDefaultDurability()
Durability from the MongoClientConfiguration.
Overridden to return the configurations default durability.
MongoClientConfiguration.Client.getDefaultDurability()public ReadPreference getDefaultReadPreference()
ReadPreference from the
MongoClientConfiguration.
Overridden to return the configurations default read preference.
MongoClientConfiguration .Client.getDefaultReadPreference()protected Connection findConnection(Message message1, Message message2) throws MongoDbException
Connection to send a message on.
Tries to locate a connection that can quickly dispatch the message to a MongoDB server. The basic metrics for determining if a connection is idle is to look at the number of messages waiting to be sent. The basic logic for finding a connection is:
findConnection in class AbstractClientmessage1 - The first message that will be sent. The connection return
should be compatible with all of the messages
ReadPreference.message2 - The second message that will be sent. The connection return
should be compatible with all of the messages
ReadPreference. May be null.Connection to send a message on.MongoDbException - In the case of an error finding a Connection.protected void handleConnectionClosed(Connection connection)
Connections. If a connection
was being closed then cleans up the remaining state.connection - The connection that was closed.protected void reconnect(Connection connection)
connection - The connection to reconnect.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.