Package io.debezium.connector.mongodb
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 Summary
Fields Modifier and Type Field Description private List<com.mongodb.ServerAddress>addressesprivate inthcprivate static PatternHOST_PATTERNRegular expression that extracts the hosts for the replica sets.private StringreplicaSetNameprivate StringshardName
-
Constructor Summary
Constructors Constructor Description ReplicaSet(String addresses, String replicaSetName, String shardName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<com.mongodb.ServerAddress>addresses()Get the immutable list of server addresses.protected static intcompare(com.mongodb.ServerAddress address1, com.mongodb.ServerAddress address2)protected static intcompareNullable(String str1, String str2)protected static intcompareServerAddresses(com.mongodb.ServerAddress one, com.mongodb.ServerAddress two)intcompareTo(ReplicaSet that)booleanequals(Object obj)inthashCode()booleanhasReplicaSetName()Return whether the address(es) represents a replica set, where thereplica set nameis notnull.booleanisStandaloneServer()Return whether the address(es) represent a standalone server, where thereplica set nameisnull.static ReplicaSetparse(String hosts)Parse the supplied string for the information about the hosts for a replica set.StringreplicaSetName()Get the name of this replica set.StringshardName()Get the shard name for this replica set.StringtoString()
-
-
-
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
-
-
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
nullif 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
nullif the addresses are for standalone servers.
-
shardName
public String shardName()
Get the shard name for this replica set.- Returns:
- the shard name, or
nullif this replica set is not used as a shard
-
isStandaloneServer
public boolean isStandaloneServer()
Return whether the address(es) represent a standalone server, where thereplica set nameisnull. This method returns the opposite ofhasReplicaSetName().- Returns:
trueif this represents the address of a standalone server, orfalseif 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 thereplica set nameis notnull. This method returns the opposite ofisStandaloneServer().- Returns:
trueif this represents the address of a replica set, orfalseif it represents the address of a standalone server- See Also:
isStandaloneServer()
-
compareTo
public int compareTo(ReplicaSet that)
- Specified by:
compareToin interfaceComparable<ReplicaSet>
-
compareServerAddresses
protected static int compareServerAddresses(com.mongodb.ServerAddress one, com.mongodb.ServerAddress two)
-
compare
protected static int compare(com.mongodb.ServerAddress address1, com.mongodb.ServerAddress address2)
-
-