Search in sources :

Example 1 with MemoryDocumentStore

use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.

the class ClusterRepositoryInfoTest method checkChangeId.

@Test
public void checkChangeId() throws Exception {
    MemoryDocumentStore store = new MemoryDocumentStore();
    DocumentNodeStore ds1 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(store).setClusterId(1).getNodeStore();
    String repoId1 = ClusterRepositoryInfo.getOrCreateId(ds1);
    ds1.runBackgroundOperations();
    // Change with a custom ID
    setId(ds1, "xxxxxxxx");
    String id = ClusterRepositoryInfo.getOrCreateId(ds1);
    Assert.assertNotNull(id);
    Assert.assertEquals(id, "xxxxxxxx");
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) Test(org.junit.Test)

Example 2 with MemoryDocumentStore

use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.

the class CheckpointsTest method crossClusterNodeCheckpoint.

@Test
public void crossClusterNodeCheckpoint() throws Exception {
    // use an async delay to ensure DocumentNodeStore.suspendUntil() works
    // but set it to a high value and control background ops manually in
    // this test
    final int asyncDelay = (int) TimeUnit.MINUTES.toMillis(1);
    DocumentStore store = new MemoryDocumentStore();
    final DocumentNodeStore ns1 = builderProvider.newBuilder().setClusterId(1).setDocumentStore(store).setAsyncDelay(asyncDelay).getNodeStore();
    final DocumentNodeStore ns2 = builderProvider.newBuilder().setClusterId(2).setDocumentStore(store).setAsyncDelay(asyncDelay).getNodeStore();
    // create node on ns1
    NodeBuilder builder = ns1.getRoot().builder();
    builder.child("foo");
    ns1.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // make visible on ns2
    ns1.runBackgroundOperations();
    ns2.runBackgroundOperations();
    // create checkpoint on ns1
    String cp1 = ns1.checkpoint(Long.MAX_VALUE);
    // retrieve checkpoint on ns2
    NodeState root = ns2.retrieve(cp1);
    assertNotNull(root);
    assertTrue(root.hasChildNode("foo"));
    ns2.release(cp1);
    // create node on ns1
    builder = ns1.getRoot().builder();
    builder.child("bar");
    ns1.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // create checkpoint when 'bar' is not yet visible to ns2
    final String cp2 = ns1.checkpoint(Long.MAX_VALUE);
    // retrieve checkpoint on ns2
    final NodeState[] state = new NodeState[1];
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            state[0] = ns2.retrieve(cp2);
        }
    });
    t.start();
    ns1.runBackgroundOperations();
    ns2.runBackgroundOperations();
    t.join();
    assertNotNull(state[0]);
    assertTrue(state[0].hasChildNode("bar"));
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 3 with MemoryDocumentStore

use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.

the class DataStoreTrackerGCTest method sameClusterGC.

/**
     * Tests GC twice on 2 node cluster setup.
     * @throws Exception
     */
@Test
public void sameClusterGC() throws Exception {
    MemoryDocumentStore store = new MemoryDocumentStore();
    Cluster cluster1 = new Cluster("cluster1-1", 1, store);
    Cluster cluster2 = new Cluster("cluster1-2", 2, store);
    clusterGCInternal(cluster1, cluster2, true);
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Test(org.junit.Test)

Example 4 with MemoryDocumentStore

use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.

the class ClusterRepositoryInfoTest method differentCluster.

@Test
public void differentCluster() throws Exception {
    DocumentNodeStore ds1 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(new MemoryDocumentStore()).setBlobStore(blobStore).getNodeStore();
    String repoId1 = ClusterRepositoryInfo.getOrCreateId(ds1);
    DocumentNodeStore ds2 = builderProvider.newBuilder().setAsyncDelay(0).setDocumentStore(new MemoryDocumentStore()).setBlobStore(blobStore).getNodeStore();
    String repoId2 = ClusterRepositoryInfo.getOrCreateId(ds2);
    Assert.assertNotSame(repoId1, repoId2);
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) Test(org.junit.Test)

Example 5 with MemoryDocumentStore

use of org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore in project jackrabbit-oak by apache.

the class JournalIT method doLargeCleanupTest.

private void doLargeCleanupTest(int offset, int size) throws Exception {
    Clock clock = new Clock.Virtual();
    DocumentMK mk1 = createMK(0, /* clusterId: 0 => uses clusterNodes collection */
    0, new MemoryDocumentStore(), new MemoryBlobStore());
    DocumentNodeStore ns1 = mk1.getNodeStore();
    // make sure we're visible and marked as active
    renewClusterIdLease(ns1);
    JournalGarbageCollector gc = new JournalGarbageCollector(ns1);
    clock.getTimeIncreasing();
    clock.getTimeIncreasing();
    // cleanup everything that might still be there
    gc.gc(0, TimeUnit.MILLISECONDS);
    // create entries as parametrized:
    for (int i = offset; i < size + offset; i++) {
        mk1.commit("/", "+\"regular" + i + "\": {}", null, null);
        // always run background ops to 'flush' the change
        // into the journal:
        ns1.runBackgroundOperations();
    }
    // sleep 100millis
    Thread.sleep(100);
    // should now be able to clean up everything
    assertEquals(size, gc.gc(0, TimeUnit.MILLISECONDS));
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) JournalGarbageCollector(org.apache.jackrabbit.oak.plugins.document.JournalGarbageCollector) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Clock(org.apache.jackrabbit.oak.stats.Clock)

Aggregations

MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)132 Test (org.junit.Test)113 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)72 Clock (org.apache.jackrabbit.oak.stats.Clock)21 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)19 Before (org.junit.Before)13 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)11 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 Utils.getRootDocument (org.apache.jackrabbit.oak.plugins.document.util.Utils.getRootDocument)9 Random (java.util.Random)8 CONSTRAINT (org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT)8 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)7 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)6 ArrayList (java.util.ArrayList)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 StringSort (org.apache.jackrabbit.oak.commons.sort.StringSort)5 List (java.util.List)4 Semaphore (java.util.concurrent.Semaphore)4 VersionGCStats (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats)4