use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.
the class Cluster2Test 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 ClusterTest method openCloseOpen.
@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);
mk1.runBackgroundOperations();
DocumentMK mk2 = createMK(2, 0, ds, bs);
mk2.commit("/", "+\"a\": {}", null, null);
mk2.commit("/", "-\"a\"", null, null);
mk2.runBackgroundOperations();
DocumentMK mk3 = createMK(3, 0, ds, bs);
mk3.commit("/", "+\"a\": {}", null, null);
mk3.commit("/", "-\"a\"", null, null);
mk3.runBackgroundOperations();
DocumentMK mk4 = createMK(4, 0, ds, bs);
mk4.commit("/", "+\"a\": {}", null, null);
mk4.runBackgroundOperations();
DocumentMK mk5 = createMK(5, 0, ds, bs);
mk5.commit("/", "-\"a\"", null, null);
mk5.commit("/", "+\"a\": {}", null, null);
}
use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.
the class OakDirectoryTestBase method markAllBlobsFromBlobStoreAsDeleted.
// OAK-7066
@Test
public void markAllBlobsFromBlobStoreAsDeleted() throws Exception {
IndexDefinition def = new IndexDefinition(root, builder.getNodeState(), "/foo");
final Set<String> deletedFiles = newHashSet();
MemoryBlobStore bs = new MemoryBlobStore();
bs.setBlockSizeMin(48);
BlobFactory factory = in -> new BlobStoreBlob(bs, bs.writeBlob(in));
OakDirectory dir = getOakDirectoryBuilder(builder, def).setReadOnly(false).with(factory).with(new ActiveDeletedBlobCollectorFactory.BlobDeletionCallback() {
@Override
public void deleted(String blobId, Iterable<String> ids) {
deletedFiles.add(Iterables.getLast(ids));
}
@Override
public void commitProgress(IndexProgress indexProgress) {
}
@Override
public boolean isMarkingForActiveDeletionUnsafe() {
return false;
}
}).build();
writeFile(dir, "file1", 25);
writeFile(dir, "file2", 50);
dir.deleteFile("file1");
dir.deleteFile("file2");
dir.close();
assertTrue("file1 must be reported as deleted", deletedFiles.contains("file1"));
assertTrue("file2 must be reported as deleted", deletedFiles.contains("file2"));
}
use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.
the class FlatFileStoreTest method basicTest.
@Test
public void basicTest() throws Exception {
List<String> paths = createTestPaths();
FlatFileNodeStoreBuilder builder = new FlatFileNodeStoreBuilder(TestUtils.createEntries(paths), folder.getRoot());
FlatFileStore flatStore = builder.withBlobStore(new MemoryBlobStore()).withPreferredPathElements(preferred).build();
List<String> entryPaths = StreamSupport.stream(flatStore.spliterator(), false).map(NodeStateEntry::getPath).collect(Collectors.toList());
List<String> sortedPaths = TestUtils.sortPaths(paths, preferred);
assertEquals(sortedPaths, entryPaths);
}
use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore in project jackrabbit-oak by apache.
the class MergeRetryTest method retryPersisted.
/**
* Test for OAK-1202
*/
@Test
public void retryPersisted() 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();
createTree(builder1.child("bar"), 2);
NodeBuilder builder2 = ns2.getRoot().builder();
createTree(builder2.child("qux"), 2);
ns1.merge(builder1, HOOK, CommitInfo.EMPTY);
ns2.merge(builder2, HOOK, CommitInfo.EMPTY);
} finally {
ns1.dispose();
ns2.dispose();
}
}
Aggregations