public class ShardedConnectionFactory extends Object implements ConnectionFactory
| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
LOG
The logger for the
ShardedConnectionFactory. |
protected ProxiedConnectionFactory |
myConnectionFactory
The factory to create proxied connections.
|
| Constructor and Description |
|---|
ShardedConnectionFactory(ProxiedConnectionFactory factory,
MongoClientConfiguration config)
Creates a new
ShardedConnectionFactory. |
| Modifier and Type | Method and Description |
|---|---|
void |
bootstrap()
Finds the mongos servers.
|
void |
close() |
Connection |
connect()
Creates a new connection to the shared mongos servers.
|
protected ClusterState |
getClusterState()
Returns the clusterState value.
|
ClusterType |
getClusterType()
Returns the type of cluster the connection factory connects to.
|
ReconnectStrategy |
getReconnectStrategy()
Returns the reconnection strategy for the type of connections.
|
protected static final Logger LOG
ShardedConnectionFactory.protected final ProxiedConnectionFactory myConnectionFactory
public ShardedConnectionFactory(ProxiedConnectionFactory factory, MongoClientConfiguration config)
ShardedConnectionFactory.factory - The factory to create proxied connections.config - The initial configuration.public void bootstrap()
Performs a find on the config database's mongos collection to return the id for all of the mongos servers in the cluster.
A single mongos entry looks like:
{ "_id" : "mongos.example.com:27017", "ping" : ISODate("2011-12-05T23:54:03.122Z"), "up" : 330 }
public void close()
Overridden to close the cluster state and the
ProxiedConnectionFactory.
close in interface Closeableclose in interface AutoCloseablepublic Connection connect() throws IOException
connect in interface ConnectionFactoryIOException - On a failure connecting to the server.ConnectionFactory.connect()public ClusterType getClusterType()
Overridden to return ClusterType.SHARDED cluster type.
getClusterType in interface ConnectionFactorypublic ReconnectStrategy getReconnectStrategy()
Overridden to return the delegates strategy but replace his state and selector with our own.
getReconnectStrategy in interface ConnectionFactoryprotected ClusterState getClusterState()
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.