Index: oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (revision 1777538) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (working copy) @@ -60,6 +60,7 @@ import org.apache.jackrabbit.oak.api.ContentSession; import org.apache.jackrabbit.oak.api.Descriptors; import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.api.jmx.IndexStatsMBean; import org.apache.jackrabbit.oak.api.jmx.QueryEngineSettingsMBean; import org.apache.jackrabbit.oak.api.jmx.RepositoryManagementMBean; import org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser; @@ -154,9 +155,12 @@ private final Closer closer = Closer.create(); private ContentRepository contentRepository; - + private Clusterable clusterable; + //TODO make false!! + private boolean registerPropertyIndexAsyncReindex = true; + /** * Default {@code ScheduledExecutorService} used for scheduling background tasks. * This default spawns up to 32 background thread on an as need basis. Idle @@ -607,6 +611,15 @@ return this; } + /** + * Registers the PropertyIndexAsyncReindexMBean mbean exposing the option to + * asynchronously reindex syncronous property indexes. + */ + public Oak withPropertyIndexAsyncReindex() { + registerPropertyIndexAsyncReindex = true; + return this; + } + @Nonnull public Whiteboard getWhiteboard() { return this.whiteboard; @@ -652,13 +665,19 @@ indexRegistration.registerAsyncIndexer(task, t.getValue()); closer.register(task); } + // backwards compatibility + registerPropertyIndexAsyncReindex = true; + } - PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex( - new AsyncIndexUpdate(IndexConstants.ASYNC_REINDEX_VALUE, - store, indexEditors, true), getExecutor()); + if (registerPropertyIndexAsyncReindex) { + String name = IndexConstants.ASYNC_REINDEX_VALUE; + AsyncIndexUpdate task = new AsyncIndexUpdate(name, store, indexEditors, true); + PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(task, getExecutor()); regs.add(registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async")); + regs.add(registerMBean(whiteboard, IndexStatsMBean.class, + task.getIndexStats(), IndexStatsMBean.TYPE, name)); } regs.add(registerMBean(whiteboard, NodeCounterMBean.class,