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

Examples of org.apache.jackrabbit.oak.plugins.document.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


        }

        @Override
        public DocumentStore createDocumentStore(int clusterId) {
            try {
                MongoConnection connection = new MongoConnection(uri);
                DB db = connection.getDB();
                MongoUtils.dropCollections(db);
                return new MongoDocumentStore(db, new DocumentMK.Builder().setClusterId(clusterId));
            } 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

        return OakMongoMKRepositoryStub.createConnection(
                ConcurrentAddNodesClusterIT.class.getSimpleName());
    }

    private static void dropDB() throws Exception {
        MongoConnection con = createConnection();
        try {
            con.getDB().dropDatabase();
        } finally {
            con.close();
        }
    }
View Full Code Here

            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(
                new SimpleCredentials("admin", "admin".toCharArray()));
        session.logout();
View Full Code Here

   
    private static NodeStoreFixture getMongo() {
        return new NodeStoreFixture() {
            @Override
            public NodeStore createNodeStore() {
                MongoConnection connection;
                try {
                    connection = new MongoConnection("mongodb://localhost:27017/oak");
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                DB mongoDB = connection.getDB();               
                return new DocumentMK.Builder().
                            memoryCacheSize(0).
                            setMongoDB(mongoDB, 1, 16).
                            getNodeStore();
            }
View Full Code Here

            MongoClientURI uri = new MongoClientURI(nonOptions.get(0));
            if (uri.getDatabase() == null) {
                System.err.println("Database missing in MongoDB URI: " + uri.getURI());
                System.exit(1);
            }
            MongoConnection mongo = new MongoConnection(uri.getURI());
            DocumentNodeStore store = new DocumentMK.Builder().
                    setMongoDB(mongo.getDB()).
                    setClusterId(clusterId.value(options)).getNodeStore();
            fixture = new MongoFixture(store);
        } else {
            fixture = new SegmentFixture(new FileStore(
                    new File(nonOptions.get(0)), 256));
View Full Code Here

        public DocumentFixture() {
            this(DEFAULT_URI, false, null);
        }

        private static NodeStore createNodeStore(String uri, BlobStore blobStore) {
            MongoConnection connection;
            try {
                connection = new MongoConnection(uri);
                DB mongoDB = connection.getDB();
                DocumentMK.Builder builder = new DocumentMK.Builder();
                if(blobStore != null){
                    builder.setBlobStore(blobStore);
                }
                builder.setMongoDB(mongoDB);
View Full Code Here

    @Before
    public void prepareStores() throws Exception {
        clock = new Clock.Virtual();
        replicationLag = TimeUnit.SECONDS.toMillis(10);
        MongoConnection mc = MongoUtils.getConnection();
        documentNodeStore = new DocumentMK.Builder()
                .setMaxReplicationLag(replicationLag, TimeUnit.MILLISECONDS)
                .setMongoDB(mc.getDB())
                .setClusterId(1)
                .getNodeStore();
        mongoDS = (MongoDocumentStore) documentNodeStore.getDocumentStore();
        nodeStore = documentNodeStore;
    }
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.