@Immutable public final class ReplicaSet extends Object implements Comparable<ReplicaSet>
| Modifier and Type | Field and Description |
|---|---|
private List<com.mongodb.ServerAddress> |
addresses |
private int |
hc |
private static Pattern |
HOST_PATTERN
Regular expression that extracts the hosts for the replica sets.
|
private String |
replicaSetName |
private String |
shardName |
| Constructor and Description |
|---|
ReplicaSet(String addresses,
String replicaSetName,
String shardName) |
| Modifier and Type | Method and Description |
|---|---|
List<com.mongodb.ServerAddress> |
addresses()
Get the immutable list of server addresses.
|
protected static int |
compare(com.mongodb.ServerAddress address1,
com.mongodb.ServerAddress address2) |
protected static int |
compareNullable(String str1,
String str2) |
protected static int |
compareServerAddresses(com.mongodb.ServerAddress one,
com.mongodb.ServerAddress two) |
int |
compareTo(ReplicaSet that) |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
hasReplicaSetName()
Return whether the address(es) represents a replica set, where the
replica set name is
not null. |
boolean |
isStandaloneServer()
Return whether the address(es) represent a standalone server, where the
replica set name is
null. |
static ReplicaSet |
parse(String hosts)
Parse the supplied string for the information about the hosts for a replica set.
|
String |
replicaSetName()
Get the name of this replica set.
|
String |
shardName()
Get the shard name for this replica set.
|
String |
toString() |
private static final Pattern HOST_PATTERN
((([^=]+)[=])?(([^/]+)\/))?(.+).private final List<com.mongodb.ServerAddress> addresses
private final String replicaSetName
private final String shardName
private final int hc
public static ReplicaSet parse(String hosts)
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").hosts - the hosts string; may be nullnull if the host string could not be parsedpublic List<com.mongodb.ServerAddress> addresses()
public String replicaSetName()
null if the addresses are for standalone servers.public String shardName()
null if this replica set is not used as a shardpublic boolean isStandaloneServer()
replica set name is
null. This method returns the opposite of hasReplicaSetName().true if this represents the address of a standalone server, or false if it represents the
address of a replica sethasReplicaSetName()public boolean hasReplicaSetName()
replica set name is
not null. This method returns the opposite of isStandaloneServer().true if this represents the address of a replica set, or false if it represents the
address of a standalone serverisStandaloneServer()public int compareTo(ReplicaSet that)
compareTo in interface Comparable<ReplicaSet>protected static int compareServerAddresses(com.mongodb.ServerAddress one,
com.mongodb.ServerAddress two)
protected static int compare(com.mongodb.ServerAddress address1,
com.mongodb.ServerAddress address2)
Copyright © 2016 JBoss by Red Hat. All rights reserved.