@Immutable public class ServerDescription extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ServerDescription.Builder
A builder for creating ServerDescription.
|
Modifier and Type | Method and Description |
---|---|
static ServerDescription.Builder |
builder()
Gets a Builder for creating a new ServerDescription instance.
|
boolean |
equals(Object o)
Returns true if this instance is equals to @code{o}.
|
ServerAddress |
getAddress()
Gets the address of this server
|
Set<String> |
getArbiters()
Gets the arbiters in the replica set
|
String |
getCanonicalAddress()
Gets the string representing the host name and port that this member of a replica set was configured with,
e.g.
|
ClusterType |
getClusterType()
Gets the type of the cluster this server is in (for example, replica set).
|
static int |
getDefaultMaxDocumentSize()
Get the default maximum document size.
|
static int |
getDefaultMaxWireVersion()
Get the default maximum wire version
|
static int |
getDefaultMinWireVersion()
Get the default minimum wire version
|
ObjectId |
getElectionId()
The replica set electionid reported by this MongoDB server.
|
Throwable |
getException()
Gets the exception thrown while attempting to determine the server description.
|
Set<String> |
getHosts()
Get a Set of strings in the format of "[hostname]:[port]" that contains all members of the replica set that are neither hidden,
passive, nor arbiters.
|
long |
getLastUpdateTime(TimeUnit timeUnit)
Gets the time that this server description was created, using a monotonic clock like
System.nanoTime() . |
Date |
getLastWriteDate()
Gets the last write date.
|
int |
getMaxDocumentSize()
The maximum permitted size of a BSON object in bytes for this mongod process.
|
int |
getMaxWireVersion()
The latest version of the wire protocol that this MongoDB server is capable of using to communicate with clients.
|
int |
getMinWireVersion()
The earliest version of the wire protocol that this MongoDB server is capable of using to communicate with clients.
|
Set<String> |
getPassives()
Gets the passive members of the replica set.
|
String |
getPrimary()
Gets the address of the current primary in the replica set
|
long |
getRoundTripTimeNanos()
Get the time it took to make the round trip for requesting this information from the server in nanoseconds.
|
String |
getSetName()
Gets the name of the replica set
|
Integer |
getSetVersion()
The replica set setVersion reported by this MongoDB server.
|
String |
getShortDescription()
Returns a short, pretty description for this ServerDescription.
|
ServerConnectionState |
getState()
Gets the current state of the connection to the server.
|
TagSet |
getTagSet()
A set of all tags assigned to this member.
|
ServerType |
getType()
Gets the type of the server, for example whether it's a standalone or in a replica set.
|
ServerVersion |
getVersion()
Gets the server version
|
int |
hashCode() |
boolean |
hasTags(TagSet desiredTags)
Returns true if the server has the given tags.
|
boolean |
isCompatibleWithDriver()
Return whether the server is compatible with the driver.
|
boolean |
isOk()
The isOK() result from requesting this information from the server
|
boolean |
isPrimary()
Returns whether this can be treated as a primary server.
|
boolean |
isReplicaSetMember()
Gets whether this server is a replica set member.
|
boolean |
isSecondary()
Returns whether this can be treated as a secondary server.
|
boolean |
isShardRouter()
Gets whether this is a server that is the entry point to a sharded instance of MongoDB.
|
boolean |
isStandAlone()
Gets whether this is part of a replica set/sharded system, or is a single server.
|
String |
toString() |
public static ServerDescription.Builder builder()
public String getCanonicalAddress()
"somehost:27019"
. This is typically derived from the "me" field from the "isMaster" command response.public boolean isCompatibleWithDriver()
public static int getDefaultMaxDocumentSize()
public static int getDefaultMinWireVersion()
public static int getDefaultMaxWireVersion()
public ServerAddress getAddress()
public boolean isReplicaSetMember()
public boolean isShardRouter()
public boolean isStandAlone()
public boolean isPrimary()
public boolean isSecondary()
public Set<String> getHosts()
public Set<String> getPassives()
public Set<String> getArbiters()
public String getPrimary()
public int getMaxDocumentSize()
public TagSet getTagSet()
public int getMinWireVersion()
public int getMaxWireVersion()
public ObjectId getElectionId()
public Integer getSetVersion()
public Date getLastWriteDate()
public long getLastUpdateTime(TimeUnit timeUnit)
System.nanoTime()
.timeUnit
- the time unitpublic boolean hasTags(TagSet desiredTags)
ServerType.STANDALONE
or ServerType.SHARD_ROUTER
is considered to have all tags, so this method will always return true for instances of either of those
types.desiredTags
- the tagspublic String getSetName()
public boolean isOk()
public ServerConnectionState getState()
public ServerType getType()
public ClusterType getClusterType()
public ServerVersion getVersion()
public long getRoundTripTimeNanos()
public Throwable getException()
public boolean equals(Object o)
public String getShortDescription()