本文整理了Java中org.infinispan.configuration.cache.Configuration.indexing()
方法的一些代码示例,展示了Configuration.indexing()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.indexing()
方法的具体详情如下:
包路径:org.infinispan.configuration.cache.Configuration
类名称:Configuration
方法名:indexing
暂无
代码示例来源:origin: org.infinispan/infinispan-query
private static void ensureIndexed(Cache<?, ?> cache) {
Configuration cfg = SecurityActions.getCacheConfiguration(cache);
if (!cfg.indexing().index().isEnabled()) {
throw new IllegalStateException("Indexing was not enabled on cache " + cache.getName());
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
/**
* For a given configuration, define which IndexModificationStrategy is going to be used.
* @param searchFactory
* @param cfg
* @return the appropriate IndexModificationStrategy
*/
public static IndexModificationStrategy configuredStrategy(SearchIntegrator searchFactory, Configuration cfg) {
IndexingMode indexingMode = searchFactory.unwrap(SearchIntegrator.class).getIndexingMode();
if (indexingMode == IndexingMode.MANUAL) {
return MANUAL;
} else {
if (cfg.indexing().index().isLocalOnly()) {
return LOCAL_ONLY;
} else if (cfg.indexing().index().isPrimaryOwner()) {
return PRIMARY_OWNER;
} else {
return ALL;
}
}
}
代码示例来源:origin: org.infinispan/infinispan-query
/**
* For a given configuration, define which IndexModificationStrategy is going to be used.
* @param searchFactory
* @param cfg
* @return the appropriate IndexModificationStrategy
*/
public static IndexModificationStrategy configuredStrategy(SearchIntegrator searchFactory, Configuration cfg) {
IndexingMode indexingMode = searchFactory.unwrap(SearchIntegrator.class).getIndexingMode();
if (indexingMode == IndexingMode.MANUAL) {
return MANUAL;
} else {
if (cfg.indexing().index().isLocalOnly()) {
return LOCAL_ONLY;
} else if (cfg.indexing().index().isPrimaryOwner()) {
return PRIMARY_OWNER;
} else {
return ALL;
}
}
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Start
protected void start() {
Set<Class<?>> indexedEntities = cache.getCacheConfiguration().indexing().indexedEntities();
this.indexedEntities = indexedEntities.isEmpty() ? null : indexedEntities.toArray(new Class<?>[indexedEntities.size()]);
queryKnownClasses = indexedEntities.isEmpty() ? new QueryKnownClasses(cache.getName(), cache.getCacheManager(), internalCacheRegistry) : new QueryKnownClasses(indexedEntities);
searchFactoryHandler = new SearchFactoryHandler(searchFactory, queryKnownClasses, new TransactionHelper(transactionManager));
if (this.indexedEntities == null) {
queryKnownClasses.start(searchFactoryHandler);
Set<Class<?>> classes = queryKnownClasses.keys();
Class<?>[] classesArray = classes.toArray(new Class<?>[classes.size()]);
//Important to enable them all in a single call, much more efficient:
enableClasses(classesArray);
}
stopping.set(false);
}
代码示例来源:origin: org.infinispan/infinispan-avro-server
/**
* Registers the remote value wrapper interceptor in the cache before it gets started.
*/
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
if (!cacheName.equals(Support.AVRO_METADATA_CACHE_NAME)) {
if (cfg.indexing().index().isEnabled() && !cfg.compatibility().enabled()) {
log.infof("Registering RemoteAvroValueWrapperInterceptor for cache %s", cacheName);
createRemoteIndexingInterceptor(cr, cfg);
}
}
}
代码示例来源:origin: org.infinispan/infinispan-avro-server
@Override
public void cacheStarted(ComponentRegistry cr, String cacheName) {
Configuration configuration = cr.getComponent(Configuration.class);
boolean remoteValueWrappingEnabled = configuration.indexing().index().isEnabled() && !configuration.compatibility().enabled();
if (!remoteValueWrappingEnabled) {
if (verifyChainContainsRemoteAvroValueWrapperInterceptor(cr)) {
throw new IllegalStateException("It was NOT expected to find the RemoteAvroValueWrapperInterceptor registered in the InterceptorChain as indexing was disabled, but it was found");
}
return;
}
if (!verifyChainContainsRemoteAvroValueWrapperInterceptor(cr)) {
throw new IllegalStateException("It was expected to find the RemoteAvroValueWrapperInterceptor registered in the InterceptorChain but it wasn't found");
}
}
代码示例来源:origin: org.infinispan/infinispan-query
@Start
protected void start() {
Set<Class<?>> indexedEntities = cacheConfiguration.indexing().indexedEntities();
this.indexedEntities = indexedEntities.isEmpty() ? null : indexedEntities.toArray(new Class<?>[indexedEntities.size()]);
queryKnownClasses = indexedEntities.isEmpty() ? new QueryKnownClasses(cache.getName(), cache.getCacheManager(), internalCacheRegistry) : new QueryKnownClasses(cache.getName(), indexedEntities);
searchFactoryHandler = new SearchFactoryHandler(searchFactory, queryKnownClasses, new TransactionHelper(cache.getTransactionManager()));
if (this.indexedEntities == null) {
queryKnownClasses.start(searchFactoryHandler);
Set<Class<?>> classes = queryKnownClasses.keys();
Class<?>[] classesArray = classes.toArray(new Class<?>[classes.size()]);
//Important to enable them all in a single call, much more efficient:
searchFactoryHandler.enableClasses(classesArray);
}
isPersistenceEnabled = cacheConfiguration.persistence().usingStores();
stopping.set(false);
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testIndexedConfigurationInheritance() {
Configuration configuration = cacheManager.getCacheConfiguration("default");
Set<Class<?>> indexedEntities = configuration.indexing().indexedEntities();
assertEquals(1, indexedEntities.size());
assertTrue(indexedEntities.contains(Book.class));
configuration = cacheManager.getCacheConfiguration("extended");
indexedEntities = configuration.indexing().indexedEntities();
assertEquals(2, indexedEntities.size());
assertTrue(indexedEntities.contains(Book.class));
assertTrue(indexedEntities.contains(AnotherGrassEater.class));
}
代码示例来源:origin: org.infinispan/infinispan-query
Configuration defaultConfiguration = namedConfigurations.get("default").build();
assertEquals(defaultConfiguration.indexing().properties().size(), 2);
assertTrue(defaultConfiguration.indexing().index().isEnabled());
assertEquals(defaultConfiguration.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "someDefault");
assertFalse(nonSearchableCfg.indexing().index().isEnabled());
assertTrue(simpleCfg.indexing().index().isEnabled());
assertEquals(simpleCfg.indexing().properties().size(), 2);
assertTrue(memoryCfg.indexing().index().isEnabled());
assertFalse(memoryCfg.indexing().index().isLocalOnly());
assertEquals(memoryCfg.indexing().properties().size(), 2);
assertEquals(memoryCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "local-heap");
assertTrue(diskCfg.indexing().index().isEnabled());
assertTrue(diskCfg.indexing().index().isLocalOnly());
assertEquals(diskCfg.indexing().properties().size(), 3);
assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "filesystem");
assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.cats.exclusive_index_use"), "true");
代码示例来源:origin: org.infinispan/infinispan-query
@Test
public void testIndexingParametersForNamedCache() {
Cache<Object, Object> inMemory = manager.getCache("memory-searchable");
inMemory.start();
assertFalse(inMemory.getCacheConfiguration().indexing().properties().isEmpty(),
"should contain definition from xml");
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testConfigurationFileParsing() throws IOException {
ParserRegistry parserRegistry = new ParserRegistry(Thread.currentThread().getContextClassLoader());
ConfigurationBuilderHolder holder = parserRegistry.parseFile("configuration-parsing-test.xml");
Map<String, ConfigurationBuilder> namedConfigurations = holder.getNamedConfigurationBuilders();
Configuration defaultConfiguration = namedConfigurations.get("default").build();
assertEquals(defaultConfiguration.indexing().properties().size(), 0);
assertFalse(defaultConfiguration.indexing().index().isEnabled());
Configuration simpleCfg = namedConfigurations.get("simple").build();
assertFalse(simpleCfg.indexing().index().isEnabled());
assertEquals(simpleCfg.indexing().properties().size(), 0);
Configuration memoryCfg = namedConfigurations.get("memory-searchable").build();
assertTrue(memoryCfg.indexing().index().isEnabled());
assertEquals(2, memoryCfg.indexing().properties().size());
assertEquals(memoryCfg.indexing().properties().getProperty("default.directory_provider"), "local-heap");
Configuration diskCfg = namedConfigurations.get("disk-searchable").build();
assertTrue(diskCfg.indexing().index().isEnabled());
assertEquals(diskCfg.indexing().properties().size(), 3);
assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "filesystem");
assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.cats.exclusive_index_use"), "true");
Configuration replDefaults = namedConfigurations.get("repl-with-default").build();
assertTrue(replDefaults.indexing().index().isEnabled());
assertFalse(replDefaults.indexing().properties().isEmpty());
Configuration affinity = namedConfigurations.get("dist-with-affinity").build();
assertTrue(affinity.indexing().index().isEnabled());
assertTrue(affinity.indexing().index().isPrimaryOwner());
assertEquals(affinity.indexing().properties().getProperty("default.indexmanager"), AffinityIndexManager.class.getName());
}
代码示例来源:origin: org.infinispan/infinispan-query
@Override
public void cacheStarted(ComponentRegistry cr, String cacheName) {
Configuration configuration = cr.getComponent(Configuration.class);
IndexingConfiguration indexingConfiguration = configuration.indexing();
if (!indexingConfiguration.index().isEnabled()) {
if (verifyChainContainsQueryInterceptor(cr)) {
代码示例来源:origin: org.infinispan/infinispan-embedded-query
@Override
public void cacheStarted(ComponentRegistry cr, String cacheName) {
Configuration configuration = cr.getComponent(Configuration.class);
IndexingConfiguration indexingConfiguration = configuration.indexing();
if (!indexingConfiguration.index().isEnabled()) {
if (verifyChainContainsQueryInterceptor(cr)) {
代码示例来源:origin: org.infinispan/infinispan-query
@Override
public void call() {
Configuration cacheConfiguration = cm.getCacheConfiguration("repl-with-default");
TypedProperties properties = cacheConfiguration.indexing().properties();
assertFalse(properties.isEmpty());
assertEquals(properties.getProperty("hibernate.search.default.exclusive_index_use"), "true");
assertEquals(properties.getProperty("hibernate.search.default.reader.strategy"), "shared");
assertEquals(properties.getProperty("hibernate.search.default.indexmanager"), "near-real-time");
assertEquals(properties.getProperty("hibernate.search.default.directory_provider"), "filesystem");
cacheConfiguration = cm.getCacheConfiguration("dist-with-default");
properties = cacheConfiguration.indexing().properties();
assertFalse(properties.isEmpty());
assertEquals(properties.getProperty("hibernate.search.default.directory_provider"), "infinispan");
assertEquals(properties.getProperty("hibernate.search.default.indexmanager"), "org.infinispan.query.indexmanager.InfinispanIndexManager");
assertEquals(properties.getProperty("hibernate.search.default.exclusive_index_use"), "true");
assertEquals(properties.getProperty("hibernate.search.default.reader.strategy"), "shared");
}
});
代码示例来源:origin: org.infinispan/infinispan-tree
public TreeCacheImpl(AdvancedCache<?, ?> cache) {
super(cache, cache.getBatchContainer());
if (cache.getCacheConfiguration().indexing().index().isEnabled())
throw new CacheConfigurationException("TreeCache cannot be used with a Cache instance configured to use indexing!");
assertBatchingSupported(cache.getCacheConfiguration());
createRoot();
}
代码示例来源:origin: org.infinispan/infinispan-embedded-query
/**
* Registers the Search interceptor in the cache before it gets started
*/
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, Flag.QUERYABLE)) {
boolean isIndexed = cfg.indexing().index().isEnabled();
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
SearchIntegrator searchFactory = null;
if (isIndexed) {
log.registeringQueryInterceptor(cacheName);
cr.registerComponent(new ShardAllocationManagerImpl(), ShardAllocatorManager.class);
searchFactory = getSearchFactory(cacheName, cfg.indexing(), cr);
createQueryInterceptorIfNeeded(cr, cfg, searchFactory);
addCacheDependencyIfNeeded(cacheName, cache.getCacheManager(), cfg.indexing());
// initializing the query module command initializer.
// we can t inject Cache and CacheManager with @inject in there
CommandInitializer initializer = cr.getComponent(CommandInitializer.class);
initializer.setCacheManager(cache.getCacheManager());
QueryBox queryBox = new QueryBox();
queryBox.setCache(cache);
cr.registerComponent(queryBox, QueryBox.class);
}
registerMatcher(cr, searchFactory);
EmbeddedQueryEngine queryEngine = new EmbeddedQueryEngine(cache, isIndexed);
cr.registerComponent(queryEngine, EmbeddedQueryEngine.class);
}
}
代码示例来源:origin: org.infinispan/infinispan-query
/**
* Registers the Search interceptor in the cache before it gets started
*/
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, Flag.QUERYABLE)) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
ClassLoader aggregatedClassLoader = makeAggregatedClassLoader(cr.getGlobalComponentRegistry().getGlobalConfiguration().classLoader());
SearchIntegrator searchFactory = null;
boolean isIndexed = cfg.indexing().index().isEnabled();
if (isIndexed) {
setBooleanQueryMaxClauseCount();
cr.registerComponent(new ShardAllocationManagerImpl(), ShardAllocatorManager.class);
searchFactory = createSearchIntegrator(cfg.indexing(), cr, aggregatedClassLoader);
KeyTransformationHandler keyTransformationHandler = new KeyTransformationHandler(aggregatedClassLoader);
cr.registerComponent(keyTransformationHandler, KeyTransformationHandler.class);
createQueryInterceptorIfNeeded(cr.getComponent(BasicComponentRegistry.class), cfg, cache, searchFactory, keyTransformationHandler);
addCacheDependencyIfNeeded(cacheName, cache.getCacheManager(), cfg.indexing());
cr.registerComponent(new QueryBox(), QueryBox.class);
}
registerMatcher(cr, searchFactory, aggregatedClassLoader);
cr.registerComponent(new EmbeddedQueryEngine(cache, isIndexed), EmbeddedQueryEngine.class);
}
}
代码示例来源:origin: de.smartics.properties/smartics-properties-cache-infinispan
/**
* Default constructor.
*
* @param manager the Infinispan cache manager.
*/
public AbstractInfinispanCompoundKeyCacheManager(
final EmbeddedCacheManager manager)
{
this.manager = manager;
configManager = new GuavaCacheManager();
manager.getDefaultCacheConfiguration().jmxStatistics();
this.cache = manager.getCache(CACHE_NAME);
if (!manager.isRunning(CACHE_NAME))
{
final Configuration cacheConfig = this.cache.getCacheConfiguration();
cacheConfig.jmxStatistics();
cacheConfig.indexing().indexLocalOnly();
cache.start();
}
// cache.addListener(new CompoundKeyHandlingCacheListener());
cache.clear();
}
代码示例来源:origin: org.infinispan/infinispan-server-hotrod
public CacheInfo getCacheInfo(AdvancedCache<byte[], byte[]> cache, HotRodHeader header) {
// Fetching persistence manager would require security action, and would be too expensive
CacheInfo info = cacheInfo.get(cache.getName() + header.getKeyMediaType().getTypeSubtype() + header.getValueMediaType().getTypeSubtype());
if (info == null) {
AdvancedCache<byte[], byte[]> localNonBlocking = SecurityActions.anonymizeSecureCache(cache)
.noFlags().withFlags(LOCAL_NON_BLOCKING_GET);
if (cache.getStatus() != ComponentStatus.RUNNING) {
// stay on the safe side
return new CacheInfo(localNonBlocking, true, true, true);
}
ComponentRegistry cr = SecurityActions.getCacheComponentRegistry(cache);
PersistenceManager pm = cr.getComponent(PersistenceManager.class);
boolean hasIndexing = SecurityActions.getCacheConfiguration(cache).indexing().index().isEnabled();
CacheNotifierImpl cacheNotifier = (CacheNotifierImpl) cr.getComponent(CacheNotifier.class);
info = new CacheInfo(localNonBlocking, pm.isEnabled(), hasIndexing, hasSyncListener(cacheNotifier));
cacheInfo.put(cache.getName() + header.getKeyMediaType().getTypeSubtype() + header.getValueMediaType().getTypeSubtype(), info);
}
return info;
}
代码示例来源:origin: org.infinispan/infinispan-query
public void testPropertyMutabilityInInheritance() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.indexing().autoConfig(true).addProperty("key", "value");
Configuration configuration = builder.build();
try {
configuration.indexing().properties().setProperty("anotherKey", "anotherValue");
fail("Expecting unmodifiable properties");
} catch (UnsupportedOperationException e) {
// expected
}
ConfigurationBuilder derived = new ConfigurationBuilder();
derived.read(configuration);
builder.indexing().addProperty("anotherKey", "anotherValue");
}
}
内容来源于网络,如有侵权,请联系作者删除!