Package com.mongodb

Examples of com.mongodb.WriteConcern


  private void executeBatchUpdate(Map<DBCollection, BatchInsertionTask> inserts, UpdateTupleOperation tupleOperation) {
    EntityKey entityKey = tupleOperation.getEntityKey();
    Tuple tuple = tupleOperation.getTuple();
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tupleOperation.getTuple().getSnapshot();
    WriteConcern writeConcern = getWriteConcern( tupleOperation.getTupleContext() );

    if ( INSERT == snapshot.getOperationType() && columnNamesAllowBatchInsert( tupleOperation ) ) {
      prepareForInsert( inserts, snapshot, entityKey, tuple, writeConcern );
    }
    else {
View Full Code Here


        String wPolicy = getStringFieldValue(Item.writePolicy);
        int wtimeout = getIntFieldValue(Item.writeTimeout);
//        boolean fsync = getBooleanFieldValue(Item.fsync);
        boolean jsync = getBooleanFieldValue(Item.jsync);
        if (!wPolicy.trim().isEmpty())
            return new WriteConcern(wPolicy, wtimeout, false, jsync);
        return new WriteConcern(w, wtimeout, false, jsync);
    }
View Full Code Here

    /**
     * Gets the write concern for entity or returns the default write concern for this datastore.
     */
    public WriteConcern getWriteConcern(Object clazzOrEntity) {
        WriteConcern wc = defConcern;
        if (clazzOrEntity != null) {
            wc = getMapper().getMappedClass(clazzOrEntity).getWriteConcern();
        }

        return wc;
View Full Code Here

     * Returns a WriteConcern for this mapped class - by default it is SAFE.
     *
     * @return
     */
    public WriteConcern getWriteConcern() {
        WriteConcern wc = WriteConcern.SAFE;

        Entity entity = (Entity) getFirstAnnotation(Entity.class);
        if (entity == null) {
            return wc;
        }
View Full Code Here

                    LOG.info("Using ReadPreference " + readPref);
                }
            }
            String write = map.get("write");
            if (write != null) {
                WriteConcern writeConcern = WriteConcern.valueOf(write);
                if (!writeConcern.equals(nodes.getWriteConcern())) {
                    nodes.setWriteConcern(writeConcern);
                    LOG.info("Using WriteConcern " + writeConcern);
                }
            }
        } catch (Exception e) {
View Full Code Here

     * Set the {@link WriteConcern} for write operations on MongoDB, passing in the bean ref to a custom WriteConcern which exists in the Registry.
     * You can also use standard WriteConcerns by passing in their key. See the {@link #setWriteConcern(String) setWriteConcern} method.
     * @param writeConcernRef the name of the bean in the registry that represents the WriteConcern to use
     */
    public void setWriteConcernRef(String writeConcernRef) {
        WriteConcern wc = this.getCamelContext().getRegistry().lookupByNameAndType(writeConcernRef, WriteConcern.class);
        if (wc == null) {
            LOG.error("Camel MongoDB component could not find the WriteConcern in the Registry. Verify that the "
                    + "provided bean name ({}) is correct. Aborting initialization.", writeConcernRef);
            throw new IllegalArgumentException("Camel MongoDB component could not find the WriteConcern in the Registry");  
        }
View Full Code Here

    }
  }

  private WriteConcern buildWriteConcern(Map<?, ?> cfg) {
    Object cfgWriteConcern = cfg.get( Environment.MONGODB_WRITE_CONCERN );
    WriteConcern writeConcern = Environment.MONGODB_DEFAULT_WRITE_CONCERN;
    String wcLogMessage = "ACKNOWLEDGED";
    if ( cfgWriteConcern != null ) {
      final String confWC = cfgWriteConcern.toString();
      writeConcern = WriteConcern.valueOf( confWC );
View Full Code Here

                        + "for the MongoDB provider.");
                return null;
            }
        }

        WriteConcern writeConcern;
        if (writeConcernConstant != null && writeConcernConstant.length() > 0) {
            if (writeConcernConstantClassName != null && writeConcernConstantClassName.length() > 0) {
                try {
                    final Class<?> writeConcernConstantClass = Class.forName(writeConcernConstantClassName);
                    final Field field = writeConcernConstantClass.getField(writeConcernConstant);
View Full Code Here

                    this.readPreference = readPref;
                }
            }
            String write = map.get("write");
            if (write != null) {
                WriteConcern writeConcern = WriteConcern.valueOf(write);
                if (!writeConcern.equals(this.writeConcern)) {
                    this.writeConcern = writeConcern;
                }
            }
        } catch (Exception e) {
            // unsupported or parse error - ignore
View Full Code Here

            if (!readPref.equals(nodes.getReadPreference())) {
                nodes.setReadPreference(readPref);
                LOG.info("Using ReadPreference {} ",readPref);
            }

            WriteConcern writeConcern = uri.getOptions().getWriteConcern();
            if (!writeConcern.equals(nodes.getWriteConcern())) {
                nodes.setWriteConcern(writeConcern);
                LOG.info("Using WriteConcern " + writeConcern);
            }
        } catch (Exception e) {
            LOG.error("Error setting readWriteMode " + readWriteMode, e);
View Full Code Here

TOP

Related Classes of com.mongodb.WriteConcern

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.