Class ConnectionCheckedOutEvent

java.lang.Object
com.mongodb.event.ConnectionCheckedOutEvent

public final class ConnectionCheckedOutEvent extends Object
An event for checking out a connection from the pool. Such a connection is considered in use until it becomes available.
Since:
3.5
  • Constructor Details

    • ConnectionCheckedOutEvent

      public ConnectionCheckedOutEvent(ConnectionId connectionId, long operationId, long elapsedTimeNanos)
      Constructs an instance.
      Parameters:
      connectionId - The connection ID. See getConnectionId().
      operationId - The operation ID. See getOperationId().
      elapsedTimeNanos - The time it took to check out the connection. See getElapsedTime(TimeUnit).
      Since:
      4.11
  • Method Details

    • getConnectionId

      public ConnectionId getConnectionId()
      Gets the connection id
      Returns:
      the connection id
    • getOperationId

      public long getOperationId()
      Gets the operation identifier
      Returns:
      the operation identifier
      Since:
      4.10
    • getElapsedTime

      public long getElapsedTime(TimeUnit timeUnit)
      The time it took to check out the connection. More specifically, the time elapsed between emitting a ConnectionCheckOutStartedEvent and emitting this event as part of the same checking out.

      Naturally, if a new connection was not created and established as part of checking out, this duration is usually not greater than ConnectionPoolSettings.getMaxWaitTime(TimeUnit), but may occasionally be greater than that, because the driver does not provide hard real-time guarantees.

      Parameters:
      timeUnit - The time unit of the result. TimeUnit.convert(long, TimeUnit) specifies how the conversion from nanoseconds to timeUnit is done.
      Returns:
      The time it took to establish the connection.
      Since:
      4.11
    • toString

      public String toString()
      Overrides:
      toString in class Object