Search in sources :

Example 16 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider 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 17 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class ExcerptTest method createRepository.

@Override
protected ContentRepository createRepository() {
    LuceneIndexEditorProvider editorProvider = new LuceneIndexEditorProvider();
    LuceneIndexProvider provider = new LuceneIndexProvider();
    NodeStore nodeStore = new MemoryNodeStore();
    return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((Observer) provider).with(editorProvider).with((QueryIndexProvider) provider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)

Example 18 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class DefaultThreeWayConflictHandlerTheirsTest method setUp.

@Before
public void setUp() throws CommitFailedException {
    ContentSession session = new Oak().with(new OpenSecurityProvider()).with(DefaultThreeWayConflictHandler.THEIRS).createContentSession();
    // Add test content
    Root root = session.getLatestRoot();
    Tree tree = root.getTree("/");
    tree.setProperty("a", 1);
    tree.setProperty("b", 2);
    tree.setProperty("c", 3);
    tree.addChild("x");
    tree.addChild("y");
    tree.addChild("z");
    root.commit();
    ourRoot = session.getLatestRoot();
    theirRoot = session.getLatestRoot();
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Before(org.junit.Before)

Example 19 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class LuceneWritesOnSegmentStatsTest method createRepository.

@Override
protected ContentRepository createRepository() {
    LuceneIndexEditorProvider editorProvider;
    LuceneIndexProvider provider;
    if (copyOnRW) {
        IndexCopier copier = createIndexCopier();
        editorProvider = new LuceneIndexEditorProvider(copier, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100));
        provider = new LuceneIndexProvider(copier);
    } else {
        editorProvider = new LuceneIndexEditorProvider();
        provider = new LuceneIndexProvider();
    }
    NodeStore nodeStore;
    try {
        statisticsProvider = new DefaultStatisticsProvider(scheduledExecutorService);
        fileStore = FileStoreBuilder.fileStoreBuilder(DIRECTORY).withStatisticsProvider(statisticsProvider).withBlobStore(createBlobStore()).build();
        nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    } catch (IOException | InvalidFileStoreVersionException e) {
        throw new RuntimeException(e);
    }
    return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).with(optionalEditorProvider).with(new PropertyIndexEditorProvider()).with(new NodeTypeIndexProvider()).createContentRepository();
}
Also used : NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IOException(java.io.IOException) InitialContent(org.apache.jackrabbit.oak.InitialContent) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) Oak(org.apache.jackrabbit.oak.Oak)

Example 20 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class SuggestionIntervalTest method createRepository.

@Override
protected ContentRepository createRepository() {
    LuceneIndexProvider provider = new LuceneIndexProvider();
    ContentRepository repository = new Oak().with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(new LuceneIndexEditorProvider()).createContentRepository();
    clock = new Clock.Virtual();
    try {
        clock.waitUntil(System.currentTimeMillis());
    } catch (Exception e) {
    // eat exception if clock couldn't wait... that was just courteous anyway!
    }
    LuceneIndexEditorContext.setClock(clock);
    return repository;
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Clock(org.apache.jackrabbit.oak.stats.Clock) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)

Aggregations

OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)51 Oak (org.apache.jackrabbit.oak.Oak)38 InitialContent (org.apache.jackrabbit.oak.InitialContent)25 Test (org.junit.Test)19 Root (org.apache.jackrabbit.oak.api.Root)16 Tree (org.apache.jackrabbit.oak.api.Tree)14 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)14 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)12 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)11 Before (org.junit.Before)11 IOException (java.io.IOException)8 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)8 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)8 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)7 Nonnull (javax.annotation.Nonnull)6 Closeable (java.io.Closeable)5 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)5 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)5 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4