Search in sources :

Example 76 with BsonInt32

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());
}
Also used : BsonInt32(org.bson.BsonInt32) BsonDocument(org.bson.BsonDocument) Document(org.bson.Document) BsonDocument(org.bson.BsonDocument) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 77 with BsonInt32

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));
        }
    };
}
Also used : BsonInt32(org.bson.BsonInt32) BsonDocument(org.bson.BsonDocument) RawBsonDocument(org.bson.RawBsonDocument) RawBsonDocument(org.bson.RawBsonDocument)

Example 78 with BsonInt32

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);
}
Also used : BsonInt32(org.bson.BsonInt32)

Example 79 with BsonInt32

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);
    }
}
Also used : BsonInt32(org.bson.BsonInt32) BsonDocument(org.bson.BsonDocument)

Example 80 with BsonInt32

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);
}
Also used : BsonInt32(org.bson.BsonInt32)

Aggregations

BsonInt32 (org.bson.BsonInt32)106 BsonDocument (org.bson.BsonDocument)91 BsonString (org.bson.BsonString)58 BsonArray (org.bson.BsonArray)26 Test (org.junit.Test)26 Document (org.bson.Document)23 BsonInt64 (org.bson.BsonInt64)20 Test (org.junit.jupiter.api.Test)16 BsonValue (org.bson.BsonValue)15 ArrayList (java.util.ArrayList)13 List (java.util.List)9 BsonDouble (org.bson.BsonDouble)9 DisplayName (org.junit.jupiter.api.DisplayName)8 BsonNull (org.bson.BsonNull)7 MongoClientSettings (com.mongodb.MongoClientSettings)6 TestCommandListener (com.mongodb.internal.connection.TestCommandListener)5 Map (java.util.Map)5 BsonBoolean (org.bson.BsonBoolean)5 ClusterFixture.serverVersionAtLeast (com.mongodb.ClusterFixture.serverVersionAtLeast)4 ServerAddress (com.mongodb.ServerAddress)4