@Immutable public class ServerDescription extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ServerDescription.Builder
A builder for creating ServerDescription.
|
Modifier and Type | Field and Description |
---|---|
private ServerAddress |
address |
private java.util.Set<java.lang.String> |
arbiters |
private java.lang.String |
canonicalAddress |
private static int |
DEFAULT_MAX_DOCUMENT_SIZE |
private ObjectId |
electionId |
private java.lang.Throwable |
exception |
private java.util.Set<java.lang.String> |
hosts |
private long |
lastUpdateTimeNanos |
private java.util.Date |
lastWriteDate |
(package private) static int |
MAX_DRIVER_WIRE_VERSION |
private int |
maxDocumentSize |
private int |
maxWireVersion |
(package private) static int |
MIN_DRIVER_WIRE_VERSION |
private int |
minWireVersion |
private boolean |
ok |
private java.util.Set<java.lang.String> |
passives |
private java.lang.String |
primary |
private long |
roundTripTimeNanos |
private java.lang.String |
setName |
private java.lang.Integer |
setVersion |
private ServerConnectionState |
state |
private TagSet |
tagSet |
private ServerType |
type |
private ServerVersion |
version |
Constructor and Description |
---|
ServerDescription(ServerDescription.Builder builder) |
Modifier and Type | Method and Description |
---|---|
static ServerDescription.Builder |
builder()
Gets a Builder for creating a new ServerDescription instance.
|
boolean |
equals(java.lang.Object o)
Returns true if this instance is equals to @code{o}.
|
ServerAddress |
getAddress()
Gets the address of this server
|
java.util.Set<java.lang.String> |
getArbiters()
Gets the arbiters in the replica set
|
java.lang.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.
|
java.lang.Throwable |
getException()
Gets the exception thrown while attempting to determine the server description.
|
java.util.Set<java.lang.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(java.util.concurrent.TimeUnit timeUnit)
Gets the time that this server description was created, using a monotonic clock like
System.nanoTime() . |
java.util.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.
|
java.util.Set<java.lang.String> |
getPassives()
Gets the passive members of the replica set.
|
java.lang.String |
getPrimary()
Gets the address of the current primary in the replica set
|
private java.lang.String |
getRoundTripFormattedInMilliseconds() |
long |
getRoundTripTimeNanos()
Get the time it took to make the round trip for requesting this information from the server in nanoseconds.
|
java.lang.String |
getSetName()
Gets the name of the replica set
|
java.lang.Integer |
getSetVersion()
The replica set setVersion reported by this MongoDB server.
|
java.lang.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.
|
java.lang.String |
toString() |
private java.lang.String |
translateExceptionToString() |
static final int MIN_DRIVER_WIRE_VERSION
static final int MAX_DRIVER_WIRE_VERSION
private static final int DEFAULT_MAX_DOCUMENT_SIZE
private final ServerAddress address
private final ServerType type
private final java.lang.String canonicalAddress
private final java.util.Set<java.lang.String> hosts
private final java.util.Set<java.lang.String> passives
private final java.util.Set<java.lang.String> arbiters
private final java.lang.String primary
private final int maxDocumentSize
private final TagSet tagSet
private final java.lang.String setName
private final long roundTripTimeNanos
private final boolean ok
private final ServerConnectionState state
private final ServerVersion version
private final int minWireVersion
private final int maxWireVersion
private final ObjectId electionId
private final java.lang.Integer setVersion
private final java.util.Date lastWriteDate
private final long lastUpdateTimeNanos
private final java.lang.Throwable exception
ServerDescription(ServerDescription.Builder builder)
public static ServerDescription.Builder builder()
public java.lang.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 java.util.Set<java.lang.String> getHosts()
public java.util.Set<java.lang.String> getPassives()
public java.util.Set<java.lang.String> getArbiters()
public java.lang.String getPrimary()
public int getMaxDocumentSize()
public TagSet getTagSet()
public int getMinWireVersion()
public int getMaxWireVersion()
public ObjectId getElectionId()
public java.lang.Integer getSetVersion()
public java.util.Date getLastWriteDate()
public long getLastUpdateTime(java.util.concurrent.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 java.lang.String getSetName()
public boolean isOk()
public ServerConnectionState getState()
public ServerType getType()
public ClusterType getClusterType()
public ServerVersion getVersion()
public long getRoundTripTimeNanos()
public java.lang.Throwable getException()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to compare topublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getShortDescription()
private java.lang.String translateExceptionToString()
private java.lang.String getRoundTripFormattedInMilliseconds()