private static boolean hasDynamicMembership(ServiceReference reference) { return PropertiesUtil.toBoolean(reference.getProperty(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP), DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP_DEFAULT); }
@Activate private void activate(BundleContext bundleContext, Map<String, ?> config) { failOnDetection = PropertiesUtil.toBoolean(config.get(PROP_FAIL_ON_DETECTION), false); }
@Activate private void activate(BundleContext bundleContext, Map<String, ?> config) { failOnDetection = PropertiesUtil.toBoolean(config.get(PROP_FAIL_ON_DETECTION), true); if (mountInfoProvider.hasNonDefaultMounts()) { serviceRegistration = bundleContext.registerService(EditorProvider.class.getName(), this, null); logger.info("Enabling PrivateStoreValidatorProvider with failOnDetection {}", failOnDetection); } }
private void configureIndexDefinitionStorage(Map<String, ?> config) { boolean disableStorage = PropertiesUtil.toBoolean(config.get(PROP_DISABLE_STORED_INDEX_DEFINITION), PROP_DISABLE_DEFN_STORAGE_DEFAULT); if (disableStorage){ log.info("Feature to ensure that index definition matches the index state is disabled. Change in " + "index definition would now affect query plans and might lead to inconsistent results."); IndexDefinition.setDisableStoredIndexDefinition(disableStorage); } }
@Activate protected void activate(ComponentContext context, Map<String, ?> config) throws IOException, CommitFailedException { this.context = context; seedMount = PropertiesUtil.toString(config.get(PROP_SEED_MOUNT), null); pathStats = PropertiesUtil.toBoolean(config.get(PATH_STATS), false); enableChecks = PropertiesUtil.toBoolean(config.get(ENABLE_CHECKS), true); registerCompositeNodeStore(); }
private void initializeLogging(Map<String, ?> config) { boolean debug = PropertiesUtil.toBoolean(config.get(PROP_DEBUG), false); if (debug) { InfoStream.setDefault(LoggingInfoStream.INSTANCE); log.info("Registered LoggingInfoStream with Lucene. Lucene logs can be enabled " + "now via category [{}]", LoggingInfoStream.PREFIX); } }
private void initializeLogging(Map<String, ?> config) { boolean debug = PropertiesUtil.toBoolean(config.get(PROP_DEBUG), false); if (debug) { InfoStream.setDefault(LoggingInfoStream.INSTANCE); log.info("Registered LoggingInfoStream with Lucene. Lucene logs can be enabled " + "now via category [{}]", LoggingInfoStream.PREFIX); } }
private void configureIndexDefinitionStorage(Map<String, ?> config) { boolean disableStorage = PropertiesUtil.toBoolean(config.get(PROP_DISABLE_STORED_INDEX_DEFINITION), PROP_DISABLE_DEFN_STORAGE_DEFAULT); if (disableStorage){ log.info("Feature to ensure that index definition matches the index state is disabled. Change in " + "index definition would now affect query plans and might lead to inconsistent results."); IndexDefinition.setDisableStoredIndexDefinition(disableStorage); } }
@SuppressWarnings("UnusedDeclaration") @Activate protected void activate(ComponentContext componentContext) { Object value = componentContext.getProperties().get(QUERY_TIME_AGGREGATION); boolean queryTimeAggregation = PropertiesUtil.toBoolean(value, QUERY_TIME_AGGREGATION_DEFAULT); if (solrServerProvider != null && oakSolrConfigurationProvider != null) { QueryIndexProvider solrQueryIndexProvider = new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider, nodeAggregator); log.debug("creating Solr query index provider {} query time aggregation", queryTimeAggregation ? "with" : "without"); if (queryTimeAggregation) { solrQueryIndexProvider = AggregateIndexProvider.wrap(solrQueryIndexProvider); } regs.add(componentContext.getBundleContext().registerService(QueryIndexProvider.class.getName(), solrQueryIndexProvider, null)); } }
@SuppressWarnings("UnusedDeclaration") @Activate protected void activate(ComponentContext componentContext) { Object value = componentContext.getProperties().get(QUERY_TIME_AGGREGATION); boolean queryTimeAggregation = PropertiesUtil.toBoolean(value, QUERY_TIME_AGGREGATION_DEFAULT); if (solrServerProvider != null && oakSolrConfigurationProvider != null) { QueryIndexProvider solrQueryIndexProvider = new SolrQueryIndexProvider(solrServerProvider, oakSolrConfigurationProvider, nodeAggregator); log.debug("creating Solr query index provider {} query time aggregation", queryTimeAggregation ? "with" : "without"); if (queryTimeAggregation) { solrQueryIndexProvider = AggregateIndexProvider.wrap(solrQueryIndexProvider); } regs.add(componentContext.getBundleContext().registerService(QueryIndexProvider.class.getName(), solrQueryIndexProvider, null)); } }
@Activate protected void activate(ComponentContext componentContext) throws Exception { boolean enabled = PropertiesUtil.toBoolean(componentContext.getProperties().get(ENABLED), false); if (enabled) { BundleContext bundleContext = componentContext.getBundleContext(); Whiteboard whiteboard = new OsgiWhiteboard(bundleContext); executor = new WhiteboardExecutor(); executor.start(whiteboard); backgroundObserver = new BackgroundObserver(nodeStateSolrServersObserver, executor, 5); regs.add(bundleContext.registerService(Observer.class.getName(), backgroundObserver, null)); } }
@Activate protected void activate(ComponentContext componentContext) throws Exception { boolean enabled = PropertiesUtil.toBoolean(componentContext.getProperties().get(ENABLED), false); if (enabled) { BundleContext bundleContext = componentContext.getBundleContext(); Whiteboard whiteboard = new OsgiWhiteboard(bundleContext); executor = new WhiteboardExecutor(); executor.start(whiteboard); backgroundObserver = new BackgroundObserver(nodeStateSolrServersObserver, executor, 5); regs.add(bundleContext.registerService(Observer.class.getName(), backgroundObserver, null)); } }
private void bootstrapMaster(ComponentContext context) throws CertificateException, SSLException { Dictionary<?, ?> props = context.getProperties(); int port = PropertiesUtil.toInteger(props.get(PORT), PORT_DEFAULT); String[] ranges = PropertiesUtil.toStringArray(props.get(ALLOWED_CLIENT_IP_RANGES), ALLOWED_CLIENT_IP_RANGES_DEFAULT); boolean secure = PropertiesUtil.toBoolean(props.get(SECURE), SECURE_DEFAULT); primary = new StandbyServer(port, segmentStore, ranges, secure); primary.start(); log.info("started primary on port {} with allowed ip ranges {}.", port, ranges); }
@Override public Future addingService(ServiceReference<Runnable> reference) { Runnable runnable = context.getService(reference); long period = PropertiesUtil.toLong(reference.getProperty("scheduler.period"), -1); boolean concurrent = PropertiesUtil.toBoolean(reference.getProperty("scheduler.concurrent"), false); Future future = null; if (period != -1) { if (concurrent) { future = getExecutor().scheduleAtFixedRate( runnable, period, period, TimeUnit.SECONDS); } else { future = getExecutor().scheduleWithFixedDelay( runnable, period, period, TimeUnit.SECONDS); } } return future; }
private void registerObserver(BundleContext bundleContext, Map<String, ?> config) { boolean enableAsyncIndexOpen = PropertiesUtil.toBoolean(config.get(PROP_ASYNC_INDEX_OPEN), true); Observer observer = indexProvider; if (enableAsyncIndexOpen) { backgroundObserver = new BackgroundObserver(indexProvider, getExecutorService(), 5); observer = backgroundObserver; oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, backgroundObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneIndexConfigObserver queue stats")); log.info("Registering the LuceneIndexProvider as a BackgroundObserver"); } regs.add(bundleContext.registerService(Observer.class.getName(), observer, null)); }
private void registerObserver(BundleContext bundleContext, Map<String, ?> config) { boolean enableAsyncIndexOpen = PropertiesUtil.toBoolean(config.get(PROP_ASYNC_INDEX_OPEN), true); Observer observer = indexProvider; if (enableAsyncIndexOpen) { backgroundObserver = new BackgroundObserver(indexProvider, getExecutorService(), 5); observer = backgroundObserver; oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, backgroundObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneIndexConfigObserver queue stats")); log.info("Registering the LuceneIndexProvider as a BackgroundObserver"); } regs.add(bundleContext.registerService(Observer.class.getName(), observer, null)); }
private void initializeIndexCopier(BundleContext bundleContext, Map<String, ?> config) throws IOException { if(indexCopier != null){ return; } boolean prefetchEnabled = PropertiesUtil.toBoolean(config.get(PROP_PREFETCH_INDEX_FILES), PROP_PREFETCH_INDEX_FILES_DEFAULT); if (prefetchEnabled){ log.info("Prefetching of index files enabled. Index would be opened after copying all new files locally"); } indexCopier = new IndexCopier(getExecutorService(), indexDir, prefetchEnabled); oakRegs.add(registerMBean(whiteboard, CopyOnReadStatsMBean.class, indexCopier, CopyOnReadStatsMBean.TYPE, "IndexCopier support statistics")); }
private void initializeIndexCopier(BundleContext bundleContext, Map<String, ?> config) throws IOException { if(indexCopier != null){ return; } boolean prefetchEnabled = PropertiesUtil.toBoolean(config.get(PROP_PREFETCH_INDEX_FILES), PROP_PREFETCH_INDEX_FILES_DEFAULT); if (prefetchEnabled){ log.info("Prefetching of index files enabled. Index would be opened after copying all new files locally"); } indexCopier = new IndexCopier(getExecutorService(), indexDir, prefetchEnabled); oakRegs.add(registerMBean(whiteboard, CopyOnReadStatsMBean.class, indexCopier, CopyOnReadStatsMBean.TYPE, "IndexCopier support statistics")); }
private void startBundles(PojoServiceRegistry registry, String bundleFilter, Map config) { try { if (bundleFilter == null){ bundleFilter = REPOSITORY_BUNDLE_FILTER_DEFAULT; } List<BundleDescriptor> descriptors = new ClasspathScanner().scanForBundles(bundleFilter); descriptors = Lists.newArrayList(descriptors); if (PropertiesUtil.toBoolean(config.get(REPOSITORY_ENV_SPRING_BOOT), false)){ descriptors = SpringBootSupport.processDescriptors(descriptors); } descriptors = processDescriptors(descriptors); registry.startBundles(descriptors); } catch (Exception e) { throw new RuntimeException(e); } }
@Test public void testToBoolean() { assertEquals(true, PropertiesUtil.toBoolean(null, true)); assertEquals(false, PropertiesUtil.toBoolean(1.0, true)); assertEquals(false, PropertiesUtil.toBoolean(false, true)); assertEquals(false, PropertiesUtil.toBoolean("false", true)); assertEquals(false, PropertiesUtil.toBoolean("abc", true)); }