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 Details

    • REPLICA_DELIMITER_PATTERN

      private static final Pattern REPLICA_DELIMITER_PATTERN
    • replicaSetsByName

      private final Map<String,ReplicaSet> replicaSetsByName
    • nonReplicaSets

      private final List<ReplicaSet> nonReplicaSets
  • Constructor Details

    • 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 Details

    • 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:
    • 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 subdivisions
      subdivisionConsumer - the function to be called with each subdivision; may not be null
    • all

      public List<ReplicaSet> all()
      Get a copy of all of the ReplicaSet objects.
      Returns:
      the replica set objects; never null but possibly empty
    • validReplicaSets

      public List<ReplicaSet> validReplicaSets()
      Get a copy of all of the valid ReplicaSet objects 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 the ReplicaSet objects 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:
      true if the replica sets have changed since the prior state, or false otherwise
    • 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:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object