private void configureBooleanClauseLimit(Map<String, ?> config) { int booleanClauseLimit = PropertiesUtil.toInteger(config.get(PROP_BOOLEAN_CLAUSE_LIMIT), PROP_BOOLEAN_CLAUSE_LIMIT_DEFAULT); if (booleanClauseLimit != BooleanQuery.getMaxClauseCount()){ BooleanQuery.setMaxClauseCount(booleanClauseLimit); log.info("Changed the Max boolean clause limit to {}", booleanClauseLimit); } }
private DataStore getCachingDataStore(Properties props, ComponentContext context) { CachingFileDataStore dataStore = new CachingFileDataStore(); dataStore.setStagingSplitPercentage( PropertiesUtil.toInteger(props.get("stagingSplitPercentage"), 0)); dataStore.setProperties(props); Dictionary<String, Object> config = new Hashtable<String, Object>(); config.put(Constants.SERVICE_PID, dataStore.getClass().getName()); config.put(DESCRIPTION, getDescription()); delegateReg = context.getBundleContext().registerService(new String[] { AbstractSharedCachingDataStore.class.getName(), AbstractSharedCachingDataStore.class.getName() }, dataStore , config); return dataStore; }
private void configureBooleanClauseLimit(Map<String, ?> config) { int booleanClauseLimit = PropertiesUtil.toInteger(config.get(PROP_BOOLEAN_CLAUSE_LIMIT), PROP_BOOLEAN_CLAUSE_LIMIT_DEFAULT); if (booleanClauseLimit != BooleanQuery.getMaxClauseCount()){ BooleanQuery.setMaxClauseCount(booleanClauseLimit); log.info("Changed the Max boolean clause limit to {}", booleanClauseLimit); } }
private void bootstrapSlave(ComponentContext context) throws SSLException { Dictionary<?, ?> props = context.getProperties(); int port = PropertiesUtil.toInteger(props.get(PORT), PORT_DEFAULT); long interval = PropertiesUtil.toInteger(props.get(INTERVAL), INTERVAL_DEFAULT); String host = PropertiesUtil.toString(props.get(PRIMARY_HOST), PRIMARY_HOST_DEFAULT); boolean secure = PropertiesUtil.toBoolean(props.get(SECURE), SECURE_DEFAULT); int readTimeout = PropertiesUtil.toInteger(props.get(READ_TIMEOUT), READ_TIMEOUT_DEFAULT); boolean clean = PropertiesUtil.toBoolean(props.get(AUTO_CLEAN), AUTO_CLEAN_DEFAULT); sync = new StandbyClient(host, port, segmentStore, secure, readTimeout, clean); Dictionary<Object, Object> dictionary = new Hashtable<Object, Object>(); dictionary.put("scheduler.period", interval); dictionary.put("scheduler.concurrent", false); // dictionary.put("scheduler.runOn", "SINGLE"); syncReg = context.getBundleContext().registerService( Runnable.class.getName(), sync, dictionary); log.info("started standby sync with {}:{} at {} sec.", host, port, interval); } }
private DataStore getCachingDataStore(Properties props, ComponentContext context) { CachingFileDataStore dataStore = new CachingFileDataStore(); dataStore.setStagingSplitPercentage( PropertiesUtil.toInteger(props.get("stagingSplitPercentage"), 0)); dataStore.setProperties(props); Dictionary<String, Object> config = new Hashtable<String, Object>(); config.put(Constants.SERVICE_PID, dataStore.getClass().getName()); config.put(DESCRIPTION, getDescription()); delegateReg = context.getBundleContext().registerService(new String[] { AbstractSharedCachingDataStore.class.getName(), AbstractSharedCachingDataStore.class.getName() }, dataStore , config); return dataStore; }
private DataStore getCachingDataStore(Properties props, ComponentContext context) { CachingFileDataStore dataStore = new CachingFileDataStore(); dataStore.setStagingSplitPercentage( PropertiesUtil.toInteger(props.get("stagingSplitPercentage"), 0)); dataStore.setProperties(props); Dictionary<String, Object> config = new Hashtable<String, Object>(); config.put(Constants.SERVICE_PID, dataStore.getClass().getName()); config.put(DESCRIPTION, getDescription()); delegateReg = context.getBundleContext().registerService(new String[] { AbstractSharedCachingDataStore.class.getName(), AbstractSharedCachingDataStore.class.getName() }, dataStore , config); return dataStore; }
private void registerPropertyIndexCleaner(Map<String, ?> config, BundleContext bundleContext) { int cleanerInterval = PropertiesUtil.toInteger(config.get(PROP_INDEX_CLEANER_INTERVAL), PROP_INDEX_CLEANER_INTERVAL_DEFAULT); if (cleanerInterval <= 0) { log.info("Property index cleaner would not be registered"); return; } cleaner = new PropertyIndexCleaner(nodeStore, indexPathService, asyncIndexInfoService, statisticsProvider); //Proxy check for DocumentNodeStore if (nodeStore instanceof Clusterable) { cleaner.setRecursiveDelete(true); log.info("PropertyIndexCleaner configured to perform recursive delete"); } oakRegs.add(scheduleWithFixedDelay(whiteboard, cleaner, ImmutableMap.of("scheduler.name", PropertyIndexCleaner.class.getName()), cleanerInterval, true, true)); log.info("Property index cleaner configured to run every [{}] seconds", cleanerInterval); }
private void registerPropertyIndexCleaner(Map<String, ?> config, BundleContext bundleContext) { int cleanerInterval = PropertiesUtil.toInteger(config.get(PROP_INDEX_CLEANER_INTERVAL), PROP_INDEX_CLEANER_INTERVAL_DEFAULT); if (cleanerInterval <= 0) { log.info("Property index cleaner would not be registered"); return; } cleaner = new PropertyIndexCleaner(nodeStore, indexPathService, asyncIndexInfoService, statisticsProvider); //Proxy check for DocumentNodeStore if (nodeStore instanceof Clusterable) { cleaner.setRecursiveDelete(true); log.info("PropertyIndexCleaner configured to perform recursive delete"); } oakRegs.add(scheduleWithFixedDelay(whiteboard, cleaner, ImmutableMap.of("scheduler.name", PropertyIndexCleaner.class.getName()), cleanerInterval, true, true)); log.info("Property index cleaner configured to run every [{}] seconds", cleanerInterval); }
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); }
public static RetryPolicy getRetryPolicy(final String maxRequestRetry) { int retries = PropertiesUtil.toInteger(maxRequestRetry, -1); if (retries < 0) { return null; } if (retries == 0) { return new RetryNoRetry(); } return new RetryExponentialRetry(RetryPolicy.DEFAULT_CLIENT_BACKOFF, retries); }
private void initializeExtractedTextCache(BundleContext bundleContext, Map<String, ?> config) { int cacheSizeInMB = PropertiesUtil.toInteger(config.get(PROP_EXTRACTED_TEXT_CACHE_SIZE), PROP_EXTRACTED_TEXT_CACHE_SIZE_DEFAULT); int cacheExpiryInSecs = PropertiesUtil.toInteger(config.get(PROP_EXTRACTED_TEXT_CACHE_EXPIRY), PROP_EXTRACTED_TEXT_CACHE_EXPIRY_DEFAULT); boolean alwaysUsePreExtractedCache = PropertiesUtil.toBoolean(config.get(PROP_PRE_EXTRACTED_TEXT_ALWAYS_USE), PROP_PRE_EXTRACTED_TEXT_ALWAYS_USE_DEFAULT); extractedTextCache = new ExtractedTextCache( cacheSizeInMB * ONE_MB, cacheExpiryInSecs, alwaysUsePreExtractedCache, indexDir); if (extractedTextProvider != null){ registerExtractedTextProvider(extractedTextProvider); } CacheStats stats = extractedTextCache.getCacheStats(); if (stats != null){ oakRegs.add(registerMBean(whiteboard, CacheStatsMBean.class, stats, CacheStatsMBean.TYPE, stats.getName())); log.info("Extracted text caching enabled with maxSize {} MB, expiry time {} secs", cacheSizeInMB, cacheExpiryInSecs); } }
private void initializeExtractedTextCache(BundleContext bundleContext, Map<String, ?> config) { int cacheSizeInMB = PropertiesUtil.toInteger(config.get(PROP_EXTRACTED_TEXT_CACHE_SIZE), PROP_EXTRACTED_TEXT_CACHE_SIZE_DEFAULT); int cacheExpiryInSecs = PropertiesUtil.toInteger(config.get(PROP_EXTRACTED_TEXT_CACHE_EXPIRY), PROP_EXTRACTED_TEXT_CACHE_EXPIRY_DEFAULT); boolean alwaysUsePreExtractedCache = PropertiesUtil.toBoolean(config.get(PROP_PRE_EXTRACTED_TEXT_ALWAYS_USE), PROP_PRE_EXTRACTED_TEXT_ALWAYS_USE_DEFAULT); extractedTextCache = new ExtractedTextCache( cacheSizeInMB * ONE_MB, cacheExpiryInSecs, alwaysUsePreExtractedCache, indexDir); if (extractedTextProvider != null){ registerExtractedTextProvider(extractedTextProvider); } CacheStats stats = extractedTextCache.getCacheStats(); if (stats != null){ oakRegs.add(registerMBean(whiteboard, CacheStatsMBean.class, stats, CacheStatsMBean.TYPE, stats.getName())); log.info("Extracted text caching enabled with maxSize {} MB, expiry time {} secs", cacheSizeInMB, cacheExpiryInSecs); } }
DataStore ds = createDataStore(context, config); boolean encodeLengthInId = PropertiesUtil.toBoolean(config.get(PROP_ENCODE_LENGTH), true); int cacheSizeInMB = PropertiesUtil.toInteger(config.get(PROP_CACHE_SIZE), DataStoreBlobStore.DEFAULT_CACHE_SIZE);
DataStore ds = createDataStore(context, config); boolean encodeLengthInId = PropertiesUtil.toBoolean(config.get(PROP_ENCODE_LENGTH), true); int cacheSizeInMB = PropertiesUtil.toInteger(config.get(PROP_CACHE_SIZE), DataStoreBlobStore.DEFAULT_CACHE_SIZE);
private void registerLocalIndexObserver(BundleContext bundleContext, IndexTracker tracker, Map<String, ?> config) { if (!hybridIndex){ log.info("Hybrid indexing feature disabled"); return; } int queueSize = PropertiesUtil.toInteger(config.get(PROP_HYBRID_QUEUE_SIZE), PROP_HYBRID_QUEUE_SIZE_DEFAULT); documentQueue = new DocumentQueue(queueSize, tracker, getExecutorService(), statisticsProvider); LocalIndexObserver localIndexObserver = new LocalIndexObserver(documentQueue, statisticsProvider); regs.add(bundleContext.registerService(Observer.class.getName(), localIndexObserver, null)); int observerQueueSize = 1000; int builderMaxSize = 5000; regs.add(bundleContext.registerService(JournalPropertyService.class.getName(), new LuceneJournalPropertyService(builderMaxSize), null)); ExternalObserverBuilder builder = new ExternalObserverBuilder(documentQueue, tracker, statisticsProvider, getExecutorService(), observerQueueSize); log.info("Configured JournalPropertyBuilder with max size {} and backed by BackgroundObserver " + "with queue size {}", builderMaxSize, observerQueueSize); Observer observer = builder.build(); externalIndexObserver = builder.getBackgroundObserver(); regs.add(bundleContext.registerService(Observer.class.getName(), observer, null)); oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, externalIndexObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneExternalIndexObserver queue stats")); log.info("Hybrid indexing enabled for configured indexes with queue size of {}", queueSize); }
@SuppressWarnings("UnnecessaryBoxing") @Test public void testToInteger() { assertEquals(2, PropertiesUtil.toInteger(null, 2)); assertEquals(2, PropertiesUtil.toInteger(1.0, 2)); assertEquals(2, PropertiesUtil.toInteger(new Double(1.0), 2)); assertEquals(5, PropertiesUtil.toInteger(new Long(5), 2)); assertEquals(5, PropertiesUtil.toInteger(new Integer(5), 2)); assertEquals(2, PropertiesUtil.toInteger("abc", 2)); }
private void registerLocalIndexObserver(BundleContext bundleContext, IndexTracker tracker, Map<String, ?> config) { if (!hybridIndex){ log.info("Hybrid indexing feature disabled"); return; } int queueSize = PropertiesUtil.toInteger(config.get(PROP_HYBRID_QUEUE_SIZE), PROP_HYBRID_QUEUE_SIZE_DEFAULT); documentQueue = new DocumentQueue(queueSize, tracker, getExecutorService(), statisticsProvider); LocalIndexObserver localIndexObserver = new LocalIndexObserver(documentQueue, statisticsProvider); regs.add(bundleContext.registerService(Observer.class.getName(), localIndexObserver, null)); int observerQueueSize = 1000; int builderMaxSize = 5000; regs.add(bundleContext.registerService(JournalPropertyService.class.getName(), new LuceneJournalPropertyService(builderMaxSize), null)); ExternalObserverBuilder builder = new ExternalObserverBuilder(documentQueue, tracker, statisticsProvider, getExecutorService(), observerQueueSize); log.info("Configured JournalPropertyBuilder with max size {} and backed by BackgroundObserver " + "with queue size {}", builderMaxSize, observerQueueSize); Observer observer = builder.build(); externalIndexObserver = builder.getBackgroundObserver(); regs.add(bundleContext.registerService(Observer.class.getName(), observer, null)); oakRegs.add(registerMBean(whiteboard, BackgroundObserverMBean.class, externalIndexObserver.getMBean(), BackgroundObserverMBean.TYPE, "LuceneExternalIndexObserver queue stats")); log.info("Hybrid indexing enabled for configured indexes with queue size of {}", queueSize); }
@Activate public void activate(BundleContext bundleContext, Map<String, ?> config) throws Exception { observationQueueLength = PropertiesUtil.toInteger(prop( config, bundleContext, OBSERVATION_QUEUE_LENGTH), DEFAULT_OBSERVATION_QUEUE_LENGTH); if(PropertiesUtil.toBoolean(prop( config, bundleContext, COMMIT_RATE_LIMIT), DEFAULT_COMMIT_RATE_LIMIT)) { commitRateLimiter = new CommitRateLimiter(); } else { commitRateLimiter = null; } fastQueryResultSize = PropertiesUtil.toBoolean(prop( config, bundleContext, FAST_QUERY_RESULT_SIZE), DEFAULT_FAST_QUERY_RESULT_SIZE); whiteboard = new OsgiWhiteboard(bundleContext); initializers = whiteboard.track(RepositoryInitializer.class); editorProvider.start(whiteboard); indexEditorProvider.start(whiteboard); indexProvider.start(whiteboard); registration = registerRepository(bundleContext); }
@Activate public void activate(BundleContext bundleContext, Map<String, ?> config) throws Exception { observationQueueLength = PropertiesUtil.toInteger(prop( config, bundleContext, OBSERVATION_QUEUE_LENGTH), DEFAULT_OBSERVATION_QUEUE_LENGTH); if(PropertiesUtil.toBoolean(prop( config, bundleContext, COMMIT_RATE_LIMIT), DEFAULT_COMMIT_RATE_LIMIT)) { commitRateLimiter = new CommitRateLimiter(); } else { commitRateLimiter = null; } fastQueryResultSize = PropertiesUtil.toBoolean(prop( config, bundleContext, FAST_QUERY_RESULT_SIZE), DEFAULT_FAST_QUERY_RESULT_SIZE); whiteboard = new OsgiWhiteboard(bundleContext); initializers = whiteboard.track(RepositoryInitializer.class); editorProvider.start(whiteboard); indexEditorProvider.start(whiteboard); indexProvider.start(whiteboard); registration = registerRepository(bundleContext); }
@Activate public void activate(BundleContext bundleContext, Map<String, ?> config) throws Exception { observationQueueLength = PropertiesUtil.toInteger(prop( config, bundleContext, OBSERVATION_QUEUE_LENGTH), DEFAULT_OBSERVATION_QUEUE_LENGTH); if(PropertiesUtil.toBoolean(prop( config, bundleContext, COMMIT_RATE_LIMIT), DEFAULT_COMMIT_RATE_LIMIT)) { commitRateLimiter = new CommitRateLimiter(); } else { commitRateLimiter = null; } fastQueryResultSize = PropertiesUtil.toBoolean(prop( config, bundleContext, FAST_QUERY_RESULT_SIZE), DEFAULT_FAST_QUERY_RESULT_SIZE); whiteboard = new OsgiWhiteboard(bundleContext); initializers = whiteboard.track(RepositoryInitializer.class); editorProvider.start(whiteboard); indexEditorProvider.start(whiteboard); indexProvider.start(whiteboard); registration = registerRepository(bundleContext); }