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