Class ConnectionDescription

java.lang.Object
com.mongodb.connection.ConnectionDescription

@Immutable public class ConnectionDescription extends Object
A description of a connection to a MongoDB server.
Since:
3.0
  • Constructor Details

    • ConnectionDescription

      public ConnectionDescription(ServerId serverId)
      Construct a defaulted connection description instance.
      Parameters:
      serverId - the server address
    • ConnectionDescription

      public ConnectionDescription(ConnectionId connectionId, int maxWireVersion, ServerType serverType, int maxBatchCount, int maxDocumentSize, int maxMessageSize, List<String> compressors)
      Construct an instance.
      Parameters:
      connectionId - the connection id
      maxWireVersion - the max wire version
      serverType - the server type
      maxBatchCount - the max batch count
      maxDocumentSize - the max document size in bytes
      maxMessageSize - the max message size in bytes
      compressors - the available compressors on the connection
      Since:
      3.10
    • ConnectionDescription

      public ConnectionDescription(ConnectionId connectionId, int maxWireVersion, ServerType serverType, int maxBatchCount, int maxDocumentSize, int maxMessageSize, List<String> compressors, BsonArray saslSupportedMechanisms)
      Construct an instance.
      Parameters:
      connectionId - the connection id
      maxWireVersion - the max wire version
      serverType - the server type
      maxBatchCount - the max batch count
      maxDocumentSize - the max document size in bytes
      maxMessageSize - the max message size in bytes
      compressors - the available compressors on the connection
      saslSupportedMechanisms - the supported SASL mechanisms
      Since:
      4.1
    • ConnectionDescription

      public ConnectionDescription(@Nullable ObjectId serviceId, ConnectionId connectionId, int maxWireVersion, ServerType serverType, int maxBatchCount, int maxDocumentSize, int maxMessageSize, List<String> compressors, BsonArray saslSupportedMechanisms)
      Construct an instance.
      Parameters:
      serviceId - the service id, which may be null
      connectionId - the connection id
      maxWireVersion - the max wire version
      serverType - the server type
      maxBatchCount - the max batch count
      maxDocumentSize - the max document size in bytes
      maxMessageSize - the max message size in bytes
      compressors - the available compressors on the connection
      saslSupportedMechanisms - the supported SASL mechanisms
      Since:
      4.3
  • Method Details

    • withConnectionId

      public ConnectionDescription withConnectionId(ConnectionId connectionId)
      Creates a new connection description with the set connection id
      Parameters:
      connectionId - the connection id
      Returns:
      the new connection description
      Since:
      3.8
    • withServiceId

      public ConnectionDescription withServiceId(ObjectId serviceId)
      Creates a new connection description with the given service id
      Parameters:
      serviceId - the service id
      Returns:
      the new connection description
      Since:
      4.3
    • getServerAddress

      public ServerAddress getServerAddress()
      Gets the server address.
      Returns:
      the server address
    • getConnectionId

      public ConnectionId getConnectionId()
      Gets the id of the connection. If possible, this id will correlate with the connection id that the server puts in its log messages.
      Returns:
      the connection id
    • getServiceId

      @Nullable public ObjectId getServiceId()
      Gets the id of the service this connection is to
      Returns:
      the service id, which may be null
      Since:
      4.3
    • getMaxWireVersion

      public int getMaxWireVersion()
      The latest version of the wire protocol that this MongoDB server is capable of using to communicate with clients.
      Returns:
      the maximum protocol version supported by this server
      Since:
      3.10
    • getServerType

      public ServerType getServerType()
      Gets the server type.
      Returns:
      the server type
    • getMaxBatchCount

      public int getMaxBatchCount()
      Gets the max batch count for bulk write operations.
      Returns:
      the max batch count
    • getMaxDocumentSize

      public int getMaxDocumentSize()
      Gets the max document size in bytes for documents to be stored in collections.
      Returns:
      the max document size in bytes
    • getMaxMessageSize

      public int getMaxMessageSize()
      Gets the max message size in bytes for wire protocol messages to be sent to the server.
      Returns:
      the max message size in bytes.
    • getCompressors

      public List<String> getCompressors()
      Gets the compressors supported by this connection.
      Returns:
      the non-null list of compressors supported by this connection
    • getSaslSupportedMechanisms

      public BsonArray getSaslSupportedMechanisms()
      Get the supported SASL mechanisms.
      Returns:
      the supported SASL mechanisms.
      Since:
      4.1
    • getDefaultMaxMessageSize

      public static int getDefaultMaxMessageSize()
      Get the default maximum message size.
      Returns:
      the default maximum message size.
    • getDefaultMaxWriteBatchSize

      public static int getDefaultMaxWriteBatchSize()
      Get the default maximum write batch size.
      Returns:
      the default maximum write batch size.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object