Java 类com.mongodb.ReadConcern 实例源码

项目:vertx-mongo-client    文件:ParsingReadConcernLevelTest.java   
@Parameters(method = "validReadConcernValues")
@Test
public void should_parse_read_concern_from_connection_string(String readConcernString, ReadConcern expectedReadConcern) throws Exception {
  // given
  final JsonObject configWithConnectionString = new JsonObject().put(
    "connection_string",
    String.format("mongodb://localhost:27017/mydb?replicaSet=myRs&readconcernlevel=%s", readConcernString)
  );

  // when
  final ReadConcern parsedReadConcern = new MongoClientOptionsParser(configWithConnectionString)
    .settings()
    .getReadConcern();

  // then
  assertEquals(expectedReadConcern, parsedReadConcern);
}
项目:vertx-mongo-client    文件:ParsingReadConcernLevelTest.java   
@Parameters(method = "validReadConcernValues")
@Test
public void should_fallback_to_config_property_if_read_concern_not_present_in_connection_string(String readConcernString, ReadConcern expectedReadConcern) throws Exception {
  // given
  final JsonObject configWithReadConcernAsSeparateProperty = new JsonObject()
    .put("connection_string", "mongodb://localhost:27017/mydb?replicaSet=myRs")
    .put("readConcernLevel", readConcernString);

  // when
  final ReadConcern parsedReadConcern = new MongoClientOptionsParser(configWithReadConcernAsSeparateProperty)
    .settings()
    .getReadConcern();

  // then
  assertEquals(expectedReadConcern, parsedReadConcern);
}
项目:vertx-mongo-client    文件:ParsingReadConcernLevelTest.java   
@Test
public void should_return_default_read_concern_in_case_of_missing_read_concern_in_connection_string_or_config_object() throws Exception {
  // given
  final JsonObject configWithConnectionString = new JsonObject().put(
    "connection_string",
    "mongodb://localhost:27017/mydb?replicaSet=myRs"
  );

  // when
  final ReadConcern parsedReadConcern = new MongoClientOptionsParser(configWithConnectionString)
    .settings()
    .getReadConcern();

  // then
  assertEquals(ReadConcern.DEFAULT, parsedReadConcern);
}
项目:morphia    文件:CountOptionsTest.java   
@Test
public void passThrough() {
    Collation collation = Collation.builder()
                                   .locale("en")
                                   .caseLevel(true)
                                   .build();
    DBCollectionCountOptions options = new CountOptions()
        .collation(collation)
        .hint("i'm a hint")
        .limit(18)
        .maxTime(15, TimeUnit.MINUTES)
        .readPreference(ReadPreference.secondaryPreferred())
        .readConcern(ReadConcern.LOCAL)
        .skip(12)
        .getOptions();

    assertEquals(collation, options.getCollation());
    assertEquals("i'm a hint", options.getHintString());
    assertEquals(18, options.getLimit());
    assertEquals(15, options.getMaxTime(TimeUnit.MINUTES));
    assertEquals(ReadPreference.secondaryPreferred(), options.getReadPreference());
    assertEquals(ReadConcern.LOCAL, options.getReadConcern());
    assertEquals(12, options.getSkip());
}
项目:tangyuan2    文件:DefaultDataSourceCreater.java   
private ReadConcern getReadConcern(String readConcern) {
    if ("LOCAL".equalsIgnoreCase(readConcern)) {
        return ReadConcern.LOCAL;
    }
    if ("MAJORITY".equalsIgnoreCase(readConcern)) {
        return ReadConcern.MAJORITY;
    }
    return ReadConcern.DEFAULT;
}
项目:vertx-mongo-client    文件:ParsingReadConcernLevelTest.java   
@Test
public void should_prefer_read_concern_passed_via_connection_string_over_property_value() throws Exception {
  // given
  final JsonObject configWithReadConcernPassedTwice = new JsonObject()
    .put("connection_string", "mongodb://localhost:27017/mydb?replicaSet=myRs&readconcernlevel=majority")
    .put("readConcernLevel", "linearizable");

  // when
  final ReadConcern parsedReadConcern = new MongoClientOptionsParser(configWithReadConcernPassedTwice)
    .settings()
    .getReadConcern();

  // then
  assertEquals(ReadConcern.MAJORITY, parsedReadConcern);
}
项目:vertx-mongo-client    文件:ParsingReadConcernLevelTest.java   
private Object[] validReadConcernValues() {
  return new Object[]{
    new Object[]{"local", ReadConcern.LOCAL},
    new Object[]{"majority", ReadConcern.MAJORITY},
    new Object[]{"linearizable", ReadConcern.LINEARIZABLE}
  };
}
项目:jooby    文件:MongoRx.java   
private static ReadConcern readConcern(final String value) {
  return when(value.toUpperCase())
      .is("DEFAULT", ReadConcern.DEFAULT)
      .is("LOCAL", ReadConcern.LOCAL)
      .is("MAJORITY", ReadConcern.MAJORITY)
      .orElseThrow(() -> new IllegalArgumentException("readConcern: " + value));
}
项目:ibm-performance-monitor    文件:ProfiledMongoCollection.java   
@Override
public ReadConcern getReadConcern()
{
    return collection.getReadConcern();
}
项目:ibm-performance-monitor    文件:ProfiledMongoCollection.java   
@Override
public MongoCollection<TDocument> withReadConcern(ReadConcern arg0)
{
    return new ProfiledMongoCollection<TDocument>(collection.withReadConcern(arg0));
}
项目:ibm-performance-monitor    文件:ProfiledMongoDatabase.java   
@Override
public ReadConcern getReadConcern()
{
    return database.getReadConcern();
}
项目:ibm-performance-monitor    文件:ProfiledMongoDatabase.java   
@Override
public MongoDatabase withReadConcern(ReadConcern readConcern)
{
    return new ProfiledMongoDatabase(database.withReadConcern(readConcern));
}
项目:mongo-java-driver-rx    文件:MongoCollectionImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-rx    文件:MongoCollectionImpl.java   
@Override
public MongoCollection<TDocument> withReadConcern(final ReadConcern readConcern) {
    return new MongoCollectionImpl<TDocument>(wrapped.withReadConcern(readConcern), observableAdapter);
}
项目:mongo-java-driver-rx    文件:MongoDatabaseImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-rx    文件:MongoDatabaseImpl.java   
@Override
public MongoDatabase withReadConcern(final ReadConcern readConcern) {
    return new MongoDatabaseImpl(wrapped.withReadConcern(readConcern), observableAdapter);
}
项目:mongo-java-driver-rx    文件:GridFSBucketImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-rx    文件:GridFSBucketImpl.java   
@Override
public GridFSBucket withReadConcern(final ReadConcern readConcern) {
    return new GridFSBucketImpl(wrapped.withReadConcern(readConcern), observableAdapter);
}
项目:respiro    文件:MongoDBExchangesPlugin.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:respiro    文件:MongoDBExchangesPlugin.java   
@Override
public MongoDatabase withReadConcern(ReadConcern readConcern) {
    return null;
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-reactivestreams    文件:MongoCollectionImpl.java   
@Override
public MongoCollection<TDocument> withReadConcern(final ReadConcern readConcern) {
    return new MongoCollectionImpl<TDocument>(wrapped.withReadConcern(readConcern));
}
项目:mongo-java-driver-reactivestreams    文件:MongoDatabaseImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-reactivestreams    文件:MongoDatabaseImpl.java   
@Override
public MongoDatabase withReadConcern(final ReadConcern readConcern) {
    return new MongoDatabaseImpl(wrapped.withReadConcern(readConcern));
}
项目:mongo-java-driver-reactivestreams    文件:GridFSBucketImpl.java   
@Override
public ReadConcern getReadConcern() {
    return wrapped.getReadConcern();
}
项目:mongo-java-driver-reactivestreams    文件:GridFSBucketImpl.java   
@Override
public GridFSBucket withReadConcern(final ReadConcern readConcern) {
    return new GridFSBucketImpl(wrapped.withReadConcern(readConcern));
}
项目:vertx-mongo-client    文件:ReadConcernLevelParser.java   
Optional<ReadConcern> readConcern() {
  return tryToParseFromConnectionString().map(this::lift).orElseGet(this::tryToParseFromConfig);
}
项目:vertx-mongo-client    文件:ReadConcernLevelParser.java   
private Optional<ReadConcern> lift(ReadConcern readConcern) {
  return Optional.ofNullable(readConcern);
}
项目:vertx-mongo-client    文件:ReadConcernLevelParser.java   
private Optional<ReadConcern> tryToParseFromConnectionString() {
  return Optional.ofNullable(connectionString)
    .flatMap(cs -> Optional.ofNullable(cs.getReadConcern()));
}
项目:vertx-mongo-client    文件:ReadConcernLevelParser.java   
private Optional<ReadConcern> tryToParseFromConfig() {
  return Optional.ofNullable(config)
    .flatMap(cfg -> Optional.ofNullable(cfg.getString("readConcernLevel")))
    .map(ReadConcernLevel::fromString)
    .map(ReadConcern::new);
}
项目:morphia    文件:FindOptionsTest.java   
@Test
public void passThrough() {
    Collation collation = Collation.builder()
                                   .locale("en")
                                   .caseLevel(true)
                                   .build();
    DBCollectionFindOptions options = new FindOptions()
        .batchSize(42)
        .limit(18)
        .modifier("i'm a", "modifier")
        .modifier("i am", 2)
        .projection(new BasicDBObject("field", "value"))
        .maxTime(15, TimeUnit.MINUTES)
        .maxAwaitTime(45, TimeUnit.SECONDS)
        .skip(12)
        .sort(new BasicDBObject("field", -1))
        .cursorType(CursorType.TailableAwait)
        .noCursorTimeout(true)
        .oplogReplay(true)
        .partial(true)
        .readPreference(ReadPreference.secondaryPreferred(2, TimeUnit.MINUTES))
        .readConcern(ReadConcern.LOCAL)
        .collation(collation).getOptions();

    assertEquals(42, options.getBatchSize());
    assertEquals(18, options.getLimit());
    assertEquals(new BasicDBObject("i'm a", "modifier")
                     .append("i am", 2), options.getModifiers());
    assertEquals(new BasicDBObject("field", "value"), options.getProjection());
    assertEquals(15, options.getMaxTime(TimeUnit.MINUTES));
    assertEquals(45, options.getMaxAwaitTime(TimeUnit.SECONDS));
    assertEquals(12, options.getSkip());
    assertEquals(new BasicDBObject("field", -1), options.getSort());
    assertEquals(CursorType.TailableAwait, options.getCursorType());
    assertTrue(options.isNoCursorTimeout());
    assertTrue(options.isOplogReplay());
    assertTrue(options.isPartial());
    assertEquals(ReadPreference.secondaryPreferred(2, TimeUnit.MINUTES), options.getReadPreference());
    assertEquals(ReadConcern.LOCAL, options.getReadConcern());
    assertEquals(collation, options.getCollation());
}
项目:mongo-java-driver-rx    文件:MongoDatabase.java   
/**
 * Get the read concern for the MongoDatabase.
 *
 * @return the {@link com.mongodb.ReadConcern}
 * @since 1.2
 * @mongodb.server.release 3.2
 */
ReadConcern getReadConcern();
项目:mongo-java-driver-rx    文件:MongoDatabase.java   
/**
 * Create a new MongoDatabase instance with a different read concern.
 *
 * @param readConcern the new {@link ReadConcern} for the database
 * @return a new MongoDatabase instance with the different ReadConcern
 * @since 1.2
 * @mongodb.server.release 3.2
 */
MongoDatabase withReadConcern(ReadConcern readConcern);
项目:mongo-java-driver-rx    文件:GridFSBucket.java   
/**
 * Get the read concern for the GridFSBucket.
 *
 * @return the {@link com.mongodb.ReadConcern}
 * @mongodb.server.release 3.2
 * @mongodb.driver.manual reference/readConcern/ Read Concern
 */
ReadConcern getReadConcern();
项目:mongo-java-driver-rx    文件:GridFSBucket.java   
/**
 * Create a new MongoDatabase instance with a different read concern.
 *
 * @param readConcern the new {@link ReadConcern} for the database
 * @return a new GridFSBucket instance with the different ReadConcern
 * @mongodb.server.release 3.2
 * @mongodb.driver.manual reference/readConcern/ Read Concern
 */
GridFSBucket withReadConcern(ReadConcern readConcern);
项目:mongo-java-driver-rx    文件:MongoCollection.java   
/**
 * Get the read concern for the MongoCollection.
 *
 * @return the {@link com.mongodb.ReadConcern}
 * @since 1.2
 * @mongodb.server.release 3.2
 */
ReadConcern getReadConcern();
项目:mongo-java-driver-rx    文件:MongoCollection.java   
/**
 * Create a new MongoCollection instance with a different read concern.
 *
 * @param readConcern the new {@link ReadConcern} for the collection
 * @return a new MongoCollection instance with the different ReadConcern
 * @since 1.2
 * @mongodb.server.release 3.2
 */
MongoCollection<TDocument> withReadConcern(ReadConcern readConcern);
项目:mongo-java-driver-reactivestreams    文件:MongoDatabase.java   
/**
 * Get the read concern for the MongoCollection.
 *
 * @return the {@link com.mongodb.ReadConcern}
 * @since 1.2
 * @mongodb.server.release 3.2
 */
ReadConcern getReadConcern();
项目:mongo-java-driver-reactivestreams    文件:MongoDatabase.java   
/**
 * Create a new MongoDatabase instance with a different read concern.
 *
 * @param readConcern the new {@link ReadConcern} for the collection
 * @return a new MongoDatabase instance with the different ReadConcern
 * @since 1.2
 * @mongodb.server.release 3.2
 */
MongoDatabase withReadConcern(ReadConcern readConcern);
项目:mongo-java-driver-reactivestreams    文件:GridFSBucket.java   
/**
 * Get the read concern for the GridFSBucket.
 *
 * @return the {@link com.mongodb.ReadConcern}
 * @mongodb.server.release 3.2
 * @mongodb.driver.manual reference/readConcern/ Read Concern
 */
ReadConcern getReadConcern();