Package com.mongodb.event
Class ConnectionReadyEvent
java.lang.Object
com.mongodb.event.ConnectionReadyEvent
An event for when a connection in the pool has finished being established.
Such a connection is considered available until it becomes in use
or closed.
- Since:
- 4.0
-
Constructor Summary
ConstructorDescriptionConnectionReadyEvent
(ConnectionId connectionId, long elapsedTimeNanos) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionGets the connection idlong
getElapsedTime
(TimeUnit timeUnit) The time it took to establish the connection.toString()
-
Constructor Details
-
ConnectionReadyEvent
Constructs an instance.- Parameters:
connectionId
- The connection ID. SeegetConnectionId()
.elapsedTimeNanos
- The time it took to establish the connection. SeegetElapsedTime(TimeUnit)
.- Since:
- 4.11
-
-
Method Details
-
getConnectionId
Gets the connection id- Returns:
- the connection id
-
getElapsedTime
The time it took to establish the connection. More specifically, the time elapsed between emitting aConnectionCreatedEvent
and emitting this event as part of the same checking out.Naturally, when establishing a connection is part of checking out, this duration is not greater than
ConnectionCheckedOutEvent.getElapsedTime(TimeUnit)
/ConnectionCheckOutFailedEvent.getElapsedTime(TimeUnit)
.- Parameters:
timeUnit
- The time unit of the result.TimeUnit.convert(long, TimeUnit)
specifies how the conversion from nanoseconds totimeUnit
is done.- Returns:
- The time it took to establish the connection.
- Since:
- 4.11
-
toString
-