Search in sources :

Example 1 with IndexMBeanRegistration

use of org.apache.jackrabbit.oak.plugins.index.IndexMBeanRegistration 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"));
    }
    if (NodeCounter.USE_OLD_COUNTER) {
        regs.add(registerMBean(whiteboard, NodeCounterMBean.class, new NodeCounterOld(store), NodeCounterMBean.TYPE, "nodeCounter"));
    } else {
        regs.add(registerMBean(whiteboard, NodeCounterMBean.class, new NodeCounter(store), NodeCounterMBean.TYPE, "nodeCounter"));
    }
    regs.add(registerMBean(whiteboard, QueryEngineSettingsMBean.class, queryEngineSettings, QueryEngineSettingsMBean.TYPE, "settings"));
    regs.add(registerMBean(whiteboard, QueryStatsMBean.class, queryEngineSettings.getQueryStats(), QueryStatsMBean.TYPE, "Oak Query Statistics (Extended)"));
    // 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) {
            WorkspaceInitializer wi = sc.getWorkspaceInitializer();
            if (wi instanceof QueryIndexProviderAware) {
                ((QueryIndexProviderAware) wi).setQueryIndexProvider(indexProvider);
            }
            return wi;
        }
    });
    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) Executor(java.util.concurrent.Executor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) 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) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) IndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider) OrderedPropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.OrderedPropertyIndexEditorProvider) 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) QueryIndexProviderAware(org.apache.jackrabbit.oak.spi.query.QueryIndexProviderAware) 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) QueryStatsMBean(org.apache.jackrabbit.oak.query.stats.QueryStatsMBean) 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) NodeCounterOld(org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounterOld) SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration)

Aggregations

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 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 AsyncIndexUpdate (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate)1 CompositeIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider)1 IndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider)1 IndexMBeanRegistration (org.apache.jackrabbit.oak.plugins.index.IndexMBeanRegistration)1 IndexUpdateProvider (org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider)1 NodeCounter (org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounter)1 NodeCounterMBean (org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounterMBean)1 NodeCounterOld (org.apache.jackrabbit.oak.plugins.index.counter.jmx.NodeCounterOld)1 OrderedPropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.OrderedPropertyIndexEditorProvider)1 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)1