Package com.mongodb.MongoClientOptions

Examples of com.mongodb.MongoClientOptions.Builder


   
    HistManData data =new HistManData(loadProperties(model));

    try {

      Builder options = new MongoClientOptions.Builder();

      options.connectTimeout(data.histDBTimeout);

      if(mongoClient==null) {
        mongoClient = new MongoClient(data.histURL, options.build());
      }

      logger.info("trying to connect with database {} in host {}",
          data.histDBName, data.histURL);
View Full Code Here


    /**
     * Connect the instance.
     */
    public synchronized MongoClient connect() {
        if (m == null) {
            Builder options = new MongoClientOptions.Builder();
            options.connectionsPerHost(maxConnections);
            options.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockMultiplier);

            try {

                // Connect to replica servers if given. Else the standard way to one server.
                if (replicaServers != null && replicaServers.size() > 0) {
                    m = new MongoClient(replicaServers, options.build());
                } else {
                    ServerAddress address = new ServerAddress(host, port);
                    m = new MongoClient(address, options.build());
                }
                db = m.getDB(database);
                db.setWriteConcern(WriteConcern.SAFE);

                // Try to authenticate if configured.
View Full Code Here

      clearPassword();
    }
  }

  private Builder builder(MongoClientOptions options) {
    Builder builder = MongoClientOptions.builder();
    if (options != null) {
      builder.alwaysUseMBeans(options.isAlwaysUseMBeans());
      builder.connectionsPerHost(options.getConnectionsPerHost());
      builder.connectTimeout(options.getConnectTimeout());
      builder.cursorFinalizerEnabled(options.isCursorFinalizerEnabled());
      builder.dbDecoderFactory(options.getDbDecoderFactory());
      builder.dbEncoderFactory(options.getDbEncoderFactory());
      builder.description(options.getDescription());
      builder.maxWaitTime(options.getMaxWaitTime());
      builder.readPreference(options.getReadPreference());
      builder.socketFactory(options.getSocketFactory());
      builder.socketKeepAlive(options.isSocketKeepAlive());
      builder.socketTimeout(options.getSocketTimeout());
      builder.threadsAllowedToBlockForConnectionMultiplier(options
          .getThreadsAllowedToBlockForConnectionMultiplier());
      builder.writeConcern(options.getWriteConcern());
    }
    return builder;
  }
View Full Code Here

TOP

Related Classes of com.mongodb.MongoClientOptions.Builder

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.