Examples of MemoryDocumentStore


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

        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

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

        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

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

            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

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

            DB db = MongoUtils.getConnection().getDB();
            MongoUtils.dropCollections(db);
            builder.setMongoDB(db);
        } else {
            if (ds == null) {
                ds = new MemoryDocumentStore();
            }
            if (bs == null) {
                bs = new MemoryBlobStore();
            }
            builder.setDocumentStore(ds).setBlobStore(bs);
View Full Code Here

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

    @Before
    @Override
    public void initDocumentMK() {
        logBuffer.setLength(0);
        this.store = new MemoryDocumentStore();
        DocumentMK mk = openDocumentMK();
        for (int i = 0; i < NUM_NODES; i++) {
            mk.commit("/", "+\"node-" + i + "\":{\"value\":100}", null, null);
        }
        mk.dispose();
View Full Code Here

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

        assertEquals(1L, valueMap.size());
    }

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

        builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
        DocumentMK mk1 = builder.setClusterId(1).open();

        mk1.commit("/", "+\"test\":{\"prop1\":0}", null, null);
        // make sure the new node is visible to other DocumentMK instances
        mk1.backgroundWrite();

        builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
        DocumentMK mk2 = builder.setClusterId(2).open();
        builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
        DocumentMK mk3 = builder.setClusterId(3).open();

        for (int i = 0; i < NodeDocument.NUM_REVS_THRESHOLD; i++) {
            mk1.commit("/", "^\"test/prop1\":" + i, null, null);
            mk2.commit("/", "^\"test/prop2\":" + i, null, null);
            mk3.commit("/", "^\"test/prop3\":" + i, null, null);
        }

        mk1.runBackgroundOperations();
        mk2.runBackgroundOperations();
        mk3.runBackgroundOperations();

        NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test"));
        assertNotNull(doc);
        Map<Revision, String> revs = doc.getLocalRevisions();
        assertEquals(3, revs.size());
        revs = doc.getValueMap("_revisions");
        assertEquals(3 * NodeDocument.NUM_REVS_THRESHOLD, revs.size());
View Full Code Here

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

    }

    @Test // OAK-1233
    public void manyRevisions() {
        final int numMKs = 3;
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();

        List<Set<String>> changes = new ArrayList<Set<String>>();
        List<DocumentMK> mks = new ArrayList<DocumentMK>();
        for (int i = 1; i <= numMKs; i++) {
            DocumentMK.Builder builder = new DocumentMK.Builder();
            builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
            DocumentMK mk = builder.setClusterId(i).open();
            mks.add(mk);
            changes.add(new HashSet<String>());
            if (i == 1) {
                mk.commit("/", "+\"test\":{}", null, null);
                mk.runBackgroundOperations();
            }
        }

        List<String> propNames = Arrays.asList("prop1", "prop2", "prop3");
        Random random = new Random(0);

        for (int i = 0; i < 1000; i++) {
            int mkIdx = random.nextInt(mks.size());
            // pick mk
            DocumentMK mk = mks.get(mkIdx);
            DocumentNodeStore ns = mk.getNodeStore();
            // pick property name to update
            String name = propNames.get(random.nextInt(propNames.size()));
            // need to sync?
            for (int j = 0; j < changes.size(); j++) {
                Set<String> c = changes.get(j);
                if (c.contains(name)) {
                    syncMKs(mks, j);
                    c.clear();
                    break;
                }
            }
            // read current value
            NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test"));
            assertNotNull(doc);
            Revision head = ns.getHeadRevision();
            Revision lastRev = ns.getPendingModifications().get("/test");
            Node n = doc.getNodeAtRevision(mk.getNodeStore(), head, lastRev);
            assertNotNull(n);
View Full Code Here

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

*/
public class ClusterTest2 {
   
    @Test
    public void twoNodes() throws Exception {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();
        DocumentMK.Builder builder;
       
        builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs);
View Full Code Here

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

    /**
     * Test for OAK-1198
     */
    @Test
    public void retryInMemory() throws Exception {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();

        DocumentMK mk1 = createMK(1, 1000, ds, bs);
        DocumentMK mk2 = createMK(2, 1000, ds, bs);

View Full Code Here

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

    /**
     * Test for OAK-1202
     */
    @Test
    public void retryPersisted() throws Exception {
        MemoryDocumentStore ds = new MemoryDocumentStore();
        MemoryBlobStore bs = new MemoryBlobStore();

        DocumentMK mk1 = createMK(1, 1000, ds, bs);
        DocumentMK mk2 = createMK(2, 1000, ds, bs);

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.