Class MongoDbShardedCluster
java.lang.Object
io.debezium.testing.testcontainers.MongoDbShardedCluster
- All Implemented Interfaces:
MongoDbDeployment,AutoCloseable,org.testcontainers.lifecycle.Startable
A MongoDB sharded cluster.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MongoDbReplicaSetprivate final org.testcontainers.utility.DockerImageNameprivate static final org.slf4j.Loggerprivate final org.testcontainers.containers.Networkprivate final PortResolverprivate final intprivate final intprivate final List<MongoDbContainer>private final intprivate final List<MongoDbReplicaSet>private boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate -
Method Summary
Modifier and TypeMethodDescriptionvoidaddShard()Invokes sh.addShard on a router to add a new shard replica set to the sharded cluster.private voidaddShard(MongoDbReplicaSet shard) Adds the previously created and started suppliedshardto the cluster.private voidAdds the previously created and started shards to the shards to the cluster.private MongoDbReplicaSetprivate MongoDbContainercreateRouter(org.testcontainers.containers.Network network, int i) private List<MongoDbContainer>private MongoDbReplicaSetcreateShard(int i) private List<MongoDbReplicaSet>voidenableSharding(String databaseName) private static StringformatReplicaSetAddress(MongoDbReplicaSet replicaSet, boolean namedAddress) getShard(int i) voidInvokes the removeShard command to remove the last addedshardfrom the sharded cluster.voidshardCollection(String databaseName, String collectionName, String keyField) intsize()voidstart()voidstop()private Stream<org.testcontainers.lifecycle.Startable>stream()private static <T> Stream<T>toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.debezium.testing.testcontainers.MongoDbDeployment
getAuthConnectionString, getNoAuthConnectionStringMethods inherited from interface org.testcontainers.lifecycle.Startable
close, getDependencies
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
shardCount
private final int shardCount -
replicaCount
private final int replicaCount -
routerCount
private final int routerCount -
network
private final org.testcontainers.containers.Network network -
portResolver
-
configServers
-
shards
-
routers
-
imageName
private final org.testcontainers.utility.DockerImageName imageName -
started
private volatile boolean started
-
-
Constructor Details
-
MongoDbShardedCluster
-
-
Method Details
-
shardedCluster
-
start
public void start()- Specified by:
startin interfaceorg.testcontainers.lifecycle.Startable
-
stop
public void stop()- Specified by:
stopin interfaceorg.testcontainers.lifecycle.Startable
-
size
public int size() -
getConnectionString
- Specified by:
getConnectionStringin interfaceMongoDbDeployment- Returns:
- the standard connection string
to the sharded cluster, comprised of only the
mongoshosts.
-
getShard
-
enableSharding
-
shardCollection
-
createShards
-
createShard
-
createConfigServers
-
createRouters
-
createRouter
-
addShard
public void addShard()Invokes sh.addShard on a router to add a new shard replica set to the sharded cluster. -
removeShard
public void removeShard()Invokes the removeShard command to remove the last addedshardfrom the sharded cluster.Waits until the state of the shard is
completedbefore shutting down the shard replica set. -
addShards
private void addShards()Adds the previously created and started shards to the shards to the cluster. -
addShard
Adds the previously created and started suppliedshardto the cluster.- Parameters:
shard- the shard to add
-
stream
-
getHostNames
-
formatReplicaSetAddress
-
toString
-
stream
-