Package com.mongodb

Examples of com.mongodb.Mongo$CursorCleanerThread


        }));
    }

    public static boolean isAvailable() {
        try {
            Mongo mongo = new Mongo(HOST, PORT);
            try {
                mongo.getDatabaseNames();
                return true;
            } finally {
                mongo.close();
            }
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here


            private Mongo mongo;
            @Override
            public Repository[] setUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                stores = new SegmentStore[cluster.length];
                mongo = new Mongo(host, port);
                for (int i = 0; i < cluster.length; i++) {
                    stores[i] = new MongoStore(mongo.getDB(unique), cacheSize);
                    Oak oak = new Oak(new SegmentNodeStore(stores[i]));
                    cluster[i] = new Jcr(oak).createRepository();
                }
View Full Code Here

    @Override
    public void open() {
        try {
            if (mongo == null) {
                mongo = new Mongo(host, port);
                db = mongo.getDB(dbName);
                db.setWriteConcern(com.mongodb.WriteConcern.SAFE);
                LOG.info("opened database (" + dbName + "): " + mongo);
            } else {
                LOG.info(" using opened database " + db);
View Full Code Here

    @Before
    public void setupMongo() throws Exception {

        try {
            final Mongo m = new Mongo();
            m.dropDatabase("testdb");
            testDb = m.getDB("testdb");
        } catch (final Exception e) {
            assumeThat(true, is(false)); // ignore if no MongoDB instance to
                                         // connect to
            return;
        }
View Full Code Here

    @Before
    public void setup() throws Exception {
        org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);

        final Mongo m = new Mongo();
        try {
            m.dropDatabase("mydb");
        } catch (final Exception e) {
            assumeThat(true, is(false));// ie ignore test because we've had an
                                        // exception
            return;
        }

        testDb = m.getDB("mydb");

        final BasicDBObject object = new BasicDBObject();
//        object.put("_id", "1023");
//        object.put("_type", "org.xxx.Class");
        object.put("_oid", OBJECT_TYPE + ":1023");
View Full Code Here

public class DemoMongo {
   
    // @Test
    public void installed() throws Exception {

        final Mongo m = new Mongo();

        for (final String s : m.getDatabaseNames()) {
            System.out.println(s);
        }

        /*
         * Mongo m = new Mongo( "localhost" ); Mongo m = new Mongo( "localhost"
         * , 27017 );
         */
        m.dropDatabase("mydb");

        System.out.println("\n...");
        for (final String s : m.getDatabaseNames()) {
            System.out.println(s);
        }

        final DB db = m.getDB("mydb");
        /*
         * DBCollection coll = db.getCollection("testCollection1"); coll =
         * db.getCollection("testCollection2");
         */

 
View Full Code Here

    public void setup() throws Exception {
        org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);

        try {

            final Mongo m = new Mongo();
            m.dropDatabase("mydb");
            testDb = m.getDB("mydb");
        } catch (final Exception e) {
            assumeThat(true, is(false)); // ie no exceptions
            return;
        }
View Full Code Here

                }
                if (connectionSpec.getHosts().isEmpty()) {
                    ServerAddress server = new ServerAddress("localhost", ServerAddress.defaultPort());
                    servers.add(server);                   
                }
                Mongo mongo = this.mongo;
                if (mongo == null) {
                    isExternal = false;
                    if (servers.isEmpty()) {
                        mongo = new Mongo();
                    } else {
                        mongo = new Mongo(servers);
                    }
                }
                db = mongo.getDB(connectionSpec.getDB());
                if ((connectionSpec.getUser() != null) && (connectionSpec.getUser().length() > 0)) {
                    if (!db.authenticate(connectionSpec.getUser(), connectionSpec.getPassword())) {
                        throw new ResourceException("authenticate failed for user: " + connectionSpec.getUser());
                    }
                }
View Full Code Here

    public static UpdateableDataContext createMongoDbDataContext(String hostname, Integer port, String databaseName,
            String username, char[] password, SimpleTableDef[] tableDefs) {
        try {
            DB mongoDb;
            if (port == null) {
                mongoDb = new Mongo(hostname).getDB(databaseName);
            } else {
                mongoDb = new Mongo(hostname, port).getDB(databaseName);
            }
            if (username != null) {
                mongoDb.authenticate(username, password);
            }
View Full Code Here

    protected Datastore ds;

    @BeforeClass
    public void initDB() throws Exception {
        connection = new Mongo("127.0.0.1");

        morphia = new Morphia().map(MongoDBChangeSet.class).map(MongoDBChangeSetEntry.class).map(MongoDBFile.class);

        ds = morphia.createDatastore(connection, "rhqtest");
    }
View Full Code Here

TOP

Related Classes of com.mongodb.Mongo$CursorCleanerThread

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.