Search in sources :

Example 16 with SearchMapping

use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.

the class LifecycleManager method cacheStarting.

/**
 * 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);
    LocalQueryStatistics queryStatistics = cr.getComponent(LocalQueryStatistics.class);
    if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, Flag.QUERYABLE)) {
        AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
        SecurityActions.addCacheDependency(cache.getCacheManager(), cacheName, QueryCache.QUERY_CACHE_NAME);
        ClassLoader aggregatedClassLoader = makeAggregatedClassLoader(cr.getGlobalComponentRegistry().getGlobalConfiguration().classLoader());
        boolean isIndexed = cfg.indexing().enabled();
        SearchMapping searchMapping = null;
        if (isIndexed) {
            Map<String, Class<?>> indexedClasses = makeIndexedClassesMap(cache);
            KeyTransformationHandler keyTransformationHandler = new KeyTransformationHandler(aggregatedClassLoader);
            cr.registerComponent(keyTransformationHandler, KeyTransformationHandler.class);
            for (Map.Entry<Class<?>, Class<?>> kt : cfg.indexing().keyTransformers().entrySet()) {
                keyTransformationHandler.registerTransformer(kt.getKey(), (Class<? extends Transformer>) kt.getValue());
            }
            searchMapping = createSearchMapping(queryStatistics, cfg.indexing(), indexedClasses, cr, cache, keyTransformationHandler, aggregatedClassLoader);
            createQueryInterceptorIfNeeded(cr, cfg, cache, indexedClasses);
            Indexer massIndexer = new DistributedExecutorMassIndexer(cache);
            cr.registerComponent(massIndexer, Indexer.class);
            if (searchMapping != null) {
                BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
                bcr.replaceComponent(IndexStatistics.class.getName(), new LocalIndexStatistics(), true);
                bcr.rewire();
            }
        }
        cr.registerComponent(ObjectReflectionMatcher.create(new ReflectionEntityNamesResolver(aggregatedClassLoader), searchMapping), ObjectReflectionMatcher.class);
        cr.registerComponent(new QueryEngine<>(cache, isIndexed), QueryEngine.class);
    }
}
Also used : ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) DistributedExecutorMassIndexer(org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) DistributedExecutorMassIndexer(org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer) Indexer(org.infinispan.query.Indexer) KeyTransformationHandler(org.infinispan.query.backend.KeyTransformationHandler) AggregatedClassLoader(org.infinispan.commons.util.AggregatedClassLoader) LocalQueryStatistics(org.infinispan.query.core.stats.impl.LocalQueryStatistics) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Cache(org.infinispan.Cache) QueryCache(org.infinispan.query.core.impl.QueryCache) AdvancedCache(org.infinispan.AdvancedCache)

Example 17 with SearchMapping

use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.

the class LifecycleManager method cacheStopping.

@Override
public void cacheStopping(ComponentRegistry cr, String cacheName) {
    QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class);
    if (queryInterceptor != null) {
        queryInterceptor.prepareForStopping();
    }
    SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
    if (searchMapping != null) {
        searchMapping.close();
    }
}
Also used : TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping)

Example 18 with SearchMapping

use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.

the class ClusteredQueryDslConditionsTest method checkIndexPresence.

private void checkIndexPresence(Cache<?, ?> cache) {
    SearchMapping searchMapping = TestQueryHelperFactory.extractSearchMapping(cache);
    verifyClassIsIndexed(searchMapping, getModelFactory().getUserImplClass());
    verifyClassIsIndexed(searchMapping, getModelFactory().getAccountImplClass());
    verifyClassIsIndexed(searchMapping, getModelFactory().getTransactionImplClass());
    verifyClassIsNotIndexed(searchMapping, getModelFactory().getAddressImplClass());
}
Also used : SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping)

Example 19 with SearchMapping

use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.

the class SearchFactoryShutdownTest method testCorrectShutdown.

public void testCorrectShutdown() {
    CacheContainer cc = null;
    try {
        ConfigurationBuilder cfg = new ConfigurationBuilder();
        cfg.transaction().transactionMode(TransactionMode.TRANSACTIONAL).indexing().enable().storage(LOCAL_HEAP).addIndexedEntity(Person.class);
        cc = TestCacheManagerFactory.createCacheManager(cfg);
        Cache<?, ?> cache = cc.getCache();
        SearchMapping searchMapping = TestingUtil.extractComponent(cache, SearchMapping.class);
        assertFalse(searchMapping.isClose());
        cc.stop();
        assertTrue(searchMapping.isClose());
    } finally {
        // proper cleanup for exceptional execution
        TestingUtil.killCacheManagers(cc);
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) CacheContainer(org.infinispan.manager.CacheContainer)

Example 20 with SearchMapping

use of org.infinispan.search.mapper.mapping.SearchMapping in project infinispan by infinispan.

the class LazySearchMapping method mapping.

private SearchMapping mapping() {
    long stamp = stampedLock.tryOptimisticRead();
    SearchMapping searchMapping = searchMappingRef.get();
    if (!stampedLock.validate(stamp)) {
        stamp = stampedLock.readLock();
        try {
            searchMapping = searchMappingRef.get();
        } finally {
            stampedLock.unlockRead(stamp);
        }
    }
    return searchMapping;
}
Also used : SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) SerializationContextSearchMapping(org.infinispan.query.remote.impl.mapping.SerializationContextSearchMapping)

Aggregations

SearchMapping (org.infinispan.search.mapper.mapping.SearchMapping)20 AdvancedCache (org.infinispan.AdvancedCache)4 Cache (org.infinispan.Cache)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)3 QueryInterceptor (org.infinispan.query.backend.QueryInterceptor)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 MediaType (org.infinispan.commons.dataconversion.MediaType)2 IndexingConfiguration (org.infinispan.configuration.cache.IndexingConfiguration)2 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)2 DataConversion (org.infinispan.encoding.DataConversion)2 ComponentRegistry (org.infinispan.factories.ComponentRegistry)2 ReflectionEntityNamesResolver (org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver)2 SerializationContext (org.infinispan.protostream.SerializationContext)2 Indexer (org.infinispan.query.Indexer)2 KeyTransformationHandler (org.infinispan.query.backend.KeyTransformationHandler)2 QueryCache (org.infinispan.query.core.impl.QueryCache)2 IndexStatistics (org.infinispan.query.core.stats.IndexStatistics)2