Search in sources :

Example 1 with IndexPathService

use of org.apache.jackrabbit.oak.plugins.index.IndexPathService in project jackrabbit-oak by apache.

the class ActiveDeletedBlobCollectorMBeanImplTest method timedOutWhileWaitingForIndexerShouldAutoResume.

@Test
public void timedOutWhileWaitingForIndexerShouldAutoResume() {
    IndexPathService indexPathService = MockRegistrar.getIndexPathsService(indexPaths);
    AsyncIndexInfoService asyncIndexInfoService = MockRegistrar.getAsyncIndexInfoService(newArrayList(new IndexMBeanInfoSupplier("foo-async", () -> STATUS_RUNNING, () -> 2L)));
    ActiveDeletedBlobCollectorMBean bean = getTestBean(indexPathService, asyncIndexInfoService);
    bean.flagActiveDeletionUnsafeForCurrentState();
    assertFalse("Timing out on running indexer didn't resume marking blobs", bean.isActiveDeletionUnsafe());
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) Test(org.junit.Test)

Example 2 with IndexPathService

use of org.apache.jackrabbit.oak.plugins.index.IndexPathService in project jackrabbit-oak by apache.

the class ActiveDeletedBlobCollectorMBeanImplTest method headIndexFilesGetMarkedUnsafe.

@Test
public void headIndexFilesGetMarkedUnsafe() throws Exception {
    String indexPath = "/fooIndex";
    createFakeIndex(indexPath);
    IndexPathService indexPathService = MockRegistrar.getIndexPathsService(indexPaths);
    AsyncIndexInfoService asyncIndexInfoService = MockRegistrar.getAsyncIndexInfoService(newArrayList(new IndexMBeanInfoSupplier("foo-async", () -> STATUS_DONE, () -> 2L)));
    ActiveDeletedBlobCollectorMBean bean = getTestBean(indexPathService, asyncIndexInfoService);
    bean.flagActiveDeletionUnsafeForCurrentState();
    NodeState indexFile = getFakeIndexFile(indexPath);
    assertTrue(indexFile.getBoolean(PROP_UNSAFE_FOR_ACTIVE_DELETION));
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) Test(org.junit.Test)

Example 3 with IndexPathService

use of org.apache.jackrabbit.oak.plugins.index.IndexPathService in project jackrabbit-oak by apache.

the class ActiveDeletedBlobCollectorMBeanImplTest method clonedNSWithSharedDS.

@Test
public void clonedNSWithSharedDS() throws Exception {
    MemoryBlobStore bs = new MemoryBlobStore();
    bs.setBlockSizeMin(48);
    MemoryDocumentStore mds1 = new MemoryDocumentStore();
    DocumentNodeStore dns1 = builderProvider.newBuilder().setDocumentStore(mds1).setBlobStore(bs).build();
    // Create initial repo with InitialContent. It has enough data to create blobs
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider();
    ContentRepository repository = new Oak(dns1).with(new InitialContent()).with(new OpenSecurityProvider()).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
    ContentSession session = repository.login(null, null);
    Root root = session.getLatestRoot();
    TestUtil.createFulltextIndex(root.getTree("/"), "testIndex");
    root.commit();
    // pause active deletion
    IndexPathService indexPathService = new IndexPathServiceImpl(dns1);
    AsyncIndexInfoService asyncIndexInfoService = MockRegistrar.getAsyncIndexInfoService(newArrayList(new IndexMBeanInfoSupplier("foo-async", () -> STATUS_DONE, () -> 2L)));
    ActiveDeletedBlobCollectorMBeanImpl bean = new ActiveDeletedBlobCollectorMBeanImpl(ActiveDeletedBlobCollectorFactory.NOOP, wb, dns1, indexPathService, asyncIndexInfoService, new MemoryBlobStore(), sameThreadExecutor());
    bean.clock = clock;
    bean.flagActiveDeletionUnsafeForCurrentState();
    // we try here to create some churn and we want some files to get created at dns1
    // BUT get deleted at dns2. "segments_1" is one such file.
    // since our "creation" of churn is assumed, we should assert that dns1 has "segments_1"
    // (and later dns2 doesn't have it)
    root = session.getLatestRoot();
    assertTrue("First pass indexing should generate segments_1", root.getTree("/oak:index/testIndex/:data/segments_1").exists());
    // shutdown first instance
    dns1.dispose();
    // clone
    MemoryDocumentStore mds2 = mds1.copy();
    DocumentNodeStore dns2 = builderProvider.newBuilder().setDocumentStore(mds2).setBlobStore(bs).build();
    // create some churn to delete some index files - using clone store
    // we'd setup lucene editor with active deletion collector
    DeletedFileTrackingADBC deletedFileTrackingADBC = new DeletedFileTrackingADBC(new File(temporaryFolder.getRoot(), "adbc-workdir"));
    editorProvider = new LuceneIndexEditorProvider(null, null, new ExtractedTextCache(0, 0), null, Mounts.defaultMountInfoProvider(), deletedFileTrackingADBC);
    repository = new Oak(dns2).with(new OpenSecurityProvider()).with(editorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
    session = repository.login(null, null);
    root = session.getLatestRoot();
    Tree rootTree = root.getTree("/");
    for (int i = 0; i < 20; i++) {
        Tree child = rootTree.addChild("a" + i);
        for (int j = 0; j < 20; j++) {
            child.setProperty("foo" + j, "bar" + j);
        }
    }
    root.commit();
    // since our index is not async, we are unable to track commit progress automatically.
    // OR, iow, we need to play the rold of AsyncIndexUpdate explicitly
    deletedFileTrackingADBC.blobDeletionCallback.commitProgress(COMMIT_SUCCEDED);
    deletedFileTrackingADBC.purgeBlobsDeleted(Clock.SIMPLE.getTime() + TimeUnit.SECONDS.toMillis(1), bs);
    root = session.getLatestRoot();
    assertFalse("Churn created via dns2 should delete segments_1", root.getTree("/oak:index/testIndex/:data/segments_1").exists());
    dns2.dispose();
    // validate index using dns1 which should still have valid index data even
    // after dns2's churn
    dns1 = builderProvider.newBuilder().setDocumentStore(mds1).setBlobStore(bs).build();
    IndexConsistencyChecker checker = new IndexConsistencyChecker(dns1.getRoot(), "/oak:index/testIndex", new File(temporaryFolder.getRoot(), "checker-workdir"));
    IndexConsistencyChecker.Result result = checker.check(IndexConsistencyChecker.Level.BLOBS_ONLY);
    assertFalse("Nodestore1 can't read blobs: " + result.missingBlobIds + " while reading index", result.missingBlobs);
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) Root(org.apache.jackrabbit.oak.api.Root) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IndexPathServiceImpl(org.apache.jackrabbit.oak.plugins.index.IndexPathServiceImpl) InitialContent(org.apache.jackrabbit.oak.InitialContent) IndexConsistencyChecker(org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexConsistencyChecker) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) MemoryBlobStore(org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore) File(java.io.File) Test(org.junit.Test)

Example 4 with IndexPathService

use of org.apache.jackrabbit.oak.plugins.index.IndexPathService in project jackrabbit-oak by apache.

the class ActiveDeletedBlobCollectorMBeanImplTest method pauseResumeSetsInMemFlag.

@Test
public void pauseResumeSetsInMemFlag() {
    IndexPathService indexPathService = MockRegistrar.getIndexPathsService(indexPaths);
    AsyncIndexInfoService asyncIndexInfoService = MockRegistrar.getAsyncIndexInfoService(newArrayList(new IndexMBeanInfoSupplier("foo-async", () -> STATUS_DONE, () -> 2L)));
    ActiveDeletedBlobCollectorMBean bean = getTestBean(indexPathService, asyncIndexInfoService);
    assertFalse("Bean should delegate the call correctly", bean.isActiveDeletionUnsafe());
    bean.flagActiveDeletionUnsafeForCurrentState();
    assertTrue("Active deleted blob collector isn't notified to stop marking", ActiveDeletedBlobCollectorFactory.NOOP.isActiveDeletionUnsafe());
    assertTrue("Bean should delegate the call correctly", bean.isActiveDeletionUnsafe());
    bean.flagActiveDeletionSafe();
    assertFalse("Active deleted blob collector isn't notified to resume marking", ActiveDeletedBlobCollectorFactory.NOOP.isActiveDeletionUnsafe());
    assertFalse("Bean should delegate the call correctly", bean.isActiveDeletionUnsafe());
}
Also used : IndexPathService(org.apache.jackrabbit.oak.plugins.index.IndexPathService) AsyncIndexInfoService(org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService) Test(org.junit.Test)

Example 5 with IndexPathService

use of org.apache.jackrabbit.oak.plugins.index.IndexPathService 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)

Aggregations

IndexPathService (org.apache.jackrabbit.oak.plugins.index.IndexPathService)9 AsyncIndexInfoService (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService)8 Test (org.junit.Test)8 IndexPathServiceImpl (org.apache.jackrabbit.oak.plugins.index.IndexPathServiceImpl)3 MemoryBlobStore (org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore)3 File (java.io.File)2 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)2 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Nonnull (javax.annotation.Nonnull)1 InitialContent (org.apache.jackrabbit.oak.InitialContent)1 Oak (org.apache.jackrabbit.oak.Oak)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)1 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)1 Root (org.apache.jackrabbit.oak.api.Root)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)1 AsyncIndexInfoServiceImpl (org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoServiceImpl)1