Example usage for com.mongodb WriteConcern W1

List of usage examples for com.mongodb WriteConcern W1

Introduction

In this page you can find the example usage for com.mongodb WriteConcern W1.

Prototype

WriteConcern W1

To view the source code for com.mongodb WriteConcern W1.

Click Source Link

Document

Write operations that use this write concern will wait for acknowledgement from a single member.

Usage

From source file:org.jooby.mongodb.MongoRx.java

License:Apache License

static MongoClientSettings.Builder settings(final ConnectionString cstr, final Config conf) {
    MongoClientSettings.Builder settings = MongoClientSettings.builder();

    settings.clusterSettings(cluster(cstr, conf));
    settings.connectionPoolSettings(pool(cstr, conf));
    settings.heartbeatSocketSettings(socket("heartbeat", cstr, conf));

    withStr("readConcern", conf,
            v -> settings.readConcern(Match(v.toUpperCase())
                    .option(Case("DEFAULT", ReadConcern.DEFAULT), Case("LOCAL", ReadConcern.LOCAL),
                            Case("MAJORITY", ReadConcern.MAJORITY))
                    .getOrElseThrow(() -> new IllegalArgumentException("readConcern=" + v))));

    withStr("readPreference", conf, v -> settings.readPreference(ReadPreference.valueOf(v)));

    settings.serverSettings(server(conf));
    settings.socketSettings(socket("socket", cstr, conf));
    settings.sslSettings(ssl(cstr, conf));

    withStr("writeConcern", conf,
            v -> settings.writeConcern(Match(v.toUpperCase())
                    .option(Case("W1", WriteConcern.W1), Case("W2", WriteConcern.W2),
                            Case("W3", WriteConcern.W3), Case("ACKNOWLEDGED", WriteConcern.ACKNOWLEDGED),
                            Case("JOURNALED", WriteConcern.JOURNALED), Case("MAJORITY", WriteConcern.MAJORITY))
                    .getOrElseThrow(() -> new IllegalArgumentException("writeConcern=" + v))));

    return settings;
}