Create a {@link MongoClientOptions} using the {@link MongoDBConfiguration}.

@return the {@link MongoClientOptions} corresponding to the {@link MongoDBConfiguration}
426940
public MongoClientOptions buildOptions() {
		MongoClientOptions.Builder optionsBuilder = MongoClientOptions.builder();

		optionsBuilder.writeConcern( writeConcern );
		optionsBuilder.readConcern( readConcern );
		optionsBuilder.readPreference( readPreference );

		Map<String, Method> settingsMap = createSettingsMap();
		for ( Map.Entry<String, Method> entry : settingsMap.entrySet() ) {
			String setting = MongoDBProperties.MONGO_DRIVER_SETTINGS_PREFIX + "." + entry.getKey();
			// we know that there is exactly one parameter
			Class<?> type = entry.getValue().getParameterTypes()[0];

			// for reflection purposes we need to deal with wrapper classes
			if ( int.class.equals( type ) ) {
				type = Integer.class;
			}
			if ( boolean.class.equals( type ) ) {
				type = Boolean.class;
			}

			Object property = propertyReader.property( setting, type ).withDefault( null ).getValue();
			if ( property == null ) {
				continue;
			}

			Method settingMethod = entry.getValue();
			try {
				settingMethod.invoke( optionsBuilder, property );
			}
			catch ( InvocationTargetException | IllegalAccessException e ) {
				throw log.unableToInvokeMethodViaReflection(
						settingMethod.getDeclaringClass().getName(),
						settingMethod.getName()
				);
			}
		}

		return optionsBuilder.build();
	}
807959
private Client getClient(){
        final ClientConfig cfg = new DefaultClientConfig();
        cfg.getClasses().add(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider.class);
        cfg.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, timeout);

        return Client.create(cfg);
    }
1137128
private function getMongoClient() {
        if ($this->mongoClient === null) {
            try {
                $this->mongoClient = new MongoClient($this->params['server'], $this->params['options']);
            } catch (MongoException $e) {
                throw new DatabaseException('Could not connect to database', 500, $e);
            }
        }

        return $this->mongoClient;
    }
1095402
@Bean(name = "JaversFromStarter")
    @ConditionalOnMissingBean
    public Javers javers() {
        logger.info("Starting javers-spring-boot-starter-mongo ...");

        MongoDatabase mongoDatabase = mongoClient.getDatabase( mongoProperties.getMongoClientDatabase() );

        logger.info("connecting to database: {}", mongoProperties.getMongoClientDatabase());

        MongoRepository javersRepository = createMongoRepository(javersMongoProperties, mongoDatabase);

        return JaversBuilder.javers()
                .registerJaversRepository(javersRepository)
                .withProperties(javersMongoProperties)
                .withObjectAccessHook(new DBRefUnproxyObjectAccessHook())
                .build();
    }
501562
function Storage(mongoURI, mongoOptions, storageOptions) {
  if (!(this instanceof Storage)) {
    return new Storage(mongoURI, mongoOptions, storageOptions);
  }

  assert(typeof mongoOptions === 'object', 'Invalid mongo options supplied');

  this._uri = mongoURI;
  this._options = mongoOptions;

  const defaultLogger = {
    info: console.log,
    debug: console.log,
    error: console.error,
    warn: console.warn
  };
  this._log = defaultLogger;
  if (storageOptions && storageOptions.logger) {
    this._log = storageOptions.logger;
  }

  // connect to the database
  this._connect();
}
334628
public ConnectionOptions withClientProperties(Map<String, Object> clientProperties) {
    factory.setClientProperties(Assert.notNull(clientProperties, "clientProperties"));
    return this;
  }
777108
@SneakyThrows
    public static ClientConfiguration buildClientConfiguration(final BaseAmazonWebServicesProperties props) {
        val cfg = new ClientConfiguration();
        cfg.setConnectionTimeout(props.getConnectionTimeout());
        cfg.setMaxConnections(props.getMaxConnections());
        cfg.setRequestTimeout(props.getRequestTimeout());
        cfg.setSocketTimeout(props.getSocketTimeout());
        cfg.setUseGzip(props.isUseGzip());
        cfg.setUseReaper(props.isUseReaper());
        cfg.setUseThrottleRetries(props.isUseThrottleRetries());
        cfg.setUseTcpKeepAlive(props.isUseTcpKeepAlive());
        cfg.setProtocol(Protocol.valueOf(props.getProtocol().toUpperCase()));
        cfg.setClientExecutionTimeout(props.getClientExecutionTimeout());
        if (props.getMaxErrorRetry() > 0) {
            cfg.setMaxErrorRetry(props.getMaxErrorRetry());
        }
        cfg.setProxyHost(props.getProxyHost());
        cfg.setProxyPassword(props.getProxyPassword());
        if (props.getProxyPort() > 0) {
            cfg.setProxyPort(props.getProxyPort());
        }
        cfg.setProxyUsername(props.getProxyUsername());
        cfg.setCacheResponseMetadata(props.isCacheResponseMetadata());

        if (StringUtils.isNotBlank(props.getLocalAddress())) {
            LOGGER.trace("Creating DynamoDb client local address [{}]", props.getLocalAddress());
            cfg.setLocalAddress(InetAddress.getByName(props.getLocalAddress()));
        }

        return cfg;
    }
469130
function initMongo(config, callback) {
  
  var self = this;
  
  // Set db
  self.db = new Db(config.database, new Server(config.host, config.port, {}), {safe: true});
  
  // Get client
  self.db.open(function(err, client) {
    if (err) throw err;
    else {
      self.client = client;
      client.collectionNames(function(err, names) {
        if (err) throw err;
        else {
          var name = config.database + '.' + config.collection;
          var exists = names.filter(function(col) {
            if (col.name == name) return col; 
          });
          
          // Collection options
          var opts = {capped: true, size: config.logSize};
          if (config.logLimit != null) opts.max = config.logLimit;
          
          if (exists.length === 0) {
            client.createCollection(config.collection, opts, function(err, collection) {
              if (err) throw err;
              else {
                self.collection = collection;
                callback.call(self);
              }
            });
          } else {
            // Get collection
            client.collection(config.collection, function(err, collection) {
              if (err) throw err;
              else {
                self.collection = collection;
                // Get collection options » Check if collection has already been capped
                collection.options(function(err, options) {
                  if (err) {
                    throw err;
                  } else {
                    // Check if collection's options match log requirements
                    var ready = (options.capped === true && options.size === opts.size);
                    if ('max' in opts) ready = (ready && options.max === opts.max);
                    if (!ready) {
                      // Convert collection to capped if it's not match log requirements
                      var cmd = {"convertToCapped": config.collection, size: opts.size};
                      if ('max' in opts) cmd.max = opts.max;
                      client.command(cmd, function(err) {
                        if (err) throw err;
                        else {
                          callback.call(self);
                        }
                      });
                    } else {
                      callback.call(self);
                    }
                  }
                });
              }
            });
          }
        }
      });
    }
  });
}
223318
@Override
    public CollectorItem createCollectorItemSelectOptions(CollectorItem item, Map<String, Object> allOptions, Map<String, Object> uniqueOptions) {
        Collector collector =  collectorRepository.findOne(item.getCollectorId());
        Map<String,Object> uniqueFieldsFromCollector = collector.getUniqueFields();
        List<CollectorItem> existing = customRepositoryQuery.findCollectorItemsBySubsetOptions(
                item.getCollectorId(), allOptions, uniqueOptions,uniqueFieldsFromCollector);

        if (!CollectionUtils.isEmpty(existing)) {
            CollectorItem existingItem = existing.get(0);
            existingItem.getOptions().putAll(item.getOptions());
            return collectorItemRepository.save(existingItem);
        }
        return collectorItemRepository.save(item);
    }
260983
protected synchronized MavenModelControllerClientConfiguration getClientConfiguration() {
        final Log log = getLog();
        String username = this.username;
        String password = this.password;
        if (username == null && password == null) {
            if (id != null) {
                if (settings != null) {
                    Server server = settings.getServer(id);
                    if (server != null) {
                        log.debug(DEBUG_MESSAGE_SETTINGS_HAS_ID);
                        password = decrypt(server);
                        username = server.getUsername();
                        if (username != null && password != null) {
                            log.debug(DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
                        } else {
                            log.debug(DEBUG_MESSAGE_NO_CREDS);
                        }
                    } else {
                        log.debug(DEBUG_MESSAGE_NO_SERVER_SECTION);
                    }
                } else {
                    log.debug(DEBUG_MESSAGE_NO_SETTINGS_FILE);
                }
            } else {
                log.debug(DEBUG_MESSAGE_NO_ID);
            }
        } else {
            log.debug(DEBUG_MESSAGE_POM_HAS_CREDS);
        }
        final ModelControllerClientConfiguration.Builder builder = new ModelControllerClientConfiguration.Builder()
                .setProtocol(protocol)
                .setHostName(hostname)
                .setPort(port)
                .setConnectionTimeout(timeout * 1000);
        if (authenticationConfig != null) {
            try {
                builder.setAuthenticationConfigUri(authenticationConfig.toURI());
            } catch (URISyntaxException e) {
                throw new RuntimeException("Failed to create URI from " + authenticationConfig, e);
            }
        }
        return new MavenModelControllerClientConfiguration(builder.build(), username, password);
    }
1168318
protected MongoClient buildMongoClient() {
        String connectionString = getConnectionString();
        if (StringUtils.isBlank(connectionString)) {
            throw new IllegalStateException("MongoDB ConnectionString is not defined.");
        }
        MongoClient mc = MongoClients.create(connectionString);
        return mc;
    }
1145105
public static MongoClient create(final PippoSettings settings) {
        String host = settings.getString(HOST, "mongodb://localhost:27017");
        return create(host);
    }
943550
public B options(ClientOptionValue<?>... options) {
        requireNonNull(options, "options");
        for (ClientOptionValue<?> o : options) {
            option(o);
        }
        return self();
    }
203712
public static ClusterClientOptions.Builder builder(ClientOptions clientOptions) {

        LettuceAssert.notNull(clientOptions, "ClientOptions must not be null");

        if (clientOptions instanceof ClusterClientOptions) {
            return ((ClusterClientOptions) clientOptions).mutate();
        }

        Builder builder = new Builder();
        builder.autoReconnect(clientOptions.isAutoReconnect()).bufferUsageRatio(clientOptions.getBufferUsageRatio())
                .cancelCommandsOnReconnectFailure(clientOptions.isCancelCommandsOnReconnectFailure())
                .disconnectedBehavior(clientOptions.getDisconnectedBehavior())
                .publishOnScheduler(clientOptions.isPublishOnScheduler())
                .pingBeforeActivateConnection(clientOptions.isPingBeforeActivateConnection())
                .requestQueueSize(clientOptions.getRequestQueueSize()).socketOptions(clientOptions.getSocketOptions())
                .sslOptions(clientOptions.getSslOptions())
                .suspendReconnectOnProtocolFailure(clientOptions.isSuspendReconnectOnProtocolFailure())
                .timeoutOptions(clientOptions.getTimeoutOptions());

        return builder;
    }
612664
public static RedissonClient create() {
        Config config = new Config();
        config.useSingleServer()
        .setTimeout(1000000)
        .setAddress("redis://127.0.0.1:6379");
//        config.useMasterSlaveConnection().setMasterAddress("127.0.0.1:6379").addSlaveAddress("127.0.0.1:6389").addSlaveAddress("127.0.0.1:6399");
//        config.useSentinelConnection().setMasterName("mymaster").addSentinelAddress("127.0.0.1:26389", "127.0.0.1:26379");
//        config.useClusterServers().addNodeAddress("127.0.0.1:7000");
        return create(config);
    }
235561
protected function createClientOptions(ConfigRepository $config): ClientOptions
    {
        $preview               = $config->get('contentful.preview');
        $defaultLocale         = $config->get('contentful.default_locale');
        $lowMemoryResourcePool = $config->get('contentful.low_memory_resource_pool');

        $clientOptions = new ClientOptions();

        if ($preview === true) {
            $clientOptions->usingPreviewApi();
        }

        if ($defaultLocale !== null) {
            $clientOptions->withDefaultLocale($defaultLocale);
        }

        if ($lowMemoryResourcePool === true) {
            $clientOptions->withLowMemoryResourcePool();
        }

        return $clientOptions;
    }
977817
private Map<String, List<MongoElement>> getMongoElements() throws Exception {
        for (MongoElement mongo : serverConfig.getMongos()) {
            addMongoElementToMap(mongo);
        }
        for (MongoDBElement mongoDB : serverConfig.getMongoDBs()) {
            if (mongoDB.getMongo() != null) {
                addMongoElementToMap(mongoDB.getMongo());
            }
        }
        return mongoElements;
    }