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");
}
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"));
}
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);
}
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);
}
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));
}
Aggregations