Example usage for com.mongodb WriteConcern ACKNOWLEDGED

List of usage examples for com.mongodb WriteConcern ACKNOWLEDGED

Introduction

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

Prototype

WriteConcern ACKNOWLEDGED

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

Click Source Link

Document

Write operations that use this write concern will wait for acknowledgement, using the default write concern configured on the server.

Usage

From source file:com.ebay.cloud.cms.dal.persistence.ConsistentPolicy.java

License:Apache License

public ConsistentPolicy(String name, ReadPreference rp) {
    this.pref = rp;
    this.concern = WriteConcern.ACKNOWLEDGED;
    this.name = name;
}

From source file:com.epam.dlab.mongo.MongoDbConnection.java

License:Apache License

/**
 * Instantiate the helper for Mongo database adapter.
 *
 * @param host         the host name.//  w  w  w .  j a va2 s.  c  o m
 * @param port         the port.
 * @param databaseName the name of database.
 * @param username     the name of user.
 * @param password     the password.
 * @throws AdapterException
 */
public MongoDbConnection(String host, int port, String databaseName, String username, String password)
        throws AdapterException {
    try {
        client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(
                MongoCredential.createCredential(username, databaseName, password.toCharArray())));
        database = client.getDatabase(databaseName).withWriteConcern(WriteConcern.ACKNOWLEDGED);
    } catch (Exception e) {
        throw new AdapterException(
                "Cannot create connection to database " + databaseName + ". " + e.getLocalizedMessage(), e);
    }
}

From source file:com.epam.ta.reportportal.config.MongodbConfiguration.java

License:Open Source License

@Bean
@Profile("!unittest")
MongoDbFactory mongoDbFactory() throws UnknownHostException {

    SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongo(), mongoProperties.getDbName());

    mongoDbFactory.setWriteConcern(WriteConcern.ACKNOWLEDGED);

    return mongoDbFactory;
}

From source file:com.epam.ta.reportportal.config.MongodbConfiguration.java

License:Open Source License

@Bean
MongoTemplate mongoTemplate() throws UnknownHostException {
    MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory(), mappingMongoConverter());
    mongoTemplate.setWriteConcern(WriteConcern.ACKNOWLEDGED);

    return mongoTemplate;
}

From source file:com.github.krr.mongodb.aggregate.support.config.AggregateTestConfiguration.java

License:Apache License

@Bean
public MongoTemplate mongoTemplate(MongoClient mongo, MongoConverter mongoConverter, String dbName) {
    MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory(mongo, dbName), mongoConverter);
    mongoTemplate.setWriteConcern(WriteConcern.ACKNOWLEDGED);
    return mongoTemplate;
}

From source file:com.health.smart.util.MongoC.java

public static void insert(String collection, String document) throws Exception {
    DBCollection coll = getClient().getDB(database).getCollection(collection);
    coll.insert((DBObject) JSON.parse(document), WriteConcern.ACKNOWLEDGED);
}

From source file:com.health.smart.util.MongoC.java

public static void insert(String collection, DBObject document) throws Exception {
    DBCollection coll = getClient().getDB(database).getCollection(collection);
    coll.insert(document, WriteConcern.ACKNOWLEDGED);
}

From source file:com.ibm.sae.LoadDreamHomeDB.java

/***************************************************************/
 private static void loadCounters(DB db) {
     System.out.println("LoadDreamHomeDB:loadCounters begins");

     DBCollection coll = db.getCollection("dhCounterColl");
     System.out.println("LoadDreamHomeDB:loadCounters collection");
     coll.drop();// w w w  .ja v a 2  s.c  om

     System.out.println("LoadDreamHomeDB:loadCounters after drop");

     DBObject countersDoc = new BasicDBObject("_id", "notificationId").append("seq", 5000);

     WriteResult wr = coll.insert(countersDoc, WriteConcern.ACKNOWLEDGED);

     countersDoc = new BasicDBObject("_id", "clientId").append("seq", 4000);

     wr = coll.insert(countersDoc, WriteConcern.ACKNOWLEDGED);

     countersDoc = new BasicDBObject("_id", "propertyId").append("seq", 2000);

     wr = coll.insert(countersDoc, WriteConcern.ACKNOWLEDGED);

     countersDoc = new BasicDBObject("_id", "agentId").append("seq", 1000);

     wr = coll.insert(countersDoc, WriteConcern.ACKNOWLEDGED);

     countersDoc = new BasicDBObject("_id", "officeId").append("seq", 3000);

     wr = coll.insert(countersDoc, WriteConcern.ACKNOWLEDGED);

     System.out.println("LoadDreamHomeDB:loadNotificationCounters ends");
 }

From source file:com.ibm.sae.LoadDreamHomeDB.java

/***************************************************************/
 private static void loadClient(DB db, DBCollection coll) {
     System.out.println("LoadDreamHomeDB:loadClient begins");

     coll.drop();//from w  w  w .  java2 s.  c  om

     List<DBObject> comments = new ArrayList<DBObject>();
     List<DBObject> suggestedProperties = new ArrayList<DBObject>();

     DBObject commentDoc = new BasicDBObject("comment", "This is a beautiful home");

     comments.add(commentDoc);

     DBObject propertyDoc = new BasicDBObject("propertyId", 1999).append("propertyState", 0)
             .append("askingPrice", 689900.45).append("rating", 0).append("comments", comments);

     suggestedProperties.add(propertyDoc);

     DBObject clientDoc = new BasicDBObject("clientId", 3999)
             .append("clientName", new BasicDBObject("clientFN", "Richard").append("clientLN", "Hendrix"))
             .append("clientInfo",
                     new BasicDBObject("address", "101 Valley Street").append("city", "Glendale")
                             .append("state", "California").append("zip", "67854"))
             .append("agentId", 1001).append("suggestedProperties", suggestedProperties)
             .append("minAskingPrice", 500000.00).append("maxAskingPrice", 700000.00);

     WriteResult wr = coll.insert(clientDoc, WriteConcern.ACKNOWLEDGED);

     System.out.println("LoadDreamHomeDB:loadClient ends");
 }

From source file:com.ibm.sae.LoadDreamHomeDB.java

/***************************************************************/
 private static void loadAgent(DB db, DBCollection coll) {
     System.out.println("LoadDreamHomeDB:loadAgent begins");

     coll.drop();// www .ja  va  2s . c  o m

     List<DBObject> properties = new ArrayList<DBObject>();

     DBObject propertyDoc = new BasicDBObject("propertyId", 2000).append("clientId", 4000)
             .append("propertyState", 0);

     properties.add(propertyDoc);

     DBObject agentDoc = new BasicDBObject("agentId", 999)
             .append("agentData", new BasicDBObject("agentFN", "Dinesh").append("agentLN", "Chugtai")
                     .append("agentLicense", "CAL-34917"))
             .append("officeId", 3000).append("properties", properties);

     WriteResult wr = coll.insert(agentDoc, WriteConcern.ACKNOWLEDGED);

     System.out.println("LoadDreamHomeDB:loadAgent ends");
 }