Package com.mongodb.event
Class ConnectionCheckOutFailedEvent
java.lang.Object
com.mongodb.event.ConnectionCheckOutFailedEvent
An event for when checking out a connection fails.
- Since:
- 4.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enumeration of the reasons checking out a connection failed -
Constructor Summary
ConstructorDescriptionConnectionCheckOutFailedEvent
(ServerId serverId, long operationId, ConnectionCheckOutFailedEvent.Reason reason, long elapsedTimeNanos) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionlong
getElapsedTime
(TimeUnit timeUnit) The time it took to check out the connection.long
Gets the operation identifierGets the reason for the check out failure.Gets the server idtoString()
-
Constructor Details
-
ConnectionCheckOutFailedEvent
public ConnectionCheckOutFailedEvent(ServerId serverId, long operationId, ConnectionCheckOutFailedEvent.Reason reason, long elapsedTimeNanos) Constructs an instance.- Parameters:
serverId
- The server ID. SeegetServerId()
.operationId
- The operation ID. SeegetOperationId()
.reason
- The reason the connection check out failed. SeegetReason()
.elapsedTimeNanos
- The time it took while trying to check out the connection. SeegetElapsedTime(TimeUnit)
.- Since:
- 4.11
-
-
Method Details
-
getServerId
Gets the server id- Returns:
- the server id
-
getOperationId
public long getOperationId()Gets the operation identifier- Returns:
- the operation identifier
- Since:
- 4.10
-
getReason
Gets the reason for the check out failure.- Returns:
- the reason
- Since:
- 4.3
-
getElapsedTime
The time it took to check out the connection. More specifically, the time elapsed between emitting aConnectionCheckOutStartedEvent
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 totimeUnit
is done.- Returns:
- The time it took to establish the connection.
- Since:
- 4.11
-
toString
-