Examples of MongoClient


Examples of com.massivecraft.mcore.xlib.mongodb.MongoClient

    private static Mongo _mongo = null;

    private static Mongo getMongo()
        throws Exception {
        if ( _mongo == null )
            _mongo = new MongoClient( host );
        return _mongo;
    }
View Full Code Here

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

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

Examples of com.mongodb.MongoClient

      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

Examples of com.mongodb.MongoClient

        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

Examples of com.mongodb.MongoClient

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

Examples of com.mongodb.MongoClient

      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

Examples of com.mongodb.MongoClient

            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

Examples of com.mongodb.MongoClient

* @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

Examples of com.mongodb.MongoClient

        }
    }

    @Bean
    public MongoClient myDb() throws UnknownHostException {
        return new MongoClient("0.0.0.0", PORT);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.