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

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


    @Test
    public void modifiedReset() throws Exception {
        Clock clock = new Clock.Virtual();
        clock.waitUntil(System.currentTimeMillis());
        Revision.setClock(clock);
        MemoryDocumentStore docStore = new MemoryDocumentStore();
        DocumentNodeStore ns1 = new DocumentMK.Builder()
                .setDocumentStore(docStore).setClusterId(1)
                .setAsyncDelay(0).clock(clock).getNodeStore();
        NodeBuilder builder1 = ns1.getRoot().builder();
        builder1.child("node");
        ns1.merge(builder1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        ns1.runBackgroundOperations();

        DocumentNodeStore ns2 = new DocumentMK.Builder()
                .setDocumentStore(docStore).setClusterId(2)
                .setAsyncDelay(0).clock(clock).getNodeStore();

        NodeBuilder builder2 = ns2.getRoot().builder();
        builder2.child("node").child("child-2");
        ns2.merge(builder2, EmptyHook.INSTANCE, CommitInfo.EMPTY);

        // wait at least _modified resolution. in reality the wait may
        // not be necessary. e.g. when the clock passes the resolution boundary
        // exactly at this time
        clock.waitUntil(System.currentTimeMillis() +
                SECONDS.toMillis(MODIFIED_IN_SECS_RESOLUTION + 1));

        builder1 = ns1.getRoot().builder();
        builder1.child("node").child("child-1");
        ns1.merge(builder1, EmptyHook.INSTANCE, CommitInfo.EMPTY);

        ns1.runBackgroundOperations();

        // get current _modified timestamp on /node
        NodeDocument doc = docStore.find(NODES, Utils.getIdFromPath("/node"));
        Long mod1 = (Long) doc.get(MODIFIED_IN_SECS);
        assertNotNull(mod1);

        ns2.runBackgroundOperations();

        doc = docStore.find(NODES, Utils.getIdFromPath("/node"));
        Long mod2 = (Long) doc.get(MODIFIED_IN_SECS);
        assertTrue("" + mod2 + " < " + mod1, mod2 >= mod1);

        ns1.dispose();
        ns2.dispose();
View Full Code Here


            return this;
        }

        public DocumentStore getDocumentStore() {
            if (documentStore == null) {
                documentStore = new MemoryDocumentStore();
            }
            return documentStore;
        }
View Full Code Here

    private int c2Id;
    private MemoryDocumentStore sharedStore;

    @Before
    public void setUp(){
        sharedStore = new MemoryDocumentStore();
        ds1 = new DocumentMK.Builder()
                .setAsyncDelay(0)
                .setDocumentStore(sharedStore)
                .getNodeStore();
        c1Id = ds1.getClusterId();
View Full Code Here

    private MemoryDocumentStore ds;
    private MemoryBlobStore bs;

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

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

        mk3.dispose();
    }

    @Test
    public void clusterNodeInfoLease() throws InterruptedException {
        MemoryDocumentStore store = new MemoryDocumentStore();
        ClusterNodeInfo c1, c2;
        c1 = ClusterNodeInfo.getInstance(store, "m1", null);
        assertEquals(1, c1.getId());
        c1.setLeaseTime(1);
        // this will quickly expire
View Full Code Here

        assertEquals(1, c2.getId());
    }

    @Test
    public void openCloseOpen() {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();

        DocumentMK mk1 = createMK(1, 0, ds, bs);
        mk1.commit("/", "+\"a\": {}", null, null);
        mk1.commit("/", "-\"a\"", null, null);
View Full Code Here

        mk3.dispose();
    }

    @Test
    public void clusterNodeInfo() {
        MemoryDocumentStore store = new MemoryDocumentStore();
        ClusterNodeInfo c1, c2, c3, c4;

        c1 = ClusterNodeInfo.getInstance(store, "m1", null);
        assertEquals(1, c1.getId());
        c1.dispose();
View Full Code Here

            DB db = MongoUtils.getConnection().getDB();
            return new DocumentMK.Builder().setMongoDB(db)
                    .setClusterId(clusterId).setAsyncDelay(asyncDelay).open();
        } else {
            if (ds == null) {
                ds = new MemoryDocumentStore();
            }
            if (bs == null) {
                bs = new MemoryBlobStore();
            }
            return createMK(clusterId, asyncDelay, ds, bs);
View Full Code Here

*/
public class NodeDocumentTest {

    @Test
    public void splitCollisions() throws Exception {
        MemoryDocumentStore docStore = new MemoryDocumentStore();
        String id = Utils.getPathFromId("/");
        NodeDocument doc = new NodeDocument(docStore);
        doc.put(Document.ID, id);
        UpdateOp op = new UpdateOp(id, false);
        for (int i = 0; i < NodeDocument.NUM_REVS_THRESHOLD + 1; i++) {
View Full Code Here

    @Test
    public void previousDocs1() {
        String rootPath = "/";
        String rootId = Utils.getIdFromPath(rootPath);
        Revision r0 = new Revision(0, 0, 1);
        MemoryDocumentStore store = new MemoryDocumentStore();
        // create previous docs
        UpdateOp op = new UpdateOp(Utils.getPreviousIdFor(rootPath, r0, 0), true);
        op.set(ID, op.getId());
        op.setMapEntry("prop", r0, "0");
        NodeDocument.setRevision(op, r0, "c");
        store.createOrUpdate(NODES, op);
        Revision r1low = new Revision(1, 0, 1);
        Revision r1high = new Revision(1, 10, 1);
        op = new UpdateOp(Utils.getPreviousIdFor(rootPath, r1high, 0), true);
        op.set(ID, op.getId());
        for (int i = r1low.getCounter(); i <= r1high.getCounter(); i++) {
            Revision r = new Revision(1, i, 1);
            op.setMapEntry("foo", r, String.valueOf(i));
            NodeDocument.setRevision(op, r, "c");
        }
        store.createOrUpdate(NODES, op);
        // create root doc
        op = new UpdateOp(rootId, true);
        op.set(ID, op.getId());
        Revision r2 = new Revision(2, 0, 1);
        op.setMapEntry("prop", r2, "1");
        NodeDocument.setRevision(op, r2, "c");
        NodeDocument.setPrevious(op, new Range(r0, r0, 0));
        NodeDocument.setPrevious(op, new Range(r1high, r1low, 0));
        store.createOrUpdate(NODES, op);

        NodeDocument doc = store.find(NODES, rootId);
        assertNotNull(doc);
        Set<Revision> revs = doc.getValueMap("prop").keySet();
        assertEquals(2, revs.size());
        assertTrue(revs.contains(r0));
        assertTrue(revs.contains(r2));
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore

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.