Package io.debezium.connector.mongodb
Class ReplicaSets
- java.lang.Object
-
- io.debezium.connector.mongodb.ReplicaSets
-
@Immutable public class ReplicaSets extends Object
A set of replica set specifications.- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description private List<ReplicaSet>nonReplicaSetsprivate static PatternREPLICA_DELIMITER_PATTERNprivate Map<String,ReplicaSet>replicaSetsByName
-
Constructor Summary
Constructors Constructor Description ReplicaSets(Collection<ReplicaSet> rsSpecs)Create a set of replica set specifications.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ReplicaSet>all()Get a copy of all of theReplicaSetobjects.static ReplicaSetsempty()Get an instance that contains no replica sets.booleanequals(Object obj)inthashCode()booleanhaveChangedSince(ReplicaSets priorState)Determine if one or more replica sets has been added or removed since the prior state.Stringhosts()Get the string containing the host names for the replica sets.voidonEachReplicaSet(Consumer<ReplicaSet> function)Perform the supplied function on each of the replica setsstatic ReplicaSetsparse(String hosts)Parse the supplied string for the information about the replica set hosts.intreplicaSetCount()Get the number of replica sets.voidsubdivide(int maxSubdivisionCount, Consumer<ReplicaSets> subdivisionConsumer)Subdivide this collection of replica sets into the maximum number of groups.StringtoString()List<ReplicaSet>unnamedReplicaSets()Get a copy of all of theReplicaSetobjects that have no names.intvalidReplicaSetCount()Get the number of replica sets with names.List<ReplicaSet>validReplicaSets()Get a copy of all of the validReplicaSetobjects that have names.
-
-
-
Field Detail
-
REPLICA_DELIMITER_PATTERN
private static final Pattern REPLICA_DELIMITER_PATTERN
-
replicaSetsByName
private final Map<String,ReplicaSet> replicaSetsByName
-
nonReplicaSets
private final List<ReplicaSet> nonReplicaSets
-
-
Constructor Detail
-
ReplicaSets
public ReplicaSets(Collection<ReplicaSet> rsSpecs)
Create a set of replica set specifications.- Parameters:
rsSpecs- the replica set specifications; may be null or empty
-
-
Method Detail
-
parse
public static ReplicaSets parse(String hosts)
Parse the supplied string for the information about the replica set hosts. The string is a semicolon-delimited list of shard hosts (e.g., "shard01=replicaSet1/host1:27017,host2:27017"), replica set hosts (e.g., "replicaSet1/host1:27017,host2:27017"), and standalone hosts (e.g., "host1:27017" or "1.2.3.4:27017").- Parameters:
hosts- the hosts string; may be null- Returns:
- the replica sets; never null but possibly empty
- See Also:
hosts()
-
empty
public static ReplicaSets empty()
Get an instance that contains no replica sets.- Returns:
- the empty instance; never null
-
replicaSetCount
public int replicaSetCount()
Get the number of replica sets.- Returns:
- the replica set count
-
validReplicaSetCount
public int validReplicaSetCount()
Get the number of replica sets with names.- Returns:
- the valid replica set count
-
onEachReplicaSet
public void onEachReplicaSet(Consumer<ReplicaSet> function)
Perform the supplied function on each of the replica sets- Parameters:
function- the consumer function; may not be null
-
subdivide
public void subdivide(int maxSubdivisionCount, Consumer<ReplicaSets> subdivisionConsumer)Subdivide this collection of replica sets into the maximum number of groups.- Parameters:
maxSubdivisionCount- the maximum number of subdivisionssubdivisionConsumer- the function to be called with each subdivision; may not be null
-
all
public List<ReplicaSet> all()
Get a copy of all of theReplicaSetobjects.- Returns:
- the replica set objects; never null but possibly empty
-
validReplicaSets
public List<ReplicaSet> validReplicaSets()
Get a copy of all of the validReplicaSetobjects that have names.- Returns:
- the valid replica set objects; never null but possibly empty
-
unnamedReplicaSets
public List<ReplicaSet> unnamedReplicaSets()
Get a copy of all of theReplicaSetobjects that have no names.- Returns:
- the unnamed replica set objects; never null but possibly empty
-
haveChangedSince
public boolean haveChangedSince(ReplicaSets priorState)
Determine if one or more replica sets has been added or removed since the prior state.- Parameters:
priorState- the prior state of the replica sets; may be null- Returns:
trueif the replica sets have changed since the prior state, orfalseotherwise
-
hosts
public String hosts()
Get the string containing the host names for the replica sets. The result is a string with each replica set hosts separated by a semicolon.- Returns:
- the host names; never null
- See Also:
parse(String)
-
-