Package com.mongodb

Examples of com.mongodb.MongoOptions


        final int port = PropertiesUtil.toInteger(props.get(PROP_PORT), DEFAULT_PORT);
        final String db = PropertiesUtil.toString(props.get(PROP_DB), DEFAULT_DB);
        logger.info("Starting MongoDB resource provider with host={}, port={}, db={}",
                new Object[] {host, port, db});
        final DBAddress address = new DBAddress(host, port, db);
        final MongoOptions options = new MongoOptions();
       
        options.connectionsPerHost = PropertiesUtil.toInteger(props.get(PROP_NUM_CONNECTIONS), DEFAULT_NUMCONNECTIONS);
        options.threadsAllowedToBlockForConnectionMultiplier = PropertiesUtil.toInteger(props.get(PROP_THREAD_MULTIPLIER), DEFAULT_THREAD_MULTIPLIER);
        final Mongo m = new Mongo(address, options);
View Full Code Here


                if (mongoURI != null) {
                    MongoURI uri = new MongoURI(mongoURI);
                    mongo = new Mongo(uri);
                }
                else {
                    MongoOptions mongoOptions = createMongoOptions(properties);
                   
                    mongo = createMongo(host, port, mongoOptions);
                }

                mongo.setWriteConcern(WriteConcern.valueOf(writeConcern));
View Full Code Here

        int socketTimeout = getProperty(properties, "socketTimeout", 0);
        int threadsAllowedToBlockForConnectionMultiplier = getProperty(properties, "threadsAllowedToBlockForConnectionMultiplier", 5);
        int w = getProperty(properties, "w", 0);
        int wtimeout = getProperty(properties, "wtimeout", 0);
       
        MongoOptions mongoOptions = new MongoOptions();
        mongoOptions.autoConnectRetry = autoConnectRetry;
        mongoOptions.connectionsPerHost = connectionsPerHost;
        mongoOptions.connectTimeout = connectTimeout;
        mongoOptions.description = description;
        mongoOptions.fsync = fsync;
View Full Code Here

            return new Mongo();
        }
    }

    private MongoOptions getMongoOptions() {
        MongoOptions options = new MongoOptions();
        options.autoConnectRetry = autoConnectRetry;
        options.connectionsPerHost = connectionsPerHost;
        options.connectTimeout = connectionTimeout;
        options.socketTimeout = socketTimeout;
        options.threadsAllowedToBlockForConnectionMultiplier = threadsAllowedToBlockForConnectionMultiplier;
View Full Code Here

                }

                // need to append db to url.
                url += "/" + database;
                System.out.println("new database url = " + url);
                MongoOptions options = new MongoOptions();
                options.connectionsPerHost = Integer.parseInt(maxConnections);
                mongo = new Mongo(new DBAddress(url), options);

                System.out.println("mongo connection created with " + url);
            }
View Full Code Here

    MongoOptionsFactoryBean bean = new MongoOptionsFactoryBean();
    bean.setMaxAutoConnectRetryTime(27);
    bean.afterPropertiesSet();

    MongoOptions options = bean.getObject();
    assertThat(options.maxAutoConnectRetryTime, is(27L));
  }
View Full Code Here

    MongoOptionsFactoryBean bean = new MongoOptionsFactoryBean();
    bean.setSsl(true);
    bean.afterPropertiesSet();

    MongoOptions options = bean.getObject();
    assertNotNull(options.getSocketFactory());
    assertTrue(options.getSocketFactory() instanceof SSLSocketFactory);
  }
View Full Code Here

    Mongo mongo;
    ServerAddress defaultOptions = new ServerAddress();

    if (mongoOptions == null) {
      mongoOptions = new MongoOptions();
    }

    if (!isNullOrEmpty(replicaPair)) {
      if (replicaPair.size() < 2) {
        throw new CannotGetMongoDbConnectionException("A replica pair must have two server entries");
View Full Code Here

   * (non-Javadoc)
   * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
   */
  public void afterPropertiesSet() {

    MongoOptions options = new MongoOptions();

    options.connectionsPerHost = connectionsPerHost;
    options.threadsAllowedToBlockForConnectionMultiplier = threadsAllowedToBlockForConnectionMultiplier;
    options.maxWaitTime = maxWaitTime;
    options.connectTimeout = connectTimeout;
    options.socketTimeout = socketTimeout;
    options.socketKeepAlive = socketKeepAlive;
    options.autoConnectRetry = autoConnectRetry;
    options.maxAutoConnectRetryTime = maxAutoConnectRetryTime;
    options.slaveOk = slaveOk;
    options.w = writeNumber;
    options.wtimeout = writeTimeout;
    options.fsync = writeFsync;

    if (ssl) {
      options.setSocketFactory(sslSocketFactory != null ? sslSocketFactory : SSLSocketFactory.getDefault());
    }

    this.options = options;
  }
View Full Code Here

    Integer port = (Integer) getField(mfb, "port");

    assertEquals("localhost", host);
    assertEquals(new Integer(27017), port);

    MongoOptions options = (MongoOptions) getField(mfb, "mongoOptions");
    assertFalse("By default socketFactory should not be a SSLSocketFactory",
        options.getSocketFactory() instanceof SSLSocketFactory);
  }
View Full Code Here

TOP

Related Classes of com.mongodb.MongoOptions

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.