List of usage examples for com.mongodb WriteConcern MAJORITY
WriteConcern MAJORITY
To view the source code for com.mongodb WriteConcern MAJORITY.
Click Source Link
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; }
From source file:org.lucee.mongodb.support.ObjectSupport.java
License:Open Source License
public WriteConcern toWriteConcern(Object obj, WriteConcern defaultValue) { if (obj instanceof WriteConcern) return (WriteConcern) obj; if (decision.isSimpleValue(obj)) { String str = caster.toString(obj, ""); str = str.trim().toUpperCase();//from w ww . j av a2 s.c o m if ("ACKNOWLEDGED".equals(str)) return WriteConcern.ACKNOWLEDGED; else if ("ACKNOWLEDGED".equals(str)) return WriteConcern.FSYNC_SAFE; else if ("FSYNC_SAFE".equals(str) || "FSYNCSAFE".equals(str)) return WriteConcern.FSYNCED; else if ("JOURNAL_SAFE".equals(str) || "JOURNALSAFE".equals(str)) return WriteConcern.JOURNAL_SAFE; else if ("JOURNALED".equals(str)) return WriteConcern.JOURNALED; else if ("MAJORITY".equals(str)) return WriteConcern.MAJORITY; else if ("NORMAL".equals(str)) return WriteConcern.NORMAL; else if ("REPLICA_ACKNOWLEDGED".equals(str) || "REPLICAACKNOWLEDGED".equals(str)) return WriteConcern.REPLICA_ACKNOWLEDGED; else if ("REPLICAS_SAFE".equals(str) || "REPLICASSAFE".equals(str)) return WriteConcern.REPLICAS_SAFE; else if ("SAFE".equals(str)) return WriteConcern.SAFE; else if ("UNACKNOWLEDGED".equals(str)) return WriteConcern.UNACKNOWLEDGED; } return defaultValue; }
From source file:org.openmama.dbwriter.MamaMongodb.java
/** * @return Write concern for database writes *///from w w w.ja v a 2 s .c o m private WriteConcern getWriteConcern(final String config) { switch (config.toLowerCase()) { case "none": case "errors_ignored": case "errorsignored": return WriteConcern.ERRORS_IGNORED; case "safe": case "acknowledged": return WriteConcern.ACKNOWLEDGED; case "normal": case "unacknowledged": return WriteConcern.UNACKNOWLEDGED; case "fsync_safe": case "fsyncsafe": case "fsynced": return WriteConcern.FSYNCED; case "journal_safe": case "journalsafe": case "journaled": return WriteConcern.JOURNALED; case "replicas_safe": case "replicassafe": case "replica_acknowledged": case "replicaacknowledged": return WriteConcern.REPLICA_ACKNOWLEDGED; case "majority": return WriteConcern.MAJORITY; default: logger.warning(String.format("%s writeTo concern not valid - using UNACKNOWLEDGED", config)); return WriteConcern.UNACKNOWLEDGED; } }
From source file:org.qi4j.entitystore.mongodb.MongoMapEntityStoreMixin.java
License:Apache License
private void loadConfiguration() throws UnknownHostException { configuration.refresh();//w w w . j a va 2 s .com MongoEntityStoreConfiguration config = configuration.get(); // Combine hostname, port and nodes configuration properties serverAddresses = new ArrayList<ServerAddress>(); if (config.hostname().get() != null && !config.hostname().get().isEmpty()) { serverAddresses.add(new ServerAddress(config.hostname().get(), config.port().get())); } serverAddresses.addAll(config.nodes().get()); // If database name not configured, set it to qi4j:entitystore databaseName = config.database().get(); if (databaseName == null) { databaseName = DEFAULT_DATABASE_NAME; } // If collection name not configured, set it to qi4j:entitystore:entities collectionName = config.collection().get(); if (collectionName == null) { collectionName = DEFAULT_COLLECTION_NAME; } // If write concern not configured, set it to normal switch (config.writeConcern().get()) { case FSYNC_SAFE: writeConcern = WriteConcern.FSYNC_SAFE; break; case JOURNAL_SAFE: writeConcern = WriteConcern.JOURNAL_SAFE; break; case MAJORITY: writeConcern = WriteConcern.MAJORITY; break; case NONE: writeConcern = WriteConcern.NONE; break; case REPLICAS_SAFE: writeConcern = WriteConcern.REPLICAS_SAFE; break; case SAFE: writeConcern = WriteConcern.SAFE; break; case NORMAL: default: writeConcern = WriteConcern.NORMAL; } // Username and password are defaulted to empty strings username = config.username().get(); password = config.password().get().toCharArray(); }