Examples of MongoConnection


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

            @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

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

     */
    public static MongoConnection getConnection() {
        if (exception != null) {
            return null;
        }
        MongoConnection mongoConnection = null;
        try {
            mongoConnection = new MongoConnection(HOST, PORT, DB);
            mongoConnection.getDB().command(new BasicDBObject("ping", 1));
            // dropCollections(mongoConnection.getDB());
        } catch (Exception e) {
            exception = e;
            mongoConnection = null;
        }
View Full Code Here

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

    protected MongoMK mk;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        if (mongoAvailable == null) {
            MongoConnection mongoConnection = new MongoConnection(HOST, PORT, DB);
            try {
                mongoConnection.getDB().command(new BasicDBObject("ping", 1));
                mongoAvailable = Boolean.TRUE;
            } catch (Exception e) {
                mongoAvailable = Boolean.FALSE;
                mongoException = e;
            } finally {
                mongoConnection.close();
            }
        }
        Assume.assumeNoException(mongoException);
    }
View Full Code Here

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

        Assume.assumeNoException(mongoException);
    }

    @Before
    public void setUpConnection() throws Exception {
        mongoConnection = new MongoConnection(HOST, PORT, DB);
        dropCollections(mongoConnection.getDB());
        mk = new MongoMK.Builder().setMongoDB(mongoConnection.getDB()).open();
    }
View Full Code Here

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

    @After
    public void tearDownConnection() throws Exception {
        mk.dispose();
        // the db might already be closed
        mongoConnection.close();
        mongoConnection = new MongoConnection(HOST, PORT, DB);
        dropCollections(mongoConnection.getDB());
        mongoConnection.close();
    }
View Full Code Here

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

    private static MicroKernel mk2;
    private static MicroKernel mk3;

    @BeforeClass
    public static void createMongoConnections() throws Exception {
        mongoConnection2 = new MongoConnection(HOST, PORT, DB2);
        mongoConnection3 = new MongoConnection(HOST, PORT, DB);
    }
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);
            this.repository = createRepository(connection);

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

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

            }
        }
    }

    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

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

        }
    }

    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

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