Search in sources :

Example 11 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.

the class MergeRetryTest method retryInMemory.

/**
 * Test for OAK-1198
 */
@Test
public void retryInMemory() throws Exception {
    MemoryDocumentStore ds = new MemoryDocumentStore();
    MemoryBlobStore bs = new MemoryBlobStore();
    DocumentNodeStore ns1 = createMK(1, 1000, ds, bs);
    DocumentNodeStore ns2 = createMK(2, 1000, ds, bs);
    try {
        NodeBuilder builder1 = ns1.getRoot().builder();
        builder1.child("bar");
        NodeBuilder builder2 = ns2.getRoot().builder();
        builder2.child("qux");
        ns1.merge(builder1, HOOK, CommitInfo.EMPTY);
        ns2.merge(builder2, HOOK, CommitInfo.EMPTY);
    } finally {
        ns1.dispose();
        ns2.dispose();
    }
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 12 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.

the class ClusterPermissionsTest method before.

@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(0);
    ns1 = builder.setClusterId(1).getNodeStore();
    builder = new DocumentMK.Builder();
    builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
    ns2 = builder.setClusterId(2).getNodeStore();
    Oak oak = new Oak(ns1).with(new InitialContent()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(securityProvider1 = SecurityProviderBuilder.newBuilder().with(getSecurityConfigParameters()).build());
    contentRepository1 = oak.createContentRepository();
    adminSession1 = login1(getAdminCredentials());
    root1 = adminSession1.getLatestRoot();
    userManager1 = securityProvider1.getConfiguration(UserConfiguration.class).getUserManager(root1, namePathMapper);
    aclMgr1 = securityProvider1.getConfiguration(AuthorizationConfiguration.class).getAccessControlManager(root1, namePathMapper);
    // make sure initial content is visible to ns2
    syncClusterNodes();
    oak = new Oak(ns2).with(new InitialContent()).with(new ReferenceEditorProvider()).with(new ReferenceIndexProvider()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(securityProvider2 = SecurityProviderBuilder.newBuilder().with(getSecurityConfigParameters()).build());
    contentRepository2 = oak.createContentRepository();
    adminSession2 = login2(getAdminCredentials());
    root2 = adminSession2.getLatestRoot();
    userManager2 = securityProvider2.getConfiguration(UserConfiguration.class).getUserManager(root2, namePathMapper);
    aclMgr2 = securityProvider2.getConfiguration(AuthorizationConfiguration.class).getAccessControlManager(root2, namePathMapper);
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) ReferenceIndexProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceIndexProvider) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) Oak(org.apache.jackrabbit.oak.Oak) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Before(org.junit.Before)

Example 13 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.

the class DocumentNodeStoreBuilder method getBlobStore.

public BlobStore getBlobStore() {
    if (blobStore == null) {
        blobStore = new MemoryBlobStore();
        configureBlobStore(blobStore);
    }
    return blobStore;
}
Also used : MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)

Example 14 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.

the class ClusterTest2 method twoNodes.

@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);
    DocumentMK mk1 = builder.setClusterId(1).open();
    builder = new DocumentMK.Builder();
    builder.setDocumentStore(ds).setBlobStore(bs);
    DocumentMK mk2 = builder.setClusterId(2).open();
    mk1.commit("/", "+\"test\":{\"x\": 1}", null, null);
    mk1.backgroundWrite();
    mk2.backgroundRead();
    String b1 = mk2.branch(mk2.getHeadRevision());
    mk2.commit("/", "-\"test\"", b1, null);
    String b2 = mk2.branch(mk2.getHeadRevision());
    String b2b = mk2.commit("/", "-\"test\"", b2, null);
    mk2.merge(b2b, null);
    mk2.backgroundWrite();
    mk1.backgroundRead();
    mk1.commit("/", "+\"test\":{\"x\": 1}", null, null);
    mk1.backgroundWrite();
    mk2.backgroundRead();
    String n1 = mk1.getNodes("/test", mk1.getHeadRevision(), 0, 0, 10, null);
    String n2 = mk2.getNodes("/test", mk2.getHeadRevision(), 0, 0, 10, null);
    // mk1 now sees both changes
    assertEquals("{\"x\":1,\":childNodeCount\":0}", n1);
    assertEquals("{\"x\":1,\":childNodeCount\":0}", n2);
    mk1.dispose();
    mk2.dispose();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Test(org.junit.Test)

Example 15 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.

the class DocumentSplitTest method cluster.

@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());
    Revision previous = null;
    for (Map.Entry<Revision, String> entry : revs.entrySet()) {
        if (previous != null) {
            assertTrue(previous.compareRevisionTimeThenClusterId(entry.getKey()) > 0);
        }
        previous = entry.getKey();
    }
    mk1.dispose();
    mk2.dispose();
    mk3.dispose();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Map(java.util.Map) Test(org.junit.Test)

Aggregations

MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)23 Test (org.junit.Test)16 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)12 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)8 File (java.io.File)5 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)4 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)4 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)4 Random (java.util.Random)3 DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)3 AsyncIndexInfoService (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService)3 IndexPathService (org.apache.jackrabbit.oak.plugins.index.IndexPathService)3 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)3 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 InitialContent (org.apache.jackrabbit.oak.InitialContent)2 Oak (org.apache.jackrabbit.oak.Oak)2 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)2 Before (org.junit.Before)2