Class ReplicaSet

java.lang.Object
io.debezium.connector.mongodb.ReplicaSet
All Implemented Interfaces:
Comparable<ReplicaSet>

@Immutable public final class ReplicaSet extends Object implements Comparable<ReplicaSet>
  • Field Details

    • HOST_PATTERN

      private static final Pattern HOST_PATTERN
      Regular expression that extracts the hosts for the replica sets. The raw expression is ((([^=]+)[=])?(([^/]+)\/))?(.+).
    • addresses

      private final List<com.mongodb.ServerAddress> addresses
    • replicaSetName

      private final String replicaSetName
    • shardName

      private final String shardName
    • hc

      private final int hc
  • Constructor Details

    • ReplicaSet

      public ReplicaSet(String addresses, String replicaSetName, String shardName)
  • Method Details

    • parse

      public static ReplicaSet parse(String hosts)
      Parse the supplied string for the information about the hosts for a replica set. The string is a shard host specification (e.g., "shard01=replicaSet1/host1:27017,host2:27017"), replica set hosts (e.g., "replicaSet1/host1:27017,host2:27017"), or standalone host (e.g., "host1:27017" or "1.2.3.4:27017").
      Parameters:
      hosts - the hosts string; may be null
      Returns:
      the replica set; or null if the host string could not be parsed
    • addresses

      public List<com.mongodb.ServerAddress> addresses()
      Get the immutable list of server addresses.
      Returns:
      the server addresses; never null
    • replicaSetName

      public String replicaSetName()
      Get the name of this replica set.
      Returns:
      the replica set name, or null if the addresses are for standalone servers.
    • shardName

      public String shardName()
      Get the shard name for this replica set.
      Returns:
      the shard name, or null if this replica set is not used as a shard
    • isStandaloneServer

      public boolean isStandaloneServer()
      Return whether the address(es) represent a standalone server, where the replica set name is null. This method returns the opposite of hasReplicaSetName().
      Returns:
      true if this represents the address of a standalone server, or false if it represents the address of a replica set
      See Also:
    • hasReplicaSetName

      public boolean hasReplicaSetName()
      Return whether the address(es) represents a replica set, where the replica set name is not null. This method returns the opposite of isStandaloneServer().
      Returns:
      true if this represents the address of a replica set, or false if it represents the address of a standalone server
      See Also:
    • hashCode

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

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

      public int compareTo(ReplicaSet that)
      Specified by:
      compareTo in interface Comparable<ReplicaSet>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareServerAddresses

      protected static int compareServerAddresses(com.mongodb.ServerAddress one, com.mongodb.ServerAddress two)
    • compareNullable

      protected static int compareNullable(String str1, String str2)
    • compare

      protected static int compare(com.mongodb.ServerAddress address1, com.mongodb.ServerAddress address2)