public class ReplicaSetConnectionFactory extends Object implements ConnectionFactory
Modifier and Type | Field and Description |
---|---|
protected static Log |
LOG
The logger for the
ReplicaSetConnectionFactory . |
protected ProxiedConnectionFactory |
myConnectionFactory
The factory to create proxied connections.
|
Constructor and Description |
---|
ReplicaSetConnectionFactory(ProxiedConnectionFactory factory,
MongoClientConfiguration config)
Creates a new
ReplicaSetConnectionFactory . |
Modifier and Type | Method and Description |
---|---|
void |
bootstrap()
Finds the primary member of the replica set.
|
void |
close() |
Connection |
connect()
Creates a new connection to the replica set.
|
protected Cluster |
getCluster()
Returns the clusterState value.
|
ClusterStats |
getClusterStats()
Returns the meta-data on the current cluster.
|
ClusterType |
getClusterType()
Returns the type of cluster the connection factory connects to.
|
ReconnectStrategy |
getReconnectStrategy()
Returns the reconnection strategy for the type of connections.
|
protected boolean |
isWritable(Server server,
Connection connection)
Determines if the connection is to the primary member of the cluster.
|
protected List<Server> |
locatePrimary()
Locates the primary server in the cluster.
|
protected static final Log LOG
ReplicaSetConnectionFactory
.protected final ProxiedConnectionFactory myConnectionFactory
public ReplicaSetConnectionFactory(ProxiedConnectionFactory factory, MongoClientConfiguration config)
ReplicaSetConnectionFactory
.factory
- The factory to create proxied connections.config
- The MongoDB client configuration.public void bootstrap()
public void close()
Overridden to close the cluster state and the
ProxiedConnectionFactory
.
close
in interface Closeable
close
in interface AutoCloseable
public Connection connect() throws IOException
connect
in interface ConnectionFactory
IOException
- On a failure connecting to the server.ConnectionFactory.connect()
public ClusterStats getClusterStats()
Overridden to return the Cluster
.
getClusterStats
in interface ConnectionFactory
public ClusterType getClusterType()
Overridden to return ClusterType.REPLICA_SET
cluster type.
getClusterType
in interface ConnectionFactory
public ReconnectStrategy getReconnectStrategy()
Overridden to return a replica set ReconnectStrategy
.
getReconnectStrategy
in interface ConnectionFactory
protected Cluster getCluster()
protected boolean isWritable(Server server, Connection connection)
server
- The server connected to.connection
- The connection to test.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.