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)
BootstrapConnectionFactory
config
- 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 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 Closeable
close
in interface AutoCloseable
public Connection connect() throws IOException
Delegates the connection to the setup delegate.
connect
in interface ConnectionFactory
IOException
- On a failure connecting to the server.public ClusterType getClusterType()
Overridden to return the cluster type of the delegate
ConnectionFactory
.
getClusterType
in interface ConnectionFactory
public ReconnectStrategy getReconnectStrategy()
Overridden to return the delegates strategy.
getReconnectStrategy
in interface ConnectionFactory
protected ConnectionFactory getDelegate()
protected void setDelegate(ConnectionFactory delegate)
delegate
- The underlying delegate factory.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.