Class ServerDescription.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • canonicalAddress

        public ServerDescription.Builder canonicalAddress​(String canonicalAddress)
        Sets the canonical host name and port of this server. This is typically derived from the "me" field contained in the "isMaster" command. response.
        Parameters:
        canonicalAddress - the host name and port as a string
        Returns:
        this
      • type

        public ServerDescription.Builder type​(ServerType type)
        Sets the type of the server, for example whether it's a standalone or in a replica set.
        Parameters:
        type - the Server type
        Returns:
        this
      • hosts

        public ServerDescription.Builder hosts​(Set<String> hosts)
        Sets all members of the replica set that are neither hidden, passive, nor arbiters.
        Parameters:
        hosts - 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.
        Returns:
        this
      • passives

        public ServerDescription.Builder passives​(Set<String> passives)
        Sets the passive members of the replica set.
        Parameters:
        passives - A Set of strings in the format of "[hostname]:[port]" listing all members of the replica set which have a priority of 0.
        Returns:
        this
      • arbiters

        public ServerDescription.Builder arbiters​(Set<String> arbiters)
        Sets the arbiters in the replica set
        Parameters:
        arbiters - A Set of strings in the format of "[hostname]:[port]" containing all members of the replica set that are arbiters.
        Returns:
        this
      • primary

        public ServerDescription.Builder primary​(String primary)
        Sets the address of the current primary in the replica set
        Parameters:
        primary - A string in the format of "[hostname]:[port]" listing the current primary member of the replica set.
        Returns:
        this
      • maxDocumentSize

        public ServerDescription.Builder maxDocumentSize​(int maxDocumentSize)
        The maximum permitted size of a BSON object in bytes for this mongod process. Defaults to 16MB.
        Parameters:
        maxDocumentSize - the maximum size a document can be
        Returns:
        this
      • tagSet

        public ServerDescription.Builder tagSet​(TagSet tagSet)
        A set of any tags assigned to this member.
        Parameters:
        tagSet - a TagSet with all the tags for this server.
        Returns:
        this
      • roundTripTime

        public ServerDescription.Builder roundTripTime​(long roundTripTime,
                                                       TimeUnit timeUnit)
        Set the time it took to make the round trip for requesting this information from the server
        Parameters:
        roundTripTime - the time taken
        timeUnit - the units of the time taken
        Returns:
        this
      • setName

        public ServerDescription.Builder setName​(String setName)
        Sets the name of the replica set
        Parameters:
        setName - the name of the replica set
        Returns:
        this
      • ok

        public ServerDescription.Builder ok​(boolean ok)
        The isOK() result from requesting this information from MongoDB
        Parameters:
        ok - true if the request executed correctly
        Returns:
        this
      • state

        public ServerDescription.Builder state​(ServerConnectionState state)
        The current state of the connection to the server.
        Parameters:
        state - ServerConnectionState representing whether the server has been successfully connected to
        Returns:
        this
      • minWireVersion

        public ServerDescription.Builder minWireVersion​(int minWireVersion)
        The earliest version of the wire protocol that this MongoDB server is capable of using to communicate with clients.
        Parameters:
        minWireVersion - the minimum protocol version supported by this server
        Returns:
        this
        Since server release
        2.6
      • maxWireVersion

        public ServerDescription.Builder maxWireVersion​(int maxWireVersion)
        The latest version of the wire protocol that this MongoDB server is capable of using to communicate with clients.
        Parameters:
        maxWireVersion - the maximum protocol version supported by this server
        Returns:
        this
        Since server release
        2.6
      • electionId

        public ServerDescription.Builder electionId​(ObjectId electionId)
        Sets the electionId reported by this server.
        Parameters:
        electionId - the electionId
        Returns:
        this
      • setVersion

        public ServerDescription.Builder setVersion​(Integer setVersion)
        Sets the setVersion reported by this server.
        Parameters:
        setVersion - the set version
        Returns:
        this
      • lastWriteDate

        public ServerDescription.Builder lastWriteDate​(Date lastWriteDate)
        Sets the lastWriteDate reported by this server
        Parameters:
        lastWriteDate - the last write date, which may be null for servers prior to 3.4
        Returns:
        this
        Since:
        3.4
        Since server release
        3.4
      • lastUpdateTimeNanos

        public ServerDescription.Builder lastUpdateTimeNanos​(long lastUpdateTimeNanos)
        Sets the last update time for this description, which is simply the time that the server description was created. A monotonic clock such as System.nanoTime() should be used to initialize this value.
        Parameters:
        lastUpdateTimeNanos - the last update time of this server description
        Returns:
        this
        Since:
        3.4
      • logicalSessionTimeoutMinutes

        public ServerDescription.Builder logicalSessionTimeoutMinutes​(Integer logicalSessionTimeoutMinutes)
        Sets the session timeout in minutes.
        Parameters:
        logicalSessionTimeoutMinutes - the session timeout in minutes, or null if sessions are not supported by this server
        Returns:
        this
        Since:
        3.6
        Since server release
        3.6
      • exception

        public ServerDescription.Builder exception​(Throwable exception)
        Sets the exception thrown while attempting to determine the server description.
        Parameters:
        exception - the exception
        Returns:
        this
      • build

        public ServerDescription build()
        Create a new ServerDescription from the settings in this builder.
        Returns:
        a new server description