Package com.mongodb

Examples of com.mongodb.WriteConcern$Majority


      }

      dbObjects.add(dbObject);
    }

    WriteConcern writeConcern = (WriteConcern) options.get(Options.OPTION_WRITE_CONCERN);

    if (writeConcern == null)
      collection.insert(dbObjects);
    else
      collection.insert(dbObjects, writeConcern);
View Full Code Here


    // The timestamp needs to be persisted with the object, and set in the response

    long timeStamp = System.currentTimeMillis();
    dbObject.put(Keywords.TIME_STAMP_KEY, timeStamp);
    response.put(URIConverter.RESPONSE_TIME_STAMP_PROPERTY, timeStamp);
    WriteConcern writeConcern = (WriteConcern) options.get(Options.OPTION_WRITE_CONCERN);

    if (id == null)
    {
      // The id was not specified in the URI, so we can let MongoDB generate the id or use the value
      // of the ID attribute
View Full Code Here

  @Test
  public void parsesCustomWriteConcern() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
        "namespace/db-factory-bean-custom-write-concern.xml");
    assertWriteConcern(ctx, new WriteConcern("rack1"));
  }
View Full Code Here

  private void assertWriteConcern(ClassPathXmlApplicationContext ctx, WriteConcern expectedWriteConcern) {
    SimpleMongoDbFactory dbFactory = ctx.getBean("first", SimpleMongoDbFactory.class);
    DB db = dbFactory.getDb();
    assertThat(db.getName(), is("db"));

    WriteConcern configuredConcern = (WriteConcern) ReflectionTestUtils.getField(dbFactory, "writeConcern");

    MyWriteConcern myDbFactoryWriteConcern = new MyWriteConcern(configuredConcern);
    MyWriteConcern myDbWriteConcern = new MyWriteConcern(db.getWriteConcern());
    MyWriteConcern myExpectedWriteConcern = new MyWriteConcern(expectedWriteConcern);
View Full Code Here

  // This test will fail since equals in WriteConcern uses == for _w and not .equals
  public void testWriteConcernEquality() {
    String s1 = new String("rack1");
    String s2 = new String("rack1");
    WriteConcern wc1 = new WriteConcern(s1);
    WriteConcern wc2 = new WriteConcern(s2);
    assertThat(wc1, is(wc2));
  }
View Full Code Here

  @Test
  public void createsWriteConcernForUnknownConstants() {

    editor.setAsText("-1");
    assertThat(editor.getValue(), is((Object) new WriteConcern("-1")));
  }
View Full Code Here

    }
    execute(collectionName, new CollectionCallback<Void>() {
      public Void doInCollection(DBCollection collection) throws MongoException, DataAccessException {
        MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.INSERT_LIST, collectionName, null,
            null, null);
        WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
        WriteResult writeResult = writeConcernToUse == null ? collection.insert(dbDocList) : collection.insert(
            dbDocList.toArray((DBObject[]) new BasicDBObject[dbDocList.size()]), writeConcernToUse);
        handleAnyWriteResultErrors(writeResult, null, MongoActionOperation.INSERT_LIST);
        return null;
      }
View Full Code Here

    }
    return execute(collectionName, new CollectionCallback<Object>() {
      public Object doInCollection(DBCollection collection) throws MongoException, DataAccessException {
        MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.SAVE, collectionName, entityClass,
            dbDoc, null);
        WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
        WriteResult writeResult = writeConcernToUse == null ? collection.save(dbDoc) : collection.save(dbDoc,
            writeConcernToUse);
        handleAnyWriteResultErrors(writeResult, dbDoc, MongoActionOperation.SAVE);
        return dbDoc.get(ID_FIELD);
      }
View Full Code Here

              + collectionName);
        }

        MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.UPDATE, collectionName,
            entityClass, updateObj, queryObj);
        WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
        WriteResult writeResult = writeConcernToUse == null ? collection.update(queryObj, updateObj, upsert, multi)
            : collection.update(queryObj, updateObj, upsert, multi, writeConcernToUse);

        if (entity != null && entity.hasVersionProperty() && !multi) {
          if (writeResult.getN() == 0 && dbObjectContainsVersionProperty(queryObj, entity)) {
View Full Code Here

        DBObject dboq = queryMapper.getMappedObject(queryObject, entity);

        MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.REMOVE, collectionName,
            entityClass, null, queryObject);
        WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);

        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("Remove using query: {} in collection: {}.", new Object[] { dboq, collection.getName() });
        }
View Full Code Here

TOP

Related Classes of com.mongodb.WriteConcern$Majority

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.