public class BootstrapConnectionFactory extends Object implements ConnectionFactory
ConnectionFactory based on the configuration of the server(s)
connected to.| Modifier and Type | Field and Description |
|---|---|
protected static Log |
LOG
The logger for the
BootstrapConnectionFactory. |
| Constructor and Description |
|---|
BootstrapConnectionFactory(MongoClientConfiguration config)
Creates a
BootstrapConnectionFactory |
| Modifier and Type | Method and Description |
|---|---|
protected void |
bootstrap()
Re-bootstraps the environment.
|
protected ConnectionFactory |
bootstrapReplicaSet(ProxiedConnectionFactory factory)
Initializes the factory for connecting to the replica set.
|
protected ConnectionFactory |
bootstrapSharded(ProxiedConnectionFactory factory)
Initializes the factory for connecting to the sharded cluster.
|
void |
close() |
Connection |
connect()
Creates a connection to the address provided.
|
ClusterStats |
getClusterStats()
Returns the meta-data on the current cluster.
|
ClusterType |
getClusterType()
Returns the type of cluster the connection factory connects to.
|
protected MongoClientConfiguration |
getConfig()
The configuration for the client.
|
protected ConnectionFactory |
getDelegate()
Returns the underlying delegate factory.
|
ReconnectStrategy |
getReconnectStrategy()
Returns the reconnection strategy for the type of connections.
|
protected void |
setDelegate(ConnectionFactory delegate)
Sets the underlying delegate factory.
|
protected static final Log LOG
BootstrapConnectionFactory.public BootstrapConnectionFactory(MongoClientConfiguration config)
BootstrapConnectionFactoryconfig - The configuration to use in discovering the server
configuration.protected void bootstrap()
A bootstrap will issue one commands to the first working MongoDB process.
The reply to the IsMaster command is used to detect connecting to
a mongos process and by extension a Sharded configuration.
If not using a Sharded configuration then the server status is checked for a repl element. If present a Replication Set configuration is assumed.
If neither a Sharded or Replication Set is being used then a plain socket connection factory is used.
public void close()
Overridden to close the delegate ConnectionFactory.
close in interface Closeableclose in interface AutoCloseablepublic Connection connect() throws IOException
Delegates the connection to the setup delegate.
connect in interface ConnectionFactoryIOException - On a failure connecting to the server.public ClusterStats getClusterStats()
Overridden to return the cluster stats of the proxied
ConnectionFactory.
getClusterStats in interface ConnectionFactorypublic ClusterType getClusterType()
Overridden to return the cluster type of the delegate
ConnectionFactory.
getClusterType in interface ConnectionFactorypublic ReconnectStrategy getReconnectStrategy()
Overridden to return the delegates strategy.
getReconnectStrategy in interface ConnectionFactoryprotected ConnectionFactory bootstrapReplicaSet(ProxiedConnectionFactory factory)
factory - The factory for connecting to the servers directly.protected ConnectionFactory bootstrapSharded(ProxiedConnectionFactory factory)
factory - The factory for connecting to the servers directly.protected MongoClientConfiguration getConfig()
protected ConnectionFactory getDelegate()
protected void setDelegate(ConnectionFactory delegate)
delegate - The underlying delegate factory.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.