Package org.apache.jackrabbit.mk.api

Examples of org.apache.jackrabbit.mk.api.MicroKernel


    private NodeStore store;

    @Before
    public void setUp() throws Exception {
        MicroKernel microKernel = new MicroKernelImpl();
        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{} " +
                "+\"oak:index\":{\"solrIdx\":{\"coreName\":\"cn\", \"solrHome\":\"sh\", \"solrConfig\":\"sc\"}} ";
        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
        store = new KernelNodeStore(microKernel);
    }
View Full Code Here


    @Test
    @Ignore("OAK-532"// FIXME OAK-532
    public void journalConsistency() throws Exception {
        while (true) {
            final MicroKernel mk1 = new MicroKernelImpl();
            final String rev = mk1.commit("", "+\"/a\":{}", null, null);

            Thread t1 = new Thread("t1") {
                @Override
                public void run() {
                    try {
                        String r2 = mk1.commit("", "-\"/a\"+\"/c\":{}", rev, null);
                    }
                    catch (MicroKernelException ignore) { }
                }
            };
            Thread t2 = new Thread("t2") {
                @Override
                public void run() {
                    try {
                        String r2 = mk1.commit("", "-\"/a\"+\"/b\":{}", rev, null);
                    }
                    catch (MicroKernelException ignore) { }
                }
            };

            t1.start();
            t2.start();

            t1.join();
            t2.join();

            String journal = mk1.getJournal(rev, null, null);
            int c = count("-\\\"/a\\", journal);
            assertEquals("Inconsistent journal :" + journal, 1, c);
        }
    }
View Full Code Here

    protected EditorHook hook;
    private ContentRepository repository;

    @Before
    public void setUp() throws Exception {
        MicroKernel microKernel = new MicroKernelImpl();
        store = new KernelNodeStore(microKernel);
        provider = new TestUtils();
        server = provider.getSolrServer();
        configuration = provider.getConfiguration();
        hook = new EditorHook(new IndexUpdateProvider(
View Full Code Here

        return true;
    }

    @Override
    public void setUpCluster(MicroKernel[] cluster) {
        MicroKernel mk = new MicroKernelImpl();
        for (int i = 0; i < cluster.length; i++) {
            cluster[i] = mk;
        }
    }
View Full Code Here

    }

    @Override
    public void setUpCluster(MicroKernel[] cluster) {
        NodeStore store = new SegmentNodeStore(new MemoryStore());
        MicroKernel mk = new NodeStoreKernel(store);
        for (int i = 0; i < cluster.length; i++) {
            cluster[i] = mk;
        }
    }
View Full Code Here

    private NodeStore store;

    @Before
    public void setUp() throws Exception {
        MicroKernel microKernel = new MicroKernelImpl();
        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{} " +
                "+\"oak:index\":{\"solrIdx\":{\"coreName\":\"cn\", \"solrHomePath\":\"sh\", \"solrConfigPath\":\"sc\"}} ";
        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
        store = new KernelNodeStore(microKernel);
    }
View Full Code Here

    private NodeStore store;

    @Before
    public void setUp() throws Exception {
        MicroKernel microKernel = new MicroKernelImpl();
        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{} " +
                "+\"oak:index\":{\"solrIdx\":{\"coreName\":\"cn\", \"solrHomePath\":\"sh\", \"solrConfigPath\":\"sc\"}} ";
        microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
        store = new KernelNodeStore(microKernel);
    }
View Full Code Here

    @Test
    @Ignore("OAK-532"// FIXME OAK-532
    public void journalConsistency() throws Exception {
        while (true) {
            final MicroKernel mk1 = new MicroKernelImpl();
            final String rev = mk1.commit("", "+\"/a\":{}", null, null);

            Thread t1 = new Thread("t1") {
                @Override
                public void run() {
                    try {
                        String r2 = mk1.commit("", "-\"/a\"+\"/c\":{}", rev, null);
                    }
                    catch (MicroKernelException ignore) { }
                }
            };
            Thread t2 = new Thread("t2") {
                @Override
                public void run() {
                    try {
                        String r2 = mk1.commit("", "-\"/a\"+\"/b\":{}", rev, null);
                    }
                    catch (MicroKernelException ignore) { }
                }
            };

            t1.start();
            t2.start();

            t1.join();
            t2.join();

            String journal = mk1.getJournal(rev, null, null);
            int c = count("-\\\"/a\\", journal);
            assertEquals(1, c);
        }
    }
View Full Code Here

        assertTrue(after - before < 10);
    }

    private ScheduledFuture<String> scheduleCommit(long delay, final String revisionId) {
        ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
        final MicroKernel mk = this.mk;
        ScheduledFuture<String> future = executorService.schedule(new Callable<String>(){
            @Override
            public String call() throws Exception {
                return mk.commit("/", "+\"b\" : {}", revisionId, null);
            }
        }, delay, TimeUnit.MILLISECONDS);
        executorService.shutdown();
        return future;
    }
View Full Code Here

            if (head.equals(base)) {
                // Nothing was written to this branch: return base state
                head = null// Mark as merged
                return base;
            } else {
                MicroKernel kernel = store.getKernel();
                String newRevision;
                JsopDiff diff = new JsopDiff(kernel);
                if (headRevision == null) {
                    // no branch created yet, commit directly
                    head.compareAgainstBaseState(base, diff);
                    newRevision = kernel.commit("", diff.toString(), baseRevision, null);
                } else {
                    // commit into branch and merge
                    head.compareAgainstBaseState(store.getRootState(headRevision), diff);
                    String jsop = diff.toString();
                    if (!jsop.isEmpty()) {
                        headRevision = kernel.commit("", jsop, headRevision, null);
                    }
                    newRevision = kernel.merge(headRevision, null);
                    headRevision = null;
                }
                head = null// Mark as merged
                return store.getRootState(newRevision);
            }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.api.MicroKernel

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.