Search in sources :

Example 6 with MemoryBlobStore

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

the class ActiveDeletedBlobCollectorMBeanImplTest method failureToFlagAllIndexFilesShouldAutoResume.

@Test
public void failureToFlagAllIndexFilesShouldAutoResume() {
    IndexPathService indexPathService = MockRegistrar.getIndexPathsService(indexPaths);
    AsyncIndexInfoService asyncIndexInfoService = MockRegistrar.getAsyncIndexInfoService(newArrayList(new IndexMBeanInfoSupplier("foo-async", () -> STATUS_DONE, () -> 2L)));
    NodeStore failingNodeStore = new MemoryNodeStore() {

        @Nonnull
        @Override
        public synchronized NodeState merge(@Nonnull NodeBuilder builder, @Nonnull CommitHook commitHook, @Nonnull CommitInfo info) throws CommitFailedException {
            throw new CommitFailedException("TestFail", 1, "We must never merge");
        }
    };
    ActiveDeletedBlobCollectorMBeanImpl bean = new ActiveDeletedBlobCollectorMBeanImpl(ActiveDeletedBlobCollectorFactory.NOOP, wb, failingNodeStore, indexPathService, asyncIndexInfoService, new MemoryBlobStore(), sameThreadExecutor());
    bean.clock = clock;
    bean.flagActiveDeletionUnsafeForCurrentState();
    assertFalse("Failure to update head index files didn't resume marking blobs", bean.isActiveDeletionUnsafe());
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) Nonnull(javax.annotation.Nonnull) CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) CommitInfo(org.apache.jackrabbit.oak.spi.commit.CommitInfo) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test)

Example 7 with MemoryBlobStore

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

the class SecondaryStoreCacheServiceTest method configureDefaultServices.

@Before
public void configureDefaultServices() {
    context.registerService(BlobStore.class, new MemoryBlobStore());
    context.registerService(NodeStoreProvider.class, new NodeStoreProvider() {

        @Override
        public NodeStore getNodeStore() {
            return secondaryStore;
        }
    }, ImmutableMap.<String, Object>of("role", "secondary"));
    context.registerService(Executor.class, Executors.newSingleThreadExecutor());
    context.registerService(StatisticsProvider.class, StatisticsProvider.NOOP);
    MockOsgi.injectServices(cacheService, context.bundleContext());
}
Also used : NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) NodeStoreProvider(org.apache.jackrabbit.oak.spi.state.NodeStoreProvider) Before(org.junit.Before)

Example 8 with MemoryBlobStore

use of org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore 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, 0);
    clock.getTimeIncreasing();
    clock.getTimeIncreasing();
    // cleanup everything that might still be there
    gc.gc();
    // 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());
}
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)

Example 9 with MemoryBlobStore

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

the class DocumentSplitTest method manyRevisions.

// OAK-1233
@Test
public void manyRevisions() {
    final int numMKs = 3;
    MemoryDocumentStore ds = new MemoryDocumentStore();
    MemoryBlobStore bs = new MemoryBlobStore();
    List<Set<String>> changes = new ArrayList<Set<String>>();
    List<DocumentMK> mks = new ArrayList<DocumentMK>();
    for (int i = 1; i <= numMKs; i++) {
        DocumentMK.Builder builder = new DocumentMK.Builder();
        builder.setDocumentStore(ds).setBlobStore(bs).setAsyncDelay(0);
        DocumentMK mk = builder.setClusterId(i).open();
        mks.add(mk);
        changes.add(new HashSet<String>());
        if (i == 1) {
            mk.commit("/", "+\"test\":{}", null, null);
            mk.runBackgroundOperations();
        }
    }
    List<String> propNames = Arrays.asList("prop1", "prop2", "prop3");
    Random random = new Random(0);
    for (int i = 0; i < 1000; i++) {
        int mkIdx = random.nextInt(mks.size());
        // pick mk
        DocumentMK mk = mks.get(mkIdx);
        DocumentNodeStore ns = mk.getNodeStore();
        // pick property name to update
        String name = propNames.get(random.nextInt(propNames.size()));
        // need to sync?
        for (int j = 0; j < changes.size(); j++) {
            Set<String> c = changes.get(j);
            if (c.contains(name)) {
                syncMKs(mks, j);
                c.clear();
                break;
            }
        }
        // read current value
        NodeDocument doc = ds.find(NODES, Utils.getIdFromPath("/test"));
        assertNotNull(doc);
        RevisionVector head = ns.getHeadRevision();
        Revision lastRev = ns.getPendingModifications().get("/test");
        DocumentNodeState n = doc.getNodeAtRevision(mk.getNodeStore(), head, lastRev);
        assertNotNull(n);
        String value = n.getPropertyAsString(name);
        // set or increment
        if (value == null) {
            value = String.valueOf(0);
        } else {
            value = String.valueOf(Integer.parseInt(value) + 1);
        }
        mk.commit("/test", "^\"" + name + "\":" + value, null, null);
        changes.get(mkIdx).add(name);
    }
    for (DocumentMK mk : mks) {
        mk.dispose();
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) ArrayList(java.util.ArrayList) Random(java.util.Random) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) Test(org.junit.Test)

Example 10 with MemoryBlobStore

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

the class RandomizedClusterTest method createMK.

private DocumentMK createMK(int clusterId) {
    DocumentMK.Builder builder = new DocumentMK.Builder();
    builder.setAsyncDelay(0);
    if (MONGO_DB) {
        MongoConnection c = connectionFactory.getConnection();
        MongoUtils.dropCollections(c.getDBName());
        builder.setMongoDB(c.getMongoClient(), c.getDBName());
    } else {
        if (ds == null) {
            ds = new MemoryDocumentStore();
        }
        if (bs == null) {
            bs = new MemoryBlobStore();
        }
        builder.setDocumentStore(ds).setBlobStore(bs);
    }
    return builder.setClusterId(clusterId + 1).open();
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) JsopBuilder(org.apache.jackrabbit.oak.commons.json.JsopBuilder) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) MongoConnection(org.apache.jackrabbit.oak.plugins.document.util.MongoConnection)

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