List of usage examples for com.mongodb WriteConcern JOURNALED
WriteConcern JOURNALED
To view the source code for com.mongodb WriteConcern JOURNALED.
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();//ww w. jav a 2 s .c om 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 . j a va 2s.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.waveprotocol.box.server.persistence.mongodb.MongoDbDeltaCollection.java
License:Apache License
@Override public void append(Collection<WaveletDeltaRecord> newDeltas) throws PersistenceException { for (WaveletDeltaRecord delta : newDeltas) { // Using Journaled Write Concern // (http://docs.mongodb.org/manual/core/write-concern/#journaled) deltaDbCollection.insert(MongoDbDeltaStoreUtil.serialize(delta, waveletName.waveId.serialise(), waveletName.waveletId.serialise()), WriteConcern.JOURNALED); }//from www . j a v a 2 s .c o m }
From source file:org.waveprotocol.box.server.persistence.mongodb.MongoDbDeltaStore.java
License:Apache License
@Override public void delete(WaveletName waveletName) throws PersistenceException, FileNotFoundPersistenceException { DBObject criteria = new BasicDBObject(); criteria.put(MongoDbDeltaStoreUtil.FIELD_WAVE_ID, waveletName.waveId.serialise()); criteria.put(MongoDbDeltaStoreUtil.FIELD_WAVELET_ID, waveletName.waveletId.serialise()); try {// w ww .j a va 2s. co m // Using Journaled Write Concern // (http://docs.mongodb.org/manual/core/write-concern/#journaled) getDeltaDbCollection().remove(criteria, WriteConcern.JOURNALED); } catch (MongoException e) { throw new PersistenceException(e); } }
From source file:simple.crawler.mongo.CrawlingDB.java
License:Open Source License
public boolean save(CrawlingDBObject obj, Collection collection) { DB db = client.getDB(dbName);//ww w . j a v a 2 s . c om DBCollection con = db.getCollection(collection.toString()); WriteResult result = con.save(obj, WriteConcern.JOURNALED); if (result.getError() == null) { return true; } else { LOG.error(result.getError()); return false; } }
From source file:youtube.managedb.ManageDB.java
public void addMetaData(DBCollection collection, BasicDBObject infodbobject) { /*File file = new File("/home/user/Stage/MongoDB/P13_2015_NOUIOUA_BOUTITI.pdf"); //from ww w . j a v a 2 s .co m GridFS gridfs = new GridFS(db, "downloads"); GridFSInputFile gfsFile = gridfs.createFile(file); gfsFile.setFilename("NOUIOUA_BOUTITI"); gfsFile.setId("1"); gfsFile.save(); */ /** * Insertion de l'objet dans la collection */ collection.insert(infodbobject, WriteConcern.JOURNALED); /** * */ }