Package com.mongodb.event
Class ConnectionCheckedOutEvent
java.lang.Object
com.mongodb.event.ConnectionCheckedOutEvent
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 Summary
ConstructorsConstructorDescriptionConnectionCheckedOutEvent(ConnectionId connectionId) Deprecated.ConnectionCheckedOutEvent(ConnectionId connectionId, long operationId) Deprecated.ConnectionCheckedOutEvent(ConnectionId connectionId, long operationId, long elapsedTimeNanos) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionGets the connection idlonggetElapsedTime(TimeUnit timeUnit) The time it took to check out the connection.longGets the operation identifiertoString()
-
Constructor Details
-
ConnectionCheckedOutEvent
public ConnectionCheckedOutEvent(ConnectionId connectionId, long operationId, long elapsedTimeNanos) Constructs an instance.- Parameters:
connectionId- The connection ID. SeegetConnectionId().operationId- The operation ID. SeegetOperationId().elapsedTimeNanos- The time it took to check out the connection. SeegetElapsedTime(TimeUnit).- Since:
- 4.11
-
ConnectionCheckedOutEvent
Deprecated.PreferConnectionCheckedOutEvent(ConnectionId, long, long). If this constructor is used, thengetElapsedTime(TimeUnit)is 0.Construct an instance- Parameters:
connectionId- the connectionIdoperationId- the operation id- Since:
- 4.10
-
ConnectionCheckedOutEvent
Deprecated.PreferConnectionCheckedOutEvent(ConnectionId, long). If this constructor is used, thengetOperationId()is -1.Construct an instance- Parameters:
connectionId- the connectionId
-
-
Method Details
-
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
The time it took to check out the connection. More specifically, the time elapsed between theConnectionCheckOutStartedEventemitted 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 totimeUnitis done.- Returns:
- The time it took to establish the connection.
- Since:
- 4.11
-
toString
-
ConnectionCheckedOutEvent(ConnectionId, long).