Search in sources :

Example 1 with IndexEditorProvider

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

the class Jcr method setUpOak.

private void setUpOak() {
    // whiteboard
    if (whiteboard != null) {
        oak.with(whiteboard);
    }
    // repository initializers
    for (RepositoryInitializer repositoryInitializer : repositoryInitializers) {
        oak.with(repositoryInitializer);
    }
    // query index providers
    for (QueryIndexProvider queryIndexProvider : queryIndexProviders) {
        oak.with(queryIndexProvider);
    }
    // commit hooks
    for (CommitHook commitHook : commitHooks) {
        oak.with(commitHook);
    }
    // conflict handlers
    oak.with(conflictHandler);
    // index editor providers
    for (IndexEditorProvider indexEditorProvider : indexEditorProviders) {
        oak.with(indexEditorProvider);
    }
    // editors
    for (Editor editor : editors) {
        oak.with(editor);
    }
    // editor providers
    for (EditorProvider editorProvider : editorProviders) {
        oak.with(editorProvider);
    }
    // securityProvider
    oak.with(securityProvider);
    // executors
    if (scheduledExecutor != null) {
        oak.with(scheduledExecutor);
    }
    if (executor != null) {
        oak.with(executor);
    }
    // observers
    for (Observer observer : observers) {
        oak.with(observer);
    }
    // commit rate limiter
    if (commitRateLimiter != null) {
        oak.with(commitRateLimiter);
    }
    // query engine settings
    if (queryEngineSettings != null) {
        oak.with(queryEngineSettings);
    }
    // default workspace name
    if (defaultWorkspaceName != null) {
        oak.with(defaultWorkspaceName);
    }
    if (clusterable != null) {
        oak.with(clusterable);
    }
}
Also used : CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) BackgroundObserver(org.apache.jackrabbit.oak.spi.commit.BackgroundObserver) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) OrderedPropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.OrderedPropertyIndexEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) Editor(org.apache.jackrabbit.oak.spi.commit.Editor) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) OrderedPropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.OrderedPropertyIndexEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider) NamespaceEditorProvider(org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider) EditorProvider(org.apache.jackrabbit.oak.spi.commit.EditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)

Example 2 with IndexEditorProvider

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

the class ReIndexer method createIndexEditorProvider.

private IndexEditorProvider createIndexEditorProvider() throws IOException {
    //Need to list all used editors otherwise async index run fails with
    //MissingIndexEditor exception. Better approach would be to change lane for
    //those indexes and then do reindexing
    NodeCounterEditorProvider counter = new NodeCounterEditorProvider();
    IndexEditorProvider lucene = indexHelper.getLuceneIndexHelper().createEditorProvider();
    IndexEditorProvider property = new PropertyIndexEditorProvider().with(indexHelper.getMountInfoProvider());
    return CompositeIndexEditorProvider.compose(asList(lucene, property, counter));
}
Also used : PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) CompositeIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) NodeCounterEditorProvider(org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)

Example 3 with IndexEditorProvider

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

the class DocumentQueueTest method setUp.

@Before
public void setUp() throws IOException {
    IndexEditorProvider editorProvider = new LuceneIndexEditorProvider(null, null, null, defaultMountInfoProvider());
    syncHook = new EditorHook(new IndexUpdateProvider(editorProvider));
    asyncHook = new EditorHook(new IndexUpdateProvider(editorProvider, "async", false));
}
Also used : IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) LuceneIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) Before(org.junit.Before)

Example 4 with IndexEditorProvider

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

the class Oak method createNewContentRepository.

private ContentRepository createNewContentRepository() {
    final RepoStateCheckHook repoStateCheckHook = new RepoStateCheckHook();
    final List<Registration> regs = Lists.newArrayList();
    regs.add(whiteboard.register(Executor.class, getExecutor(), Collections.emptyMap()));
    IndexEditorProvider indexEditors = CompositeIndexEditorProvider.compose(indexEditorProviders);
    OakInitializer.initialize(store, new CompositeInitializer(initializers), indexEditors);
    QueryIndexProvider indexProvider = CompositeQueryIndexProvider.compose(queryIndexProviders);
    commitHooks.add(repoStateCheckHook);
    List<CommitHook> initHooks = new ArrayList<CommitHook>(commitHooks);
    initHooks.add(new EditorHook(CompositeEditorProvider.compose(editorProviders)));
    if (asyncTasks != null) {
        IndexMBeanRegistration indexRegistration = new IndexMBeanRegistration(whiteboard);
        regs.add(indexRegistration);
        for (Entry<String, Long> t : asyncTasks.entrySet()) {
            AsyncIndexUpdate task = new AsyncIndexUpdate(t.getKey(), store, indexEditors);
            indexRegistration.registerAsyncIndexer(task, t.getValue());
            closer.register(task);
        }
        PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(new AsyncIndexUpdate(IndexConstants.ASYNC_REINDEX_VALUE, store, indexEditors, true), getExecutor());
        regs.add(registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"));
    }
    regs.add(registerMBean(whiteboard, NodeCounterMBean.class, new NodeCounter(store), NodeCounterMBean.TYPE, "nodeCounter"));
    regs.add(registerMBean(whiteboard, QueryEngineSettingsMBean.class, queryEngineSettings, QueryEngineSettingsMBean.TYPE, "settings"));
    // FIXME: OAK-810 move to proper workspace initialization
    // initialize default workspace
    Iterable<WorkspaceInitializer> workspaceInitializers = Iterables.transform(securityProvider.getConfigurations(), new Function<SecurityConfiguration, WorkspaceInitializer>() {

        @Override
        public WorkspaceInitializer apply(SecurityConfiguration sc) {
            return sc.getWorkspaceInitializer();
        }
    });
    OakInitializer.initialize(workspaceInitializers, store, defaultWorkspaceName, indexEditors);
    // add index hooks later to prevent the OakInitializer to do excessive indexing
    with(new IndexUpdateProvider(indexEditors, failOnMissingIndexProvider));
    withEditorHook();
    // Register observer last to prevent sending events while initialising
    for (Observer observer : observers) {
        regs.add(whiteboard.register(Observer.class, observer, emptyMap()));
    }
    RepositoryManager repositoryManager = new RepositoryManager(whiteboard);
    regs.add(registerMBean(whiteboard, RepositoryManagementMBean.class, repositoryManager, RepositoryManagementMBean.TYPE, repositoryManager.getName()));
    CommitHook composite = CompositeHook.compose(commitHooks);
    regs.add(whiteboard.register(CommitHook.class, composite, Collections.emptyMap()));
    final Tracker<Descriptors> t = whiteboard.track(Descriptors.class);
    return new ContentRepositoryImpl(store, composite, defaultWorkspaceName, queryEngineSettings.unwrap(), indexProvider, securityProvider, new AggregatingDescriptors(t)) {

        @Override
        public void close() throws IOException {
            super.close();
            repoStateCheckHook.close();
            new CompositeRegistration(regs).unregister();
            closer.close();
        }
    };
}
Also used : ContentRepositoryImpl(org.apache.jackrabbit.oak.core.ContentRepositoryImpl) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NodeCounter(org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounter) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Executor(java.util.concurrent.Executor) IndexMBeanRegistration(org.apache.jackrabbit.oak.plugins.index.IndexMBeanRegistration) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) IndexMBeanRegistration(org.apache.jackrabbit.oak.plugins.index.IndexMBeanRegistration) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) Observer(org.apache.jackrabbit.oak.spi.commit.Observer) AggregatingDescriptors(org.apache.jackrabbit.oak.spi.descriptors.AggregatingDescriptors) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) CompositeIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider) RepositoryManager(org.apache.jackrabbit.oak.management.RepositoryManager) PropertyIndexAsyncReindex(org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindex) AggregatingDescriptors(org.apache.jackrabbit.oak.spi.descriptors.AggregatingDescriptors) Descriptors(org.apache.jackrabbit.oak.api.Descriptors) PropertyIndexAsyncReindexMBean(org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindexMBean) IndexUpdateProvider(org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider) CompositeInitializer(org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer) CommitHook(org.apache.jackrabbit.oak.spi.commit.CommitHook) NodeCounterMBean(org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounterMBean) AsyncIndexUpdate(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate) CompositeQueryIndexProvider(org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider) QueryIndexProvider(org.apache.jackrabbit.oak.spi.query.QueryIndexProvider) QueryEngineSettingsMBean(org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean) RepositoryManagementMBean(org.apache.jackrabbit.oak.api.jmx.RepositoryManagementMBean) WorkspaceInitializer(org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration)

Example 5 with IndexEditorProvider

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

the class DocumentClusterIT method initRepository.

/**
     * initialise the repository
     * 
     * @param clazz the current class. Used for logging. Cannot be null.
     * @param repos list to which add the created repository. Cannot be null.
     * @param mks list to which add the created MK. Cannot be null.
     * @param clusterId the cluster ID to use. Must be greater than 0.
     * @param asyncDelay the async delay to set. For default use {@link #NOT_PROVIDED}
     * @throws Exception
     */
protected void initRepository(@Nonnull final Class<?> clazz, @Nonnull final List<Repository> repos, @Nonnull final List<DocumentMK> mks, final int clusterId, final int asyncDelay) throws Exception {
    DocumentMK.Builder builder = new DocumentMK.Builder();
    builder.setMongoDB(createConnection(checkNotNull(clazz)).getDB());
    if (asyncDelay != NOT_PROVIDED) {
        builder.setAsyncDelay(asyncDelay);
    }
    builder.setClusterId(clusterId);
    DocumentMK mk = builder.open();
    Jcr j = getJcr(mk.getNodeStore());
    Set<IndexEditorProvider> ieps = additionalIndexEditorProviders();
    if (ieps != null) {
        for (IndexEditorProvider p : ieps) {
            j = j.with(p);
        }
    }
    if (isAsyncIndexing()) {
        j = j.withAsyncIndexing();
    }
    Repository repository = j.createRepository();
    checkNotNull(repos).add(repository);
    checkNotNull(mks).add(mk);
}
Also used : Repository(javax.jcr.Repository) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)

Aggregations

IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)6 CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)3 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)3 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)2 NodeCounterEditorProvider (org.apache.jackrabbit.oak.plugins.index.counter.NodeCounterEditorProvider)2 CommitHook (org.apache.jackrabbit.oak.spi.commit.CommitHook)2 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)2 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)2 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 Executor (java.util.concurrent.Executor)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Repository (javax.jcr.Repository)1 Descriptors (org.apache.jackrabbit.oak.api.Descriptors)1 QueryEngineSettingsMBean (org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean)1 RepositoryManagementMBean (org.apache.jackrabbit.oak.api.jmx.RepositoryManagementMBean)1 ContentRepositoryImpl (org.apache.jackrabbit.oak.core.ContentRepositoryImpl)1 RepositoryManager (org.apache.jackrabbit.oak.management.RepositoryManager)1