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
ConstructorsConstructorDescriptionCommandSucceededEvent
(int requestId, ConnectionDescription connectionDescription, String commandName, BsonDocument response, long elapsedTimeNanos) Construct an instance.CommandSucceededEvent
(RequestContext requestContext, int requestId, ConnectionDescription connectionDescription, 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, getRequestContext, getRequestId
-
Constructor Details
-
CommandSucceededEvent
public CommandSucceededEvent(@Nullable RequestContext requestContext, int requestId, ConnectionDescription connectionDescription, String commandName, BsonDocument response, long elapsedTimeNanos) Construct an instance.- Parameters:
requestContext
- the request contextrequestId
- the request idconnectionDescription
- the connection descriptioncommandName
- the command nameresponse
- the command responseelapsedTimeNanos
- the non-negative elapsed time in nanoseconds for the operation to complete- Since:
- 4.4
-
CommandSucceededEvent
public CommandSucceededEvent(int requestId, ConnectionDescription connectionDescription, String commandName, BsonDocument response, long elapsedTimeNanos) Construct an instance.- Parameters:
requestId
- the request idconnectionDescription
- the connection descriptioncommandName
- the command nameresponse
- the command responseelapsedTimeNanos
- the non-negative elapsed time in nanoseconds for the operation to complete
-
-
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
-