Package io.debezium.connector.mongodb
Class ReplicaSetDiscovery
java.lang.Object
io.debezium.connector.mongodb.ReplicaSetDiscovery
A component that monitors a single replica set or the set of replica sets that make up the shards in a sharded cluster.
- Author:
- Randall Hauch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe database that might be used to check for member information in a replica set.static final StringThe database that might be used to check for replica set information in a sharded cluster.private final MongoDbTaskContextprivate static final org.slf4j.Loggerprivate final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringensureReplicaSetName(String connectionString, com.mongodb.connection.ClusterDescription clusterDescription) Ensures connection string contains the replicaSet parameter.If connection string doesn't contain the parameter, the replica set name is read from cluster description and the parameter is added.getReplicaSets(com.mongodb.client.MongoClient client) Connect to the shard cluster or replica set defined by the seed addresses, and obtain the specifications for each of the replica sets.private voidreadReplicaSetsFromCluster(Set<ReplicaSet> replicaSetSpecs, com.mongodb.connection.ClusterDescription clusterDescription, ConnectionContext connectionContext) private voidreadReplicaSetsFromShardedCluster(Set<ReplicaSet> replicaSetSpecs, com.mongodb.client.MongoClient client) private voidreadShardedClusterAsReplicaSet(Set<ReplicaSet> replicaSetSpecs, ConnectionContext connectionContext)
-
Field Details
-
CONFIG_DATABASE_NAME
The database that might be used to check for replica set information in a sharded cluster.- See Also:
-
SHARDS_COLLECTION_NAME
- See Also:
-
ADMIN_DATABASE_NAME
The database that might be used to check for member information in a replica set.- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
context
-
maskedConnectionSeed
-
-
Constructor Details
-
ReplicaSetDiscovery
Create a cluster component.- Parameters:
context- the replication context; may not be null
-
-
Method Details
-
getReplicaSets
Connect to the shard cluster or replica set defined by the seed addresses, and obtain the specifications for each of the replica sets.- Returns:
- the information about the replica sets; never null but possibly empty
-
readShardedClusterAsReplicaSet
private void readShardedClusterAsReplicaSet(Set<ReplicaSet> replicaSetSpecs, ConnectionContext connectionContext) -
readReplicaSetsFromCluster
private void readReplicaSetsFromCluster(Set<ReplicaSet> replicaSetSpecs, com.mongodb.connection.ClusterDescription clusterDescription, ConnectionContext connectionContext) -
readReplicaSetsFromShardedCluster
private void readReplicaSetsFromShardedCluster(Set<ReplicaSet> replicaSetSpecs, com.mongodb.client.MongoClient client) -
ensureReplicaSetName
private String ensureReplicaSetName(String connectionString, com.mongodb.connection.ClusterDescription clusterDescription) Ensures connection string contains the replicaSet parameter.If connection string doesn't contain the parameter, the replica set name is read from cluster description and the parameter is added.- Parameters:
connectionString- the original connection stringclusterDescription- cluster description- Returns:
- connection string with replicaSet parameter
-