use of org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer 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);
}
}
Aggregations