Examples of MemoryDocumentStore


Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    protected Root root1;
    protected Root root2;

    @Before
    public void before() throws Exception {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();
        DocumentMK.Builder builder;

        builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(1);
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    // OAK-1254
    @Test
    public void backgroundRead() throws Exception {
        final Semaphore semaphore = new Semaphore(1);
        DocumentStore docStore = new MemoryDocumentStore();
        DocumentStore testStore = new TimingDocumentStoreWrapper(docStore) {
            @Override
            public void invalidateCache() {
                super.invalidateCache();
                semaphore.acquireUninterruptibly();
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    }

    @Test
    public void childNodeEntries() throws Exception {
        final AtomicInteger counter = new AtomicInteger();
        DocumentStore docStore = new MemoryDocumentStore() {
            @Nonnull
            @Override
            public <T extends Document> List<T> query(Collection<T> collection,
                                                      String fromKey,
                                                      String toKey,
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    @Test
    public void rollback() throws Exception {
        final Map<Thread, Semaphore> locks = Collections.synchronizedMap(
                new HashMap<Thread, Semaphore>());
        final Semaphore created = new Semaphore(0);
        DocumentStore docStore = new MemoryDocumentStore() {
            @Override
            public <T extends Document> boolean create(Collection<T> collection,
                                                       List<UpdateOp> updateOps) {
                Semaphore semaphore = locks.get(Thread.currentThread());
                boolean result = super.create(collection, updateOps);
                if (semaphore != null) {
                    created.release();
                    semaphore.acquireUninterruptibly();
                }
                return result;
            }
        };
        final List<Exception> exceptions = new ArrayList<Exception>();
        final DocumentMK mk = new DocumentMK.Builder()
                .setDocumentStore(docStore).setAsyncDelay(0).open();
        final DocumentNodeStore store = mk.getNodeStore();
        final String head = mk.commit("/", "+\"foo\":{}+\"bar\":{}", null, null);
        Thread writer = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Revision r = store.newRevision();
                    Commit c = new Commit(store, Revision.fromString(head), r);
                    c.addNode(new DocumentNodeState(store, "/foo/node", r));
                    c.addNode(new DocumentNodeState(store, "/bar/node", r));
                    c.apply();
                } catch (MicroKernelException e) {
                    exceptions.add(e);
                }
            }
        });
        final Semaphore s = new Semaphore(0);
        locks.put(writer, s);
        // will block in DocumentStore.create()
        writer.start();
        // wait for writer to create nodes
        created.acquireUninterruptibly();
        // commit will succeed and add collision marker to writer commit
        Revision r = store.newRevision();
        Commit c = new Commit(store, Revision.fromString(head), r);
        c.addNode(new DocumentNodeState(store, "/foo/node", r));
        c.addNode(new DocumentNodeState(store, "/bar/node", r));
        c.apply();
        // allow writer to continue
        s.release();
        writer.join();
        assertEquals("expected exception", 1, exceptions.size());

        String id = Utils.getIdFromPath("/foo/node");
        NodeDocument doc = docStore.find(Collection.NODES, id);
        assertNotNull("document with id " + id + " does not exist", doc);
        assertTrue(!doc.getLastRev().isEmpty());
        id = Utils.getIdFromPath("/bar/node");
        doc = docStore.find(Collection.NODES, id);
        assertNotNull("document with id " + id + " does not exist", doc);
        assertTrue(!doc.getLastRev().isEmpty());

        mk.dispose();
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    DocumentStore openDocumentStore() {
        if (MONGO_DB) {
            return new MongoDocumentStore(MongoUtils.getConnection().getDB(), new DocumentMK.Builder());
        }
        return new MemoryDocumentStore();
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    // OAK-1254
    @Test
    public void backgroundRead() throws Exception {
        final Semaphore semaphore = new Semaphore(1);
        DocumentStore docStore = new MemoryDocumentStore();
        DocumentStore testStore = new TimingDocumentStoreWrapper(docStore) {
            @Override
            public void invalidateCache() {
                super.invalidateCache();
                semaphore.acquireUninterruptibly();
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    }

    @Test
    public void childNodeEntries() throws Exception {
        final AtomicInteger counter = new AtomicInteger();
        DocumentStore docStore = new MemoryDocumentStore() {
            @Nonnull
            @Override
            public <T extends Document> List<T> query(Collection<T> collection,
                                                      String fromKey,
                                                      String toKey,
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    @Test
    public void rollback() throws Exception {
        final Map<Thread, Semaphore> locks = Collections.synchronizedMap(
                new HashMap<Thread, Semaphore>());
        final Semaphore created = new Semaphore(0);
        DocumentStore docStore = new MemoryDocumentStore() {
            @Override
            public <T extends Document> boolean create(Collection<T> collection,
                                                       List<UpdateOp> updateOps) {
                Semaphore semaphore = locks.get(Thread.currentThread());
                boolean result = super.create(collection, updateOps);
                if (semaphore != null) {
                    created.release();
                    semaphore.acquireUninterruptibly();
                }
                return result;
            }
        };
        final List<Exception> exceptions = new ArrayList<Exception>();
        final DocumentMK mk = new DocumentMK.Builder()
                .setDocumentStore(docStore).setAsyncDelay(0).open();
        final DocumentNodeStore store = mk.getNodeStore();
        final String head = mk.commit("/", "+\"foo\":{}+\"bar\":{}", null, null);
        Thread writer = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Revision r = store.newRevision();
                    Commit c = new Commit(store, Revision.fromString(head), r);
                    c.addNode(new DocumentNodeState(store, "/foo/node", r));
                    c.addNode(new DocumentNodeState(store, "/bar/node", r));
                    c.apply();
                } catch (MicroKernelException e) {
                    exceptions.add(e);
                }
            }
        });
        final Semaphore s = new Semaphore(0);
        locks.put(writer, s);
        // will block in DocumentStore.create()
        writer.start();
        // wait for writer to create nodes
        created.acquireUninterruptibly();
        // commit will succeed and add collision marker to writer commit
        Revision r = store.newRevision();
        Commit c = new Commit(store, Revision.fromString(head), r);
        c.addNode(new DocumentNodeState(store, "/foo/node", r));
        c.addNode(new DocumentNodeState(store, "/bar/node", r));
        c.apply();
        // allow writer to continue
        s.release();
        writer.join();
        assertEquals("expected exception", 1, exceptions.size());

        String id = Utils.getIdFromPath("/foo/node");
        NodeDocument doc = docStore.find(Collection.NODES, id);
        assertNotNull("document with id " + id + " does not exist", doc);
        assertTrue(!doc.getLastRev().isEmpty());
        id = Utils.getIdFromPath("/bar/node");
        doc = docStore.find(Collection.NODES, id);
        assertNotNull("document with id " + id + " does not exist", doc);
        assertTrue(!doc.getLastRev().isEmpty());

        mk.dispose();
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

    }

    // OAK-1662
    @Test
    public void getNewestRevision() throws Exception {
        DocumentStore docStore = new MemoryDocumentStore();
        DocumentNodeStore ns1 = new DocumentMK.Builder()
                .setDocumentStore(docStore).setAsyncDelay(0)
                .setClusterId(1).getNodeStore();
        ns1.getRoot();
        ns1.runBackgroundOperations();
View Full Code Here

Examples of org.apache.jackrabbit.oak.plugins.mongomk.MemoryDocumentStore

    protected Root root1;
    protected Root root2;

    @Before
    public void before() throws Exception {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();
        MongoMK.Builder builder;

        builder = new MongoMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(1);
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.