Class ReplicaSet

    • Field Detail

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

      • ReplicaSet

        public ReplicaSet​(String addresses,
                          String replicaSetName,
                          String shardName)
    • Method Detail

      • 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()
      • 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:
        isStandaloneServer()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode 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)