Package com.mongodb

Examples of com.mongodb.Mongo$Holder


    }


    public MongoDatastore(String url, int port, String dbName) throws UnknownHostException {
        DBAddress address = new DBAddress(url, port, dbName);
        mongo = new Mongo(address);
        db = mongo.getDB(dbName);
    }
View Full Code Here


    }

    public MongoDatastore(String username, String password, String url, int port, String dbName) throws UnknownHostException, MongoException {
        authenticate(username, password);
        if (auth) {
            mongo = new Mongo(url, port);
            db = mongo.getDB(dbName);
        }else{
            throw new MongoException("Access Denied for the given credentials");
        }
    }
View Full Code Here

    dbName = getOptionalStringConfig("db_name", "default_db");
    username = getOptionalStringConfig("username", null);
    password = getOptionalStringConfig("password", null);

    try {
      mongo = new Mongo(host, port);
      db = mongo.getDB(dbName);
      if (username != null && password != null) {
        db.authenticate(username, password.toCharArray());
      }
      eb.registerHandler(address, this);
View Full Code Here

            }
           
            List<ServerAddress> addresses = getServerAddresses(hostname, port);
            if (addresses.size() < 2)
            {
                mongo = new Mongo(addresses.get(0));
            }
            else
            {
                // Replication set
                mongo = new Mongo(addresses);
            }
            DB database = mongo.getDB(databaseName);
           
            if (userName != null && userName.trim().length() > 0)
            {
View Full Code Here

    {
        String hostname = TEST_MONGO_SERVER_HOSTNAME;
        PropertyConfigurator.configure(getDefaultPortProperties(hostname));
       
        MongoDbAppender appender = (MongoDbAppender) Logger.getRootLogger().getAppender(MONGODB_APPENDER_NAME);
        Mongo mongo = (Mongo) p.getField(appender, "mongo");
        assertTrue(mongo.getAddress() != null);
        assertTrue(TEST_MONGO_SERVER_HOSTNAME.equals(mongo.getAddress().getHost()));
        assertTrue(TEST_MONGO_SERVER_PORT == mongo.getAddress().getPort());
       
        appender.close();
    }
View Full Code Here

        int portNum = Integer.parseInt(port);
        PropertyConfigurator.configure(getNonDefaultPortProperties(hostname, port));
       
        MongoDbAppender appender = (MongoDbAppender) Logger.getRootLogger().getAppender(MONGODB_APPENDER_NAME);

        Mongo mongo = (Mongo) p.getField(appender, "mongo");
        assertTrue(mongo.getAddress() != null);
        assertTrue(TEST_MONGO_SERVER_HOSTNAME.equals(mongo.getAddress().getHost()));
        assertTrue(portNum == mongo.getAddress().getPort());
       
        appender.close();
    }
View Full Code Here

        List<String>ports = Arrays.asList("27017", "27018");
        PropertyConfigurator.configure(getNonDefaultPortProperties(hostname, port));
       
        MongoDbAppender appender = (MongoDbAppender) Logger.getRootLogger().getAppender(MONGODB_APPENDER_NAME);

        Mongo mongo = (Mongo) p.getField(appender, "mongo");
        assertTrue(mongo.getAddress() != null)// Should return the master
        List<ServerAddress> addresses = mongo.getAllAddress();
        assertTrue(addresses != null);
        for (ServerAddress address : addresses)
        {
            boolean found = false;
            int i = 0;
View Full Code Here

    private final Mongo mongo;
    private DBCollection collection;

    public TestMongoDbPatternLayout() throws Exception
    {
        mongo = new Mongo(TEST_MONGO_SERVER_HOSTNAME, TEST_MONGO_SERVER_PORT);
    }
View Full Code Here

    }

    @BeforeClass
    public static void setUpBeforeClass() throws Exception
    {
        Mongo mongo = new Mongo(TEST_MONGO_SERVER_HOSTNAME,
                TEST_MONGO_SERVER_PORT);
        mongo.dropDatabase(TEST_DATABASE_NAME);
    }
View Full Code Here

    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception
    {
        Mongo mongo = new Mongo(TEST_MONGO_SERVER_HOSTNAME,
                TEST_MONGO_SERVER_PORT);
        mongo.dropDatabase(TEST_DATABASE_NAME);
    }
View Full Code Here

TOP

Related Classes of com.mongodb.Mongo$Holder

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.