Package com.mongodb

Examples of com.mongodb.MongoClientOptions$Builder


  @Override
  public void start() {
    if ( !isCacheStarted ) {
      try {
        ServerAddress serverAddress = new ServerAddress( config.getHost(), config.getPort() );
        MongoClientOptions clientOptions = config.buildOptions();

        log.connectingToMongo( config.getHost(), config.getPort(), clientOptions.getConnectTimeout() );

        this.mongo = new MongoClient( serverAddress, clientOptions );
        this.isCacheStarted = true;
      }
      catch ( UnknownHostException e ) {
View Full Code Here


     
    }
   
    private MongoClient createClient(final String databaseUri,
        final int port) throws UnknownHostException {
      final MongoClientOptions options = MongoClientOptions.builder()
          .connectionsPerHost(100)
          .threadsAllowedToBlockForConnectionMultiplier(1500).build();
      final MongoClient client = new MongoClient(new ServerAddress(
          databaseUri, port), options);
      return client;
View Full Code Here

                        String dbName = config.get("db", "keycloak");

                        String user = config.get("user");
                        String password = config.get("password");

                        MongoClientOptions clientOptions = getClientOptions();
                        if (user != null && password != null) {
                            MongoCredential credential = MongoCredential.createMongoCRCredential(user, dbName, password.toCharArray());
                            client = new MongoClient(new ServerAddress(host, port), Collections.singletonList(credential), clientOptions);
                        } else {
                            client = new MongoClient(new ServerAddress(host, port), clientOptions);
View Full Code Here

            logger.debug("Server #" + i + ": {}", member.address);
            builder.add(member);
        }
        ImmutableList<MongoReplicaSet.Member> members = builder.build();
        Thread.sleep(2000);
        MongoClientOptions mco = MongoClientOptions.builder().autoConnectRetry(true).connectTimeout(15000).socketTimeout(60000).build();
        Mongo mongo = new MongoClient(new ServerAddress(Network.getLocalHost().getHostName(), ports[0]), mco);
        DB mongoAdminDB = mongo.getDB(ADMIN_DATABASE_NAME);

        cr = mongoAdminDB.command(new BasicDBObject("isMaster", 1));
        logger.debug("isMaster: " + cr);
View Full Code Here

                mongoCredentials.add(MongoCredential.createMongoCRCredential(
                        definition.getMongoAdminUser(),
                        !Strings.isNullOrEmpty(definition.getMongoAdminAuthDatabase()) ? definition.getMongoAdminAuthDatabase() : MongoDBRiver.MONGODB_ADMIN_DATABASE,
                        definition.getMongoAdminPassword().toCharArray()));
            }
            MongoClientOptions mongoClientOptions = definition.getMongoClientOptions();
            ClientCacheKey cacheKey = new ClientCacheKey(servers, mongoCredentials, mongoClientOptions);

            MongoClient mongoClient = mongoClients.get(cacheKey);
            if (mongoClient != null) {
                return mongoClient;
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.