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

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


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

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

            @Override
            public Repository[] setUpCluster(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() {
                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

            @Override
            public Repository[] setUpCluster(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() {
                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

        rev1 = mk.commit("/", "+\"foo\":{}", null, null);

        // start a new MongoMK instance. this instance sees /foo
        // because it started after the commit on the first MongoMK
        MongoMK mk2 = new MongoMK.Builder().setAsyncDelay(0)
                .setMongoDB(new MongoConnection(HOST, PORT, DB).getDB()).open();

        try {
            // this creates a first commit from the second MongoMK instance
            // the first MongoMK instance does not see this yet
            mk2.commit("/", "+\"bar\":{}+\"bla\":{}", null, null);
View Full Code Here

            ns.runBackgroundOperations();
        }
    }

    private MongoNodeStore createNS(int clusterId) throws Exception {
        MongoConnection mc = new MongoConnection(HOST, PORT, DB);
        return new MongoMK.Builder()
                          .setMongoDB(mc.getDB())
                          .setClusterId(clusterId)
                          .setAsyncDelay(0) //Set delay to 0 so that effect of changes are immediately reflected
                          .getNodeStore();
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.mongomk.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.