use of org.bson.BsonInt32 in project mongo-java-driver by mongodb.
the class ListCollectionsPublisherImplTest method shouldBuildTheExpectedOperation.
@DisplayName("Should build the expected ListCollectionsOperation")
@Test
void shouldBuildTheExpectedOperation() {
TestOperationExecutor executor = createOperationExecutor(asList(getBatchCursor(), getBatchCursor()));
ListCollectionsPublisher<String> publisher = new ListCollectionsPublisherImpl<>(null, createMongoOperationPublisher(executor).withDocumentClass(String.class), true);
ListCollectionsOperation<String> expectedOperation = new ListCollectionsOperation<>(DATABASE_NAME, getDefaultCodecRegistry().get(String.class)).batchSize(Integer.MAX_VALUE).nameOnly(true).retryReads(true);
// default input should be as expected
Flux.from(publisher).blockFirst();
assertOperationIsTheSameAs(expectedOperation, executor.getReadOperation());
assertEquals(ReadPreference.primary(), executor.getReadPreference());
// Should apply settings
publisher.filter(new Document("filter", 1)).maxTime(10, SECONDS).batchSize(100);
expectedOperation.filter(new BsonDocument("filter", new BsonInt32(1))).maxTime(10, SECONDS).batchSize(100);
Flux.from(publisher).blockFirst();
assertOperationIsTheSameAs(expectedOperation, executor.getReadOperation());
assertEquals(ReadPreference.primary(), executor.getReadPreference());
}
use of org.bson.BsonInt32 in project mongo-java-driver by mongodb.
the class MultiFileExportBenchmark method exportJsonFile.
private Runnable exportJsonFile(final int fileId, final CountDownLatch latch) {
return new Runnable() {
@Override
public void run() {
List<RawBsonDocument> documents = collection.find(new BsonDocument("fileId", new BsonInt32(fileId))).batchSize(5000).into(new ArrayList<RawBsonDocument>(5000));
fileWritingService.submit(writeJsonFile(fileId, documents, latch));
}
};
}
use of org.bson.BsonInt32 in project mongo-java-driver by mongodb.
the class IdHoldingBsonWriter method writeInt32.
@Override
public void writeInt32(final String name, final int value) {
setCurrentFieldName(name);
addBsonValue(() -> new BsonInt32(value), () -> getIdBsonWriter().writeInt32(name, value));
super.writeInt32(name, value);
}
use of org.bson.BsonInt32 in project mongo-java-driver by mongodb.
the class LoggingCommandEventSender method sendSucceededEventForOneWayCommand.
@Override
public void sendSucceededEventForOneWayCommand() {
long elapsedTimeNanos = System.nanoTime() - startTimeNanos;
if (loggingRequired()) {
logger.debug(format("Execution of one-way command with request id %d completed successfully in %s ms on connection [%s] " + "to server %s", message.getId(), getElapsedTimeFormattedInMilliseconds(elapsedTimeNanos), description.getConnectionId(), description.getServerAddress()));
}
if (eventRequired()) {
BsonDocument responseDocumentForEvent = new BsonDocument("ok", new BsonInt32(1));
sendCommandSucceededEvent(message, commandName, responseDocumentForEvent, description, elapsedTimeNanos, commandListener, requestContext);
}
}
use of org.bson.BsonInt32 in project mongo-java-driver by mongodb.
the class IdHoldingBsonWriter method writeInt32.
@Override
public void writeInt32(final int value) {
addBsonValue(() -> new BsonInt32(value), () -> getIdBsonWriter().writeInt32(value));
super.writeInt32(value);
}
Aggregations