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[] messages)
Tries to locate a connection that can quickly dispatch the message to a
MongoDB server.
|
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
Connection s. |
protected void |
reconnect(Connection connection)
Runs the reconnect logic for the connection.
|
send, send
protected 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[] messages) throws MongoDbException
findConnection
in class AbstractClient
messages
- The messages to be sent on the connection. The read preference
for each message should be verified as compatible with the
connection.MongoDbException
- On a failure to talk to the MongoDB servers.protected void handleConnectionClosed(Connection connection)
Connection
s. 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.