Examples of MongoConnection


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

            @Override
            protected Repository[] internalSetUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                kernels = new MongoMK[cluster.length];
                for (int i = 0; i < cluster.length; i++) {
                    MongoConnection mongo =
                            new MongoConnection(host, port, dbName);
                    kernels[i] = new MongoMK.Builder().
                            setMongoDB(mongo.getDB()).
                            setClusterId(i).setLogging(false).open();
                    Oak oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
            }
            @Override
            public void tearDownCluster() {
                super.tearDownCluster();
                for (MongoMK kernel : kernels) {
                    kernel.dispose();
                }
                if (dropDBAfterTest) {
                    try {
                        MongoConnection mongo =
                                new MongoConnection(host, port, dbName);
                        mongo.getDB().dropDatabase();
                        mongo.close();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }
View Full Code Here

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

            @Override
            protected Repository[] internalSetUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                stores = new MongoNodeStore[cluster.length];
                for (int i = 0; i < cluster.length; i++) {
                    MongoConnection mongo =
                            new MongoConnection(host, port, dbName);
                    stores[i] = new MongoMK.Builder().
                            setMongoDB(mongo.getDB()).
                            memoryCacheSize(cacheSize).
                            setClusterId(i).setLogging(false).getNodeStore();
                    Oak oak = new Oak(stores[i]);
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
            }
            @Override
            public void tearDownCluster() {
                super.tearDownCluster();
                for (MongoNodeStore store : stores) {
                    store.dispose();
                }
                if (dropDBAfterTest) {
                    try {
                        MongoConnection mongo =
                                new MongoConnection(host, port, dbName);
                        mongo.getDB().dropDatabase();
                        mongo.close();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }
View Full Code Here

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

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

        Session session = null;
        try {
            this.connection = new MongoConnection(HOST, PORT, DB);
            MongoMK m = new MongoMK.Builder().setClusterId(1).
                    memoryCacheSize(64 * 1024 * 1024).
                    setMongoDB(connection.getDB()).open();
            Jcr jcr = new Jcr(m);
            this.repository = jcr.createRepository();
View Full Code Here

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

            }
        }
    }

    public static boolean isMongoDBAvailable() {
        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

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

            this.reference = new WeakReference<MongoConnection>(connection);
        }

        @Override
        public void run() {
            MongoConnection connection = reference.get();
            if (connection != null) {
                connection.close();
            }
        }
View Full Code Here

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

    private static final int NB_THREADS = 16;

    private List<MongoConnection> connections = new ArrayList<MongoConnection>();

    private MicroKernel createMicroKernel() throws Exception {
        MongoConnection connection = new MongoConnection(HOST,
                PORT, DB);
        connections.add(connection);
        DB mongoDB = connection.getDB();
        return new MongoMK.Builder().setMongoDB(mongoDB).open();
    }
View Full Code Here

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

        int cacheSize = PropertiesUtil.toInteger(config.get(PROP_CACHE), DEFAULT_CACHE);

        logger.info("Starting MongoDB MicroKernel with host={}, port={}, db={}",
                new Object[] {host, port, db});

        MongoConnection connection = new MongoConnection(host, port, db);
        DB mongoDB = connection.getDB();

        logger.info("Connected to database {}", mongoDB);

        mk = new MongoMK.Builder()
                        .memoryCacheSize(cacheSize * MB)
 
View Full Code Here

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

    private MongoConnection mongoConnection = null;

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

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

        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

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

        }
    }

    @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 MongoMK.Builder().
                    setMongoDB(db).setClusterId(i).open();
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.