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) Deprecated.ConnectionReadyEvent
(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
-
ConnectionReadyEvent
Deprecated.PreferConnectionReadyEvent(ConnectionId, long)
. If this constructor is used, thengetElapsedTime(TimeUnit)
is 0.Construct an instance- Parameters:
connectionId
- the connection id
-
-
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 theConnectionCreatedEvent
emitted by the same checking out and this event.Naturally, when establishing a connection is part of checking out, this duration is not greater than
ConnectionCheckedOutEvent.getElapsedTime(TimeUnit)
/ConnectionCheckOutFailedEvent.getElapsedTime(TimeUnit)
.This duration does not currently include the time to deliver the
ConnectionCreatedEvent
. Subject to change.- 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
-
ConnectionReadyEvent(ConnectionId, long)
.