Package org.apache.jackrabbit.oak.plugins.document.util

Examples of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection


            con.close();
        }
    }

    private static void initRepository() throws Exception {
        MongoConnection con = createConnection();
        DocumentMK mk = new DocumentMK.Builder()
                .setMongoDB(con.getDB())
                .setClusterId(1).open();
        Repository repository = new Jcr(mk.getNodeStore()).createRepository();
        Session session = repository.login(ADMIN);
        ensureIndex(session);
        session.logout();
View Full Code Here


        }

        @Override
        public DocumentStore createDocumentStore() {
            try {
                MongoConnection connection = new MongoConnection(uri);
                DB db = connection.getDB();
                MongoUtils.dropCollections(db);
                return new MongoDocumentStore(db, new DocumentMK.Builder());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
View Full Code Here

        }

        @Override
        public boolean isAvailable() {
            try{
                MongoConnection connection = new MongoConnection(uri);
                connection.getDB().command(new BasicDBObject("ping", 1));
                return true;
            }catch(Exception e){
                return false;
            }
        }
View Full Code Here

        }

        @Override
        public void dispose() {
            try{
                MongoConnection connection = new MongoConnection(uri);
                connection.getDB().dropDatabase();
            } catch(Exception ignore) {
            }
        }
View Full Code Here

    private MongoConnection mongoConnection = null;

    private MongoConnection getMongoConnection() throws Exception {
        if (mongoConnection == null) {
            mongoConnection = new MongoConnection(HOST, PORT, DB);
        }
        return mongoConnection;
    }
View Full Code Here

        return mongoConnection;
    }

    @Override
    public boolean isAvailable() {
        MongoConnection connection = null;
        try {
            connection = new MongoConnection(HOST, PORT, DB);
            connection.getDB().command(new BasicDBObject("ping", 1));
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Override
    public void setUpCluster(MicroKernel[] cluster) throws Exception {
        MongoConnection connection = getMongoConnection();
        DB db = connection.getDB();
        dropCollections(db);

        for (int i = 0; i < cluster.length; i++) {
            cluster[i] = new DocumentMK.Builder().
                    setMongoDB(db).setClusterId(i).open();
View Full Code Here

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

        Session session = null;
        try {
            this.connection = new MongoConnection(HOST, PORT, DB);
            this.repository = createRepository(connection);

            session = getRepository().login(superuser);
            TestContentLoader loader = new TestContentLoader();
            loader.loadTestContent(session);
View Full Code Here

            }
        }
    }

    public static boolean isMongoDBAvailable() {
        MongoConnection connection = null;
        try {
            connection = createConnection(DB);
            return true;
        } catch (Exception e) {
            return false;
        } finally {
            if (connection != null) {
                connection.close();
            }
        }
    }
View Full Code Here

        }
    }

    static MongoConnection createConnection(String db) throws Exception {
        boolean success = false;
        MongoConnection con = new MongoConnection(HOST, PORT, db);
        try {
            con.getDB().command(new BasicDBObject("ping", 1));
            success = true;
        } finally {
            if (!success) {
                con.close();
            }
        }
        return con;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection

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.