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. |
| Constructor and Description |
|---|
ClientImpl(MongoDbConfiguration config)
Create a new ClientImpl.
|
ClientImpl(MongoDbConfiguration 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.
|
MongoDbConfiguration |
getConfig()
Returns the configuration being used by the logical MongoDB connection.
|
Durability |
getDefaultDurability()
Returns the
Durability from the MongoDbConfiguration. |
ReadPreference |
getDefaultReadPreference()
Returns the
ReadPreference from the MongoDbConfiguration. |
protected void |
handleConnectionClosed(Connection connection)
Tries to reconnect previously open
Connections. |
protected void |
reconnect(Connection connection)
Runs the reconnect logic for the connection.
|
send, sendprotected static final Logger LOG
ClientImpl.public ClientImpl(MongoDbConfiguration config)
config - The configuration for interacting with MongoDB.public ClientImpl(MongoDbConfiguration 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 MongoDbConfiguration getConfig()
Overridden to return the configuration used when the client was constructed.
public Durability getDefaultDurability()
Durability from the MongoDbConfiguration.
Overridden to return the configurations default durability.
MongoDbConfiguration.Client.getDefaultDurability()public ReadPreference getDefaultReadPreference()
ReadPreference from the MongoDbConfiguration.
Overridden to return the configurations default read preference.
MongoDbConfiguration
.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-2012 Allanbank Consulting, Inc.. All Rights Reserved.