Examples of Mongo


Examples of com.mongodb.Mongo

        } else {
            int port = Integer.parseInt(String.valueOf(properties.get(PORT)));
            String db = String.valueOf(properties.get(DB));
            int cache = Integer.parseInt(String.valueOf(properties.get(CACHE)));

            mongo = new Mongo(host, port);
            store = new MongoStore(mongo.getDB(db), cache * MB);
        }

        delegate = new SegmentNodeStore(store);
    }
View Full Code Here

Examples of com.mongodb.Mongo

    public OakSegmentMKRepositoryStub(Properties settings) throws RepositoryException {
        super(settings);

        Session session = null;
        try {
            this.connection = new Mongo(HOST, PORT);
            Jcr jcr = new Jcr(new Oak(new SegmentNodeStore(
                    new MongoStore(connection.getDB(DB), 4 * 1024 * 1024))));
            this.repository = jcr.createRepository();

            session = getRepository().login(superuser);
View Full Code Here

Examples of com.mongodb.Mongo

        }));
    }

    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

Examples of com.mongodb.Mongo

            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

Examples of com.mongodb.Mongo

    @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

Examples of com.mongodb.Mongo

    @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

Examples of com.mongodb.Mongo

    @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

Examples of com.mongodb.Mongo

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

Examples of com.mongodb.Mongo

    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

Examples of com.mongodb.Mongo

                }
                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
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.