Package com.mongodb.event
Class CommandSucceededEvent
java.lang.Object
com.mongodb.event.CommandEvent
com.mongodb.event.CommandSucceededEvent
An event representing the completion of a MongoDB database command.
- Since:
- 3.1
-
Constructor Summary
ConstructorDescriptionCommandSucceededEvent
(RequestContext requestContext, long operationId, int requestId, ConnectionDescription connectionDescription, String databaseName, String commandName, BsonDocument response, long elapsedTimeNanos) Construct an instance. -
Method Summary
Modifier and TypeMethodDescriptionlong
getElapsedTime
(TimeUnit timeUnit) Gets the elapsed time in the given unit of time.Gets the response document.Methods inherited from class com.mongodb.event.CommandEvent
getCommandName, getConnectionDescription, getDatabaseName, getOperationId, getRequestContext, getRequestId
-
Constructor Details
-
CommandSucceededEvent
public CommandSucceededEvent(@Nullable RequestContext requestContext, long operationId, int requestId, ConnectionDescription connectionDescription, String databaseName, String commandName, BsonDocument response, long elapsedTimeNanos) Construct an instance.- Parameters:
requestContext
- the request contextoperationId
- the operation idrequestId
- the request idconnectionDescription
- the connection descriptiondatabaseName
- the database namecommandName
- the command nameresponse
- the command responseelapsedTimeNanos
- the non-negative elapsed time in nanoseconds for the operation to complete- Since:
- 4.11
-
-
Method Details
-
getElapsedTime
Gets the elapsed time in the given unit of time.- Parameters:
timeUnit
- the time unit in which to get the elapsed time- Returns:
- the elapsed time
-
getResponse
Gets the response document. The document is only usable within the method that delivered the event. If it's needed for longer, it must be cloned viaObject.clone()
.- Returns:
- the response document
-