Search in sources :

Example 1 with CompositeRegistration

use of org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration in project jackrabbit-oak by apache.

the class AsyncIndexerService method registerAsyncReindexSupport.

private void registerAsyncReindexSupport(Whiteboard whiteboard) {
    // async reindex
    String name = IndexConstants.ASYNC_REINDEX_VALUE;
    AsyncIndexUpdate task = new AsyncIndexUpdate(name, nodeStore, indexEditorProvider, statisticsProvider, true);
    PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(task, executor);
    final Registration reg = new CompositeRegistration(registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"), registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, name));
    closer.register(new Closeable() {

        @Override
        public void close() throws IOException {
            reg.unregister();
        }
    });
}
Also used : CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) IndexStatsMBean(org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean) Closeable(java.io.Closeable) PropertyIndexAsyncReindex(org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindex) IOException(java.io.IOException) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) PropertyIndexAsyncReindexMBean(org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindexMBean)

Example 2 with CompositeRegistration

use of org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration in project jackrabbit-oak by apache.

the class SegmentCompactionIT method setUp.

@Before
public void setUp() throws Exception {
    assumeTrue(ENABLED);
    ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
    MetricStatisticsProvider statisticsProvider = new MetricStatisticsProvider(mBeanServer, executor);
    SegmentGCOptions gcOptions = defaultGCOptions().setEstimationDisabled(true).setForceTimeout(3600);
    FileStoreBuilder builder = fileStoreBuilder(folder.getRoot());
    fileStore = builder.withMemoryMapping(true).withGCMonitor(gcMonitor).withGCOptions(gcOptions).withIOMonitor(new MetricsIOMonitor(statisticsProvider)).withStatisticsProvider(statisticsProvider).build();
    nodeStore = SegmentNodeStoreBuilders.builder(fileStore).withStatisticsProvider(statisticsProvider).build();
    WriterCacheManager cacheManager = builder.getCacheManager();
    Runnable cancelGC = new Runnable() {

        @Override
        public void run() {
            fileStore.cancelGC();
        }
    };
    Supplier<String> status = new Supplier<String>() {

        @Override
        public String get() {
            return fileStoreGCMonitor.getStatus();
        }
    };
    List<Registration> registrations = newArrayList();
    registrations.add(registerMBean(segmentCompactionMBean, new ObjectName("IT:TYPE=Segment Compaction")));
    registrations.add(registerMBean(new SegmentRevisionGCMBean(fileStore, gcOptions, fileStoreGCMonitor), new ObjectName("IT:TYPE=Segment Revision GC")));
    registrations.add(registerMBean(new RevisionGC(fileStore.getGCRunner(), cancelGC, status, executor), new ObjectName("IT:TYPE=Revision GC")));
    CacheStatsMBean segmentCacheStats = fileStore.getSegmentCacheStats();
    registrations.add(registerMBean(segmentCacheStats, new ObjectName("IT:TYPE=" + segmentCacheStats.getName())));
    CacheStatsMBean stringCacheStats = fileStore.getStringCacheStats();
    registrations.add(registerMBean(stringCacheStats, new ObjectName("IT:TYPE=" + stringCacheStats.getName())));
    CacheStatsMBean templateCacheStats = fileStore.getTemplateCacheStats();
    registrations.add(registerMBean(templateCacheStats, new ObjectName("IT:TYPE=" + templateCacheStats.getName())));
    CacheStatsMBean stringDeduplicationCacheStats = cacheManager.getStringCacheStats();
    assertNotNull(stringDeduplicationCacheStats);
    registrations.add(registerMBean(stringDeduplicationCacheStats, new ObjectName("IT:TYPE=" + stringDeduplicationCacheStats.getName())));
    CacheStatsMBean templateDeduplicationCacheStats = cacheManager.getTemplateCacheStats();
    assertNotNull(templateDeduplicationCacheStats);
    registrations.add(registerMBean(templateDeduplicationCacheStats, new ObjectName("IT:TYPE=" + templateDeduplicationCacheStats.getName())));
    CacheStatsMBean nodeDeduplicationCacheStats = cacheManager.getNodeCacheStats();
    assertNotNull(nodeDeduplicationCacheStats);
    registrations.add(registerMBean(nodeDeduplicationCacheStats, new ObjectName("IT:TYPE=" + nodeDeduplicationCacheStats.getName())));
    registrations.add(registerMBean(nodeStore.getStats(), new ObjectName("IT:TYPE=" + "SegmentNodeStore statistics")));
    mBeanRegistration = new CompositeRegistration(registrations);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ListeningScheduledExecutorService(com.google.common.util.concurrent.ListeningScheduledExecutorService) SegmentGCOptions(org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions) MetricsIOMonitor(org.apache.jackrabbit.oak.segment.file.MetricsIOMonitor) ObjectName(javax.management.ObjectName) RevisionGC(org.apache.jackrabbit.oak.spi.state.RevisionGC) SegmentRevisionGC(org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGC) SegmentRevisionGCMBean(org.apache.jackrabbit.oak.segment.compaction.SegmentRevisionGCMBean) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) CacheStatsMBean(org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean) MetricStatisticsProvider(org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) Supplier(com.google.common.base.Supplier) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Before(org.junit.Before)

Example 3 with CompositeRegistration

use of org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration 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 4 with CompositeRegistration

use of org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration in project jackrabbit-oak by apache.

the class ChangeProcessor method start.

/**
     * Start this change processor
     * @param whiteboard  the whiteboard instance to used for scheduling individual
     *                    runs of this change processor.
     * @throws IllegalStateException if started already
     */
public synchronized void start(Whiteboard whiteboard) {
    checkState(registration == null, "Change processor started already");
    final WhiteboardExecutor executor = new WhiteboardExecutor();
    executor.start(whiteboard);
    final FilteringObserver filteringObserver = createObserver(executor);
    listenerId = COUNTER.incrementAndGet() + "";
    Map<String, String> attrs = ImmutableMap.of(LISTENER_ID, listenerId);
    String name = tracker.toString();
    registration = new CompositeRegistration(whiteboard.register(Observer.class, filteringObserver, emptyMap()), registerMBean(whiteboard, EventListenerMBean.class, tracker.getListenerMBean(), "EventListener", name, attrs), registerMBean(whiteboard, BackgroundObserverMBean.class, filteringObserver.getBackgroundObserver().getMBean(), BackgroundObserverMBean.TYPE, name, attrs), registerMBean(whiteboard, ChangeProcessorMBean.class, getMBean(), ChangeProcessorMBean.TYPE, name, attrs), // re-registered
    registerMBean(whiteboard, FilterConfigMBean.class, filterProvider.get().getConfigMBean(), FilterConfigMBean.TYPE, name, attrs), new Registration() {

        @Override
        public void unregister() {
            filteringObserver.close();
        }
    }, new Registration() {

        @Override
        public void unregister() {
            executor.stop();
        }
    }, scheduleWithFixedDelay(whiteboard, new Runnable() {

        @Override
        public void run() {
            tracker.recordOneSecond();
        }
    }, 1));
}
Also used : CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration) Registration(org.apache.jackrabbit.oak.spi.whiteboard.Registration) FilteringObserver(org.apache.jackrabbit.oak.plugins.observation.FilteringObserver) WhiteboardExecutor(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor) CompositeRegistration(org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration)

Aggregations

CompositeRegistration (org.apache.jackrabbit.oak.spi.whiteboard.CompositeRegistration)4 Registration (org.apache.jackrabbit.oak.spi.whiteboard.Registration)4 PropertyIndexAsyncReindex (org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindex)2 PropertyIndexAsyncReindexMBean (org.apache.jackrabbit.oak.plugins.index.property.jmx.PropertyIndexAsyncReindexMBean)2 Supplier (com.google.common.base.Supplier)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ListeningScheduledExecutorService (com.google.common.util.concurrent.ListeningScheduledExecutorService)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Executor (java.util.concurrent.Executor)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 ObjectName (javax.management.ObjectName)1 Descriptors (org.apache.jackrabbit.oak.api.Descriptors)1 CacheStatsMBean (org.apache.jackrabbit.oak.api.jmx.CacheStatsMBean)1 IndexStatsMBean (org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean)1 QueryEngineSettingsMBean (org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean)1 RepositoryManagementMBean (org.apache.jackrabbit.oak.api.jmx.RepositoryManagementMBean)1