Class CommandSucceededEvent

java.lang.Object
com.mongodb.event.CommandEvent
com.mongodb.event.CommandSucceededEvent

public final class CommandSucceededEvent extends CommandEvent
An event representing the completion of a MongoDB database command.
Since:
3.1
  • 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 context
      operationId - the operation id
      requestId - the request id
      connectionDescription - the connection description
      databaseName - the database name
      commandName - the command name
      response - the command response
      elapsedTimeNanos - the non-negative elapsed time in nanoseconds for the operation to complete
      Since:
      4.11
  • Method Details

    • getElapsedTime

      public long getElapsedTime(TimeUnit timeUnit)
      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

      public BsonDocument 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 via Object.clone().
      Returns:
      the response document