@Activate public void activate(BundleContext bundleContext, Configuration config) { List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(config.asyncConfigs()); Whiteboard whiteboard = new OsgiWhiteboard(bundleContext); indexRegistration = new IndexMBeanRegistration(whiteboard); indexEditorProvider.start(whiteboard); executor = new WhiteboardExecutor(); executor.start(whiteboard); long leaseTimeOutMin = config.leaseTimeOutMinutes(); if (!(nodeStore instanceof Clusterable)){ leaseTimeOutMin = 0; log.info("Detected non clusterable setup. Lease checking would be disabled for async indexing"); } TrackingCorruptIndexHandler corruptIndexHandler = createCorruptIndexHandler(config); for (AsyncConfig c : asyncIndexerConfig) { AsyncIndexUpdate task = new AsyncIndexUpdate(c.name, nodeStore, indexEditorProvider, statisticsProvider, false); task.setCorruptIndexHandler(corruptIndexHandler); task.setValidatorProviders(Collections.singletonList(validatorProvider)); task.setLeaseTimeOut(TimeUnit.MINUTES.toMillis(leaseTimeOutMin)); indexRegistration.registerAsyncIndexer(task, c.timeIntervalInSecs); closer.register(task); } registerAsyncReindexSupport(whiteboard); log.info("Configured async indexers {} ", asyncIndexerConfig); log.info("Lease time: {} mins and AsyncIndexUpdate configured with {}", leaseTimeOutMin, validatorProvider.getClass().getName()); }
@Activate public void activate(BundleContext bundleContext, Configuration config) { List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(config.asyncConfigs()); Whiteboard whiteboard = new OsgiWhiteboard(bundleContext); indexRegistration = new IndexMBeanRegistration(whiteboard); indexEditorProvider.start(whiteboard); executor = new WhiteboardExecutor(); executor.start(whiteboard); long leaseTimeOutMin = config.leaseTimeOutMinutes(); if (!(nodeStore instanceof Clusterable)){ leaseTimeOutMin = 0; log.info("Detected non clusterable setup. Lease checking would be disabled for async indexing"); } TrackingCorruptIndexHandler corruptIndexHandler = createCorruptIndexHandler(config); for (AsyncConfig c : asyncIndexerConfig) { AsyncIndexUpdate task = new AsyncIndexUpdate(c.name, nodeStore, indexEditorProvider, statisticsProvider, false); task.setCorruptIndexHandler(corruptIndexHandler); task.setValidatorProviders(Collections.singletonList(validatorProvider)); task.setLeaseTimeOut(TimeUnit.MINUTES.toMillis(leaseTimeOutMin)); indexRegistration.registerAsyncIndexer(task, c.timeIntervalInSecs); closer.register(task); } registerAsyncReindexSupport(whiteboard); log.info("Configured async indexers {} ", asyncIndexerConfig); log.info("Lease time: {} mins and AsyncIndexUpdate configured with {}", leaseTimeOutMin, validatorProvider.getClass().getName()); }
@Activate public void activate(BundleContext bundleContext, Configuration config) { List<AsyncConfig> asyncIndexerConfig = getAsyncConfig(config.asyncConfigs()); Whiteboard whiteboard = new OsgiWhiteboard(bundleContext); indexRegistration = new IndexMBeanRegistration(whiteboard); indexEditorProvider.start(whiteboard); executor = new WhiteboardExecutor(); executor.start(whiteboard); long leaseTimeOutMin = config.leaseTimeOutMinutes(); if (!(nodeStore instanceof Clusterable)){ leaseTimeOutMin = 0; log.info("Detected non clusterable setup. Lease checking would be disabled for async indexing"); } TrackingCorruptIndexHandler corruptIndexHandler = createCorruptIndexHandler(config); for (AsyncConfig c : asyncIndexerConfig) { AsyncIndexUpdate task = new AsyncIndexUpdate(c.name, nodeStore, indexEditorProvider, statisticsProvider, false); task.setCorruptIndexHandler(corruptIndexHandler); task.setValidatorProviders(Collections.singletonList(validatorProvider)); task.setLeaseTimeOut(TimeUnit.MINUTES.toMillis(leaseTimeOutMin)); indexRegistration.registerAsyncIndexer(task, c.timeIntervalInSecs); closer.register(task); } registerAsyncReindexSupport(whiteboard); log.info("Configured async indexers {} ", asyncIndexerConfig); log.info("Lease time: {} mins and AsyncIndexUpdate configured with {}", leaseTimeOutMin, validatorProvider.getClass().getName()); }
@Test public void validatorProviderInvocation() throws Exception{ MemoryNodeStore store = new MemoryNodeStore(); IndexEditorProvider provider = new PropertyIndexEditorProvider(); NodeBuilder builder = store.getRoot().builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, "async"); builder.child("testRoot").setProperty("foo", "abc"); // merge it back in store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider); CollectingValidatorProvider v = new CollectingValidatorProvider(); async.setValidatorProviders(ImmutableList.<ValidatorProvider>of(v)); async.run(); assertFalse(v.visitedPaths.isEmpty()); assertThat(v.visitedPaths, hasItem("/:async")); assertThat(v.visitedPaths, hasItem("/oak:index/rootIndex")); }