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) Deprecated.ConnectionCheckOutFailedEvent
(ServerId serverId, long operationId, ConnectionCheckOutFailedEvent.Reason reason, long elapsedTimeNanos) Constructs an instance.ConnectionCheckOutFailedEvent
(ServerId serverId, ConnectionCheckOutFailedEvent.Reason reason) Deprecated.PreferConnectionCheckOutFailedEvent(ServerId, long, Reason)
If this constructor is used, thengetOperationId()
is -1. -
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
-
ConnectionCheckOutFailedEvent
@Deprecated public ConnectionCheckOutFailedEvent(ServerId serverId, long operationId, ConnectionCheckOutFailedEvent.Reason reason) Deprecated.PreferConnectionCheckOutFailedEvent(ServerId, long, Reason, long)
. If this constructor is used, thengetElapsedTime(TimeUnit)
is 0.Construct an instance- Parameters:
serverId
- the server idoperationId
- the operation idreason
- the reason the connection check out failed- Since:
- 4.10
-
ConnectionCheckOutFailedEvent
@Deprecated public ConnectionCheckOutFailedEvent(ServerId serverId, ConnectionCheckOutFailedEvent.Reason reason) Deprecated.PreferConnectionCheckOutFailedEvent(ServerId, long, Reason)
If this constructor is used, thengetOperationId()
is -1.Construct an instance- Parameters:
serverId
- the server idreason
- the reason the connection check out failed
-
-
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 theConnectionCheckOutStartedEvent
emitted by the same checking out and this event.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.This duration does not currently include the time to deliver the
ConnectionCheckOutStartedEvent
. 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
-
ConnectionCheckOutFailedEvent(ServerId, long, Reason, long)
.