@Test public void cleanerRegistration() throws Exception{ Map<String,Object> config = getDefaultConfig(); config.put("propIndexCleanerIntervalInSecs", 142); MockOsgi.activate(service, context.bundleContext(), config); ServiceReference[] sr = context.bundleContext().getAllServiceReferences(Runnable.class.getName(), "(scheduler.name="+ PropertyIndexCleaner.class.getName()+")"); assertEquals(sr.length, 1); assertEquals(142L, sr[0].getProperty("scheduler.period")); }
@Activate private void activate(BundleContext bundleContext, Map<String, ?> config) throws IOException { asyncIndexesSizeStatsUpdate = new AsyncIndexesSizeStatsUpdateImpl( PropertiesUtil.toLong(config.get(LUCENE_INDEX_STATS_UPDATE_INTERVAL), LUCENE_INDEX_STATS_UPDATE_INTERVAL_DEFAULT) * 1000); boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT); hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT); if (disabled) { log.info("Component disabled by configuration"); return; } configureIndexDefinitionStorage(config); configureBooleanClauseLimit(config); initializeFactoryClassLoaders(getClass().getClassLoader()); if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) { BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean( config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT)); } else { log.info("Not setting config for single blob for an index file as it's set by command line!"); } whiteboard = new OsgiWhiteboard(bundleContext); threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT); initializeIndexDir(bundleContext, config); initializeExtractedTextCache(bundleContext, config, statisticsProvider); tracker = createTracker(bundleContext, config); indexProvider = new LuceneIndexProvider(tracker, augmentorFactory); initializeActiveBlobCollector(whiteboard, config); initializeLogging(config); initialize(); regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null)); registerObserver(bundleContext, config); registerLocalIndexObserver(bundleContext, tracker, config); registerIndexInfoProvider(bundleContext); registerIndexImporterProvider(bundleContext); registerPropertyIndexCleaner(config, bundleContext); LuceneIndexMBeanImpl mBean = new LuceneIndexMBeanImpl(tracker, nodeStore, indexPathService, getIndexCheckDir(), cleaner); oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, mBean, LuceneIndexMBean.TYPE, "Lucene Index statistics")); registerGCMonitor(whiteboard, tracker); registerIndexEditor(bundleContext, tracker, mBean, config); LuceneIndexFileSystemStatistics luceneIndexFSStats = new LuceneIndexFileSystemStatistics(statisticsProvider, indexCopier); registerLuceneFileSystemStats(luceneIndexFSStats, PropertiesUtil.toLong(config.get(PROP_INDEX_FILESYSTEM_STATS_INTERVAL),PROP_INDEX_FILESYSTEM_STATS_INTERVAL_DEFAULT)); }
LuceneIndexProviderService { @Activate private void activate(BundleContext bundleContext, Map<String, ?> config) throws IOException { asyncIndexesSizeStatsUpdate = new AsyncIndexesSizeStatsUpdateImpl( PropertiesUtil.toLong(config.get(LUCENE_INDEX_STATS_UPDATE_INTERVAL), LUCENE_INDEX_STATS_UPDATE_INTERVAL_DEFAULT) * 1000); boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT); hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT); if (disabled) { log.info("Component disabled by configuration"); return; } configureIndexDefinitionStorage(config); configureBooleanClauseLimit(config); initializeFactoryClassLoaders(getClass().getClassLoader()); if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) { BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean( config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT)); } else { log.info("Not setting config for single blob for an index file as it's set by command line!"); } whiteboard = new OsgiWhiteboard(bundleContext); threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT); initializeIndexDir(bundleContext, config); initializeExtractedTextCache(bundleContext, config, statisticsProvider); tracker = createTracker(bundleContext, config); indexProvider = new LuceneIndexProvider(tracker, augmentorFactory); initializeActiveBlobCollector(whiteboard, config); initializeLogging(config); initialize(); regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null)); registerObserver(bundleContext, config); registerLocalIndexObserver(bundleContext, tracker, config); registerIndexInfoProvider(bundleContext); registerIndexImporterProvider(bundleContext); registerPropertyIndexCleaner(config, bundleContext); LuceneIndexMBeanImpl mBean = new LuceneIndexMBeanImpl(tracker, nodeStore, indexPathService, getIndexCheckDir(), cleaner); oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, mBean, LuceneIndexMBean.TYPE, "Lucene Index statistics")); registerGCMonitor(whiteboard, tracker); registerIndexEditor(bundleContext, tracker, mBean, config); LuceneIndexFileSystemStatistics luceneIndexFSStats = new LuceneIndexFileSystemStatistics(statisticsProvider, indexCopier); registerLuceneFileSystemStats(luceneIndexFSStats, PropertiesUtil.toLong(config.get(PROP_INDEX_FILESYSTEM_STATS_INTERVAL),PROP_INDEX_FILESYSTEM_STATS_INTERVAL_DEFAULT)); } }
LuceneIndexProviderService { @Activate private void activate(BundleContext bundleContext, Map<String, ?> config) throws IOException { asyncIndexesSizeStatsUpdate = new AsyncIndexesSizeStatsUpdateImpl( PropertiesUtil.toLong(config.get(LUCENE_INDEX_STATS_UPDATE_INTERVAL), LUCENE_INDEX_STATS_UPDATE_INTERVAL_DEFAULT) * 1000); boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT); hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT); if (disabled) { log.info("Component disabled by configuration"); return; } configureIndexDefinitionStorage(config); configureBooleanClauseLimit(config); initializeFactoryClassLoaders(getClass().getClassLoader()); if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) { BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean( config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT)); } else { log.info("Not setting config for single blob for an index file as it's set by command line!"); } whiteboard = new OsgiWhiteboard(bundleContext); threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT); initializeIndexDir(bundleContext, config); initializeExtractedTextCache(bundleContext, config, statisticsProvider); tracker = createTracker(bundleContext, config); indexProvider = new LuceneIndexProvider(tracker, augmentorFactory); initializeActiveBlobCollector(whiteboard, config); initializeLogging(config); initialize(); regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null)); registerObserver(bundleContext, config); registerLocalIndexObserver(bundleContext, tracker, config); registerIndexInfoProvider(bundleContext); registerIndexImporterProvider(bundleContext); registerPropertyIndexCleaner(config, bundleContext); LuceneIndexMBeanImpl mBean = new LuceneIndexMBeanImpl(tracker, nodeStore, indexPathService, getIndexCheckDir(), cleaner); oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, mBean, LuceneIndexMBean.TYPE, "Lucene Index statistics")); registerGCMonitor(whiteboard, tracker); registerIndexEditor(bundleContext, tracker, mBean, config); LuceneIndexFileSystemStatistics luceneIndexFSStats = new LuceneIndexFileSystemStatistics(statisticsProvider, indexCopier); registerLuceneFileSystemStats(luceneIndexFSStats, PropertiesUtil.toLong(config.get(PROP_INDEX_FILESYSTEM_STATS_INTERVAL),PROP_INDEX_FILESYSTEM_STATS_INTERVAL_DEFAULT)); }  }
LuceneIndexProviderService { @Activate private void activate(BundleContext bundleContext, Map<String, ?> config) throws IOException { asyncIndexesSizeStatsUpdate = new AsyncIndexesSizeStatsUpdateImpl( PropertiesUtil.toLong(config.get(LUCENE_INDEX_STATS_UPDATE_INTERVAL), LUCENE_INDEX_STATS_UPDATE_INTERVAL_DEFAULT) * 1000); boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT); hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT); if (disabled) { log.info("Component disabled by configuration"); return; } configureIndexDefinitionStorage(config); configureBooleanClauseLimit(config); initializeFactoryClassLoaders(getClass().getClassLoader()); if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) { BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean( config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT)); } else { log.info("Not setting config for single blob for an index file as it's set by command line!"); } whiteboard = new OsgiWhiteboard(bundleContext); threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT); initializeIndexDir(bundleContext, config); initializeExtractedTextCache(bundleContext, config, statisticsProvider); tracker = createTracker(bundleContext, config); indexProvider = new LuceneIndexProvider(tracker, augmentorFactory); initializeActiveBlobCollector(whiteboard, config); initializeLogging(config); initialize(); regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null)); registerObserver(bundleContext, config); registerLocalIndexObserver(bundleContext, tracker, config); registerIndexInfoProvider(bundleContext); registerIndexImporterProvider(bundleContext); registerPropertyIndexCleaner(config, bundleContext); LuceneIndexMBeanImpl mBean = new LuceneIndexMBeanImpl(tracker, nodeStore, indexPathService, getIndexCheckDir(), cleaner); oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, mBean, LuceneIndexMBean.TYPE, "Lucene Index statistics")); registerGCMonitor(whiteboard, tracker); registerIndexEditor(bundleContext, tracker, mBean, config); LuceneIndexFileSystemStatistics luceneIndexFSStats = new LuceneIndexFileSystemStatistics(statisticsProvider, indexCopier); registerLuceneFileSystemStats(luceneIndexFSStats, PropertiesUtil.toLong(config.get(PROP_INDEX_FILESYSTEM_STATS_INTERVAL),PROP_INDEX_FILESYSTEM_STATS_INTERVAL_DEFAULT)); }   }
LuceneIndexProviderService { @Activate private void activate(BundleContext bundleContext, Map<String, ?> config) throws IOException { asyncIndexesSizeStatsUpdate = new AsyncIndexesSizeStatsUpdateImpl( PropertiesUtil.toLong(config.get(LUCENE_INDEX_STATS_UPDATE_INTERVAL), LUCENE_INDEX_STATS_UPDATE_INTERVAL_DEFAULT) * 1000); boolean disabled = PropertiesUtil.toBoolean(config.get(PROP_DISABLED), PROP_DISABLED_DEFAULT); hybridIndex = PropertiesUtil.toBoolean(config.get(PROP_HYBRID_INDEXING), PROP_DISABLED_DEFAULT); if (disabled) { log.info("Component disabled by configuration"); return; } configureIndexDefinitionStorage(config); configureBooleanClauseLimit(config); initializeFactoryClassLoaders(getClass().getClassLoader()); if (System.getProperty(BufferedOakDirectory.ENABLE_WRITING_SINGLE_BLOB_INDEX_FILE_PARAM) == null) { BufferedOakDirectory.setEnableWritingSingleBlobIndexFile(PropertiesUtil.toBoolean( config.get(PROP_NAME_ENABLE_SINGLE_BLOB_PER_INDEX_FILE), PROP_ENABLE_SINGLE_BLOB_PER_INDEX_FILE_DEFAULT)); } else { log.info("Not setting config for single blob for an index file as it's set by command line!"); } whiteboard = new OsgiWhiteboard(bundleContext); threadPoolSize = PropertiesUtil.toInteger(config.get(PROP_THREAD_POOL_SIZE), PROP_THREAD_POOL_SIZE_DEFAULT); initializeIndexDir(bundleContext, config); initializeExtractedTextCache(bundleContext, config, statisticsProvider); tracker = createTracker(bundleContext, config); indexProvider = new LuceneIndexProvider(tracker, augmentorFactory); initializeActiveBlobCollector(whiteboard, config); initializeLogging(config); initialize(); regs.add(bundleContext.registerService(QueryIndexProvider.class.getName(), indexProvider, null)); registerObserver(bundleContext, config); registerLocalIndexObserver(bundleContext, tracker, config); registerIndexInfoProvider(bundleContext); registerIndexImporterProvider(bundleContext); registerPropertyIndexCleaner(config, bundleContext); LuceneIndexMBeanImpl mBean = new LuceneIndexMBeanImpl(tracker, nodeStore, indexPathService, getIndexCheckDir(), cleaner); oakRegs.add(registerMBean(whiteboard, LuceneIndexMBean.class, mBean, LuceneIndexMBean.TYPE, "Lucene Index statistics")); registerGCMonitor(whiteboard, tracker); registerIndexEditor(bundleContext, tracker, mBean, config); LuceneIndexFileSystemStatistics luceneIndexFSStats = new LuceneIndexFileSystemStatistics(statisticsProvider, indexCopier); registerLuceneFileSystemStats(luceneIndexFSStats, PropertiesUtil.toLong(config.get(PROP_INDEX_FILESYSTEM_STATS_INTERVAL),PROP_INDEX_FILESYSTEM_STATS_INTERVAL_DEFAULT)); }   static final String REPOSITORY_HOME; static final long PROP_HYBRID_QUEUE_TIMEOUT_DEFAULT; }