|
22 | 22 | import com.mongodb.ReadPreference;
|
23 | 23 | import com.mongodb.ServerCursor;
|
24 | 24 | import com.mongodb.connection.ServerType;
|
| 25 | +import com.mongodb.diagnostics.logging.Logger; |
| 26 | +import com.mongodb.diagnostics.logging.Loggers; |
25 | 27 | import com.mongodb.internal.async.AsyncAggregateResponseBatchCursor;
|
26 | 28 | import com.mongodb.internal.async.SingleResultCallback;
|
27 | 29 | import com.mongodb.internal.binding.AsyncConnectionSource;
|
|
49 | 51 | import static com.mongodb.assertions.Assertions.notNull;
|
50 | 52 | import static com.mongodb.internal.async.ErrorHandlingResultCallback.errorHandlingCallback;
|
51 | 53 | import static com.mongodb.internal.operation.CursorHelper.getNumberToReturn;
|
52 |
| -import static com.mongodb.internal.operation.OperationHelper.LOGGER; |
53 | 54 | import static com.mongodb.internal.operation.OperationHelper.getMoreCursorDocumentToQueryResult;
|
54 | 55 | import static com.mongodb.internal.operation.QueryHelper.translateCommandException;
|
55 | 56 | import static com.mongodb.internal.operation.ServerVersionHelper.serverIsAtLeastVersionThreeDotTwo;
|
| 57 | +import static java.lang.String.format; |
56 | 58 | import static java.util.Collections.singletonList;
|
57 | 59 |
|
58 | 60 | class AsyncQueryBatchCursor<T> implements AsyncAggregateResponseBatchCursor<T> {
|
| 61 | + private static final Logger LOGGER = Loggers.getLogger("operation"); |
59 | 62 | private static final FieldNameValidator NO_OP_FIELD_NAME_VALIDATOR = new NoOpFieldNameValidator();
|
60 | 63 | private static final String CURSOR = "cursor";
|
61 | 64 | private static final String POST_BATCH_RESUME_TOKEN = "postBatchResumeToken";
|
@@ -120,6 +123,7 @@ class AsyncQueryBatchCursor<T> implements AsyncAggregateResponseBatchCursor<T> {
|
120 | 123 | }
|
121 | 124 | }
|
122 | 125 | this.maxWireVersion = connection == null ? 0 : connection.getDescription().getMaxWireVersion();
|
| 126 | + logQueryResult(firstBatch); |
123 | 127 | }
|
124 | 128 |
|
125 | 129 | /**
|
@@ -337,8 +341,10 @@ private void endOperationInProgress() {
|
337 | 341 | }
|
338 | 342 | }
|
339 | 343 |
|
| 344 | + |
340 | 345 | private void handleGetMoreQueryResult(final AsyncConnection connection, final SingleResultCallback<List<T>> callback,
|
341 | 346 | final QueryResult<T> result) {
|
| 347 | + logQueryResult(result); |
342 | 348 | cursor.set(result.getCursor());
|
343 | 349 | if (isClosePending) {
|
344 | 350 | try {
|
@@ -373,6 +379,11 @@ private void handleGetMoreQueryResult(final AsyncConnection connection, final Si
|
373 | 379 | }
|
374 | 380 | }
|
375 | 381 |
|
| 382 | + private void logQueryResult(final QueryResult<T> result) { |
| 383 | + LOGGER.debug(format("Received batch of %d documents with cursorId %d from server %s", result.getResults().size(), |
| 384 | + result.getCursorId(), result.getAddress())); |
| 385 | + } |
| 386 | + |
376 | 387 | private class CommandResultSingleResultCallback implements SingleResultCallback<BsonDocument> {
|
377 | 388 | private final AsyncConnection connection;
|
378 | 389 | private final ServerCursor cursor;
|
|
0 commit comments