Package com.mongodb

Examples of com.mongodb.MongoClient


        properties.getProperty("mysql.password"));
    final DataSource postgresql = Helper.newDataSource(
        properties.getProperty("postgresql.uri"),
        properties.getProperty("postgresql.user"),
        properties.getProperty("postgresql.password"));
    final DB mongodb = new MongoClient(properties.getProperty("mongodb.host"))
        .getDB(properties.getProperty("mongodb.name"));
    //
    // The world cache is primed at startup with all values.  It doesn't
    // matter which database backs it; they all contain the same information
    // and the CacheLoader.load implementation below is never invoked.
View Full Code Here


        properties.getProperty("mysql.password"));
    final DataSource postgresql = Helper.newDataSource(
        properties.getProperty("postgresql.uri"),
        properties.getProperty("postgresql.user"),
        properties.getProperty("postgresql.password"));
    final DB mongodb = new MongoClient(properties.getProperty("mongodb.host"))
        .getDB(properties.getProperty("mongodb.name"));
    //
    // The world cache is primed at startup with all values.  It doesn't
    // matter which database backs it; they all contain the same information
    // and the CacheLoader.load implementation below is never invoked.
View Full Code Here

      for ( Entry<String, DBCollection> collection : collections.entrySet() ) {
        when( database.getCollection( collection.getKey() ) ).thenReturn( collection.getValue() );
      }

      MongoClient mongoClient = mock( MongoClient.class );
      when( mongoClient.getDatabaseNames() ).thenReturn( Collections.<String>emptyList() );
      when( mongoClient.getDB( anyString() ) ).thenReturn( database );

      return new MockMongoClient( collections, defaultCollection, mongoClient );
    }
View Full Code Here

        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 );
      }
      catch ( UnknownHostException e ) {
        throw log.mongoOnUnknownHost( config.getHost() );
      }
      catch ( RuntimeException e ) {
View Full Code Here

    MongoClientURI mongoUri = new MongoClientURI(uri);
    dbName = mongoUri.getDatabase();
    try
        {
          client = new MongoClient(mongoUri);
        }
        catch (UnknownHostException e)
        {
          throw new ConfigurationException(e);
        }
View Full Code Here

      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

            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

* @author Oleg Zhurakousky
*/
public class DemoUtils {

  public static MongoDbFactory prepareMongoFactory(String... additionalCollectionToDrop) throws Exception{
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoTemplate template = new MongoTemplate(mongoDbFactory);
    template.dropCollection("messages");
    template.dropCollection("data");
    for (String additionalCollection : additionalCollectionToDrop) {
      template.dropCollection(additionalCollection);
View Full Code Here

        }
    }

    @Bean
    public MongoClient myDb() throws UnknownHostException {
        return new MongoClient("0.0.0.0", PORT);
    }
View Full Code Here

            logger.info("Starting MongoDB {} with host={}, db={}",
                    new Object[] {type,mongoURI.getHosts(), db});
            logger.info("Mongo Connection details {}",MongoConnection.toString(mongoURI.getOptions()));
        }

        MongoClient client = new MongoClient(mongoURI);
        DB mongoDB = client.getDB(db);

        mk = new MongoMK.Builder()
                .memoryCacheSize(cacheSize * MB)
                .setMongoDB(mongoDB)
                .open();
View Full Code Here

TOP

Related Classes of com.mongodb.MongoClient

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.