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

Examples of org.apache.jackrabbit.oak.plugins.document.DocumentMK$Builder


        ExecutorService executor = Executors.newFixedThreadPool(numberOfMks);
        List<DocumentMK> mks = new ArrayList<DocumentMK>();
        for (int i = 0; i < numberOfMks; i++) {
            String diff = buildPyramidDiff("/", 0, numberOfChildren,
                    numberOfNodes, prefixes[i], new StringBuilder()).toString();
            DocumentMK mk = new DocumentMK.Builder().open();
            mks.add(mk);
            GenericWriteTask task = new GenericWriteTask("mk-" + i, mk, diff, 10);
            executor.execute(task);
        }
        executor.shutdown();
        executor.awaitTermination(10, TimeUnit.MINUTES);
        for (DocumentMK mk : mks) {
            mk.dispose();
        }
    }
View Full Code Here


    }

    @Test
    public void addNodesConcurrent() throws Exception {
        for (int i = 0; i < NUM_CLUSTER_NODES; i++) {
            DocumentMK mk = new DocumentMK.Builder()
                    .setMongoDB(createConnection().getDB())
                    .setClusterId(i + 1).open();
            mks.add(mk);
        }
        Map<String, Exception> exceptions = Collections.synchronizedMap(
                new HashMap<String, Exception>());
        for (int i = 0; i < mks.size(); i++) {
            DocumentMK mk = mks.get(i);
            Repository repo = new Jcr(mk.getNodeStore()).createRepository();
            repos.add(repo);
            workers.add(new Thread(new Worker(repo, exceptions), "Worker-" + (i + 1)));
        }
        for (Thread t : workers) {
            t.start();
View Full Code Here

    }

    @Test
    public void addNodes() throws Exception {
        for (int i = 0; i < 2; i++) {
            DocumentMK mk = new DocumentMK.Builder()
                    .setMongoDB(createConnection().getDB())
                    .setAsyncDelay(0)
                    .setClusterId(i + 1).open();
            mks.add(mk);
        }
        final DocumentMK mk1 = mks.get(0);
        final DocumentMK mk2 = mks.get(1);
        Repository r1 = new Jcr(mk1.getNodeStore()).createRepository();
        repos.add(r1);
        Repository r2 = new Jcr(mk2.getNodeStore()).createRepository();
        repos.add(r2);

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));
View Full Code Here

    }

    @Test
    public void addNodes2() throws Exception {
        for (int i = 0; i < 3; i++) {
            DocumentMK mk = new DocumentMK.Builder()
                    .setMongoDB(createConnection().getDB())
                    .setAsyncDelay(0)
                    .setClusterId(i + 1).open();
            mks.add(mk);
        }
        final DocumentMK mk1 = mks.get(0);
        final DocumentMK mk2 = mks.get(1);
        final DocumentMK mk3 = mks.get(2);
        Repository r1 = new Jcr(mk1.getNodeStore()).createRepository();
        repos.add(r1);
        Repository r2 = new Jcr(mk2.getNodeStore()).createRepository();
        repos.add(r2);
        Repository r3 = new Jcr(mk3.getNodeStore()).createRepository();
        repos.add(r3);

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s3 = r3.login(new SimpleCredentials("admin", "admin".toCharArray()));
View Full Code Here

    }

    @Test
    public void rebaseVisibility() throws Exception {
        for (int i = 0; i < 2; i++) {
            DocumentMK mk = new DocumentMK.Builder()
                    .setMongoDB(createConnection().getDB())
                    .setAsyncDelay(0)
                    .setClusterId(i + 1).open();
            mks.add(mk);
        }
        final DocumentMK mk1 = mks.get(0);
        final DocumentMK mk2 = mks.get(1);
        Repository r1 = new Jcr(mk1.getNodeStore()).createRepository();
        repos.add(r1);
        Repository r2 = new Jcr(mk2.getNodeStore()).createRepository();
        repos.add(r2);

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));
View Full Code Here

        }
    }

    private static void initRepository() throws Exception {
        MongoConnection con = createConnection();
        DocumentMK mk = new DocumentMK.Builder()
                .setMongoDB(con.getDB())
                .setClusterId(1).open();
        Session session = new Jcr(mk.getNodeStore()).createRepository().login(
                new SimpleCredentials("admin", "admin".toCharArray()));
        session.logout();
        mk.dispose(); // closes connection as well
    }
View Full Code Here

    public void testConcurrentAdd() throws Exception {
        // create workers
        List<Callable<String>> cs = new LinkedList<Callable<String>>();
        for (int i = 0; i < NB_THREADS; i++) {
            // each callable has its own microkernel
            final DocumentMK mk = createMicroKernel();
            mks.add(mk);
            // diff for adding one node and one child node
            final List<String> stmts = new LinkedList<String>();
            stmts.add("+\"node" + i + "\":{}");
            stmts.add("+\"node" + i + "/child\":{}");
            // create callable
            Callable<String> c = new Callable<String>() {
                @Override
                public String call() throws Exception {
                    // commit all statements, one at a time
                    String r = null;
                    for (String stmt : stmts) {
                        r = mk.commit("/", stmt, null, "msg");
                    }
                    return r;
                }
            };
            cs.add(c);
View Full Code Here

        }
    }

    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();
        dispose(repository);
        mk.dispose(); // closes connection as well
    }
View Full Code Here

            "Adding a total of {} nodes evely spread across cluster. Loop: {}, Count: {}, Cluster nodes: {}",
            new Object[] { loop * count * clusters, loop, count, clusters });

        // creating instances
        for (int i = 1; i <= clusters; i++) {
            DocumentMK mk = new DocumentMK.Builder()
                    .setMongoDB(createConnection().getDB())
                    .setClusterId(i).open();
            mks.add(mk);
        }

        Map<String, Exception> exceptions = Collections.synchronizedMap(
            new HashMap<String, Exception>());

        // initialising repositories and creating workers
        for (int i = 0; i < mks.size(); i++) {
            DocumentMK mk = mks.get(i);
            Repository repo = new Jcr(mk.getNodeStore()).createRepository();
            Session session = repo.login(ADMIN);
            ensureIndex(session);
            session.logout();
            repos.add(repo);
            workers.add(new Thread(new Worker(repo, exceptions), "Worker-" + (i + 1)));
View Full Code Here

        Runtime.getRuntime().addShutdownHook(
                new Thread(new ShutdownHook(connection)));
    }

    protected Repository createRepository(MongoConnection connection) {
        DocumentMK m = new DocumentMK.Builder().setClusterId(1).
                memoryCacheSize(64 * 1024 * 1024).
                setMongoDB(connection.getDB()).open();
        Jcr jcr = new Jcr(m);
        return jcr.createRepository();
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.document.DocumentMK$Builder

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.