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 Logger |
LOG
The logger for the
BootstrapConnectionFactory. |
| Constructor and Description |
|---|
BootstrapConnectionFactory(MongoClientConfiguration config)
Creates a
BootstrapConnectionFactory |
| Modifier and Type | Method and Description |
|---|---|
void |
bootstrap()
Re-bootstraps the environment.
|
void |
close() |
Connection |
connect()
Creates a connection to the address provided.
|
ClusterType |
getClusterType()
Returns the type of cluster the connection factory connects to.
|
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 Logger LOG
BootstrapConnectionFactory.public BootstrapConnectionFactory(MongoClientConfiguration config)
BootstrapConnectionFactoryconfig - The configuration to use in discovering the server
configuration.public void bootstrap()
A bootstrap will issue one commands to the first working MongoDB process.
The reply to the ServerStatus 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 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 getDelegate()
protected void setDelegate(ConnectionFactory delegate)
delegate - The underlying delegate factory.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.