Search in sources :

Example 26 with BasicComponentRegistry

use of org.infinispan.factories.impl.BasicComponentRegistry 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 27 with BasicComponentRegistry

use of org.infinispan.factories.impl.BasicComponentRegistry in project infinispan by infinispan.

the class LifecycleManager method createQueryInterceptorIfNeeded.

private void createQueryInterceptorIfNeeded(ComponentRegistry cr, Configuration cfg, AdvancedCache<?, ?> cache, Map<String, Class<?>> indexedClasses) {
    CONTAINER.registeringQueryInterceptor(cache.getName());
    BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
    ComponentRef<QueryInterceptor> queryInterceptorRef = bcr.getComponent(QueryInterceptor.class);
    if (queryInterceptorRef != null) {
        // could be already present when two caches share a config
        return;
    }
    ConcurrentMap<GlobalTransaction, Map<Object, Object>> txOldValues = new ConcurrentHashMap<>();
    boolean manualIndexing = HS5_CONF_STRATEGY_MANUAL.equals(cfg.indexing().properties().get(HS5_CONF_STRATEGY_PROPERTY));
    QueryInterceptor queryInterceptor = new QueryInterceptor(manualIndexing, txOldValues, cache, indexedClasses);
    AsyncInterceptorChain ic = bcr.getComponent(AsyncInterceptorChain.class).wired();
    EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class);
    ic.addInterceptorBefore(queryInterceptor, wrappingInterceptor.getClass());
    bcr.registerComponent(QueryInterceptor.class, queryInterceptor, true);
    bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), QueryInterceptor.class.getName());
    if (cfg.transaction().transactionMode().isTransactional()) {
        TxQueryInterceptor txQueryInterceptor = new TxQueryInterceptor(txOldValues, queryInterceptor);
        ic.addInterceptorBefore(txQueryInterceptor, wrappingInterceptor.getClass());
        bcr.registerComponent(TxQueryInterceptor.class, txQueryInterceptor, true);
        bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), TxQueryInterceptor.class.getName());
    }
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor) AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain) EntryWrappingInterceptor(org.infinispan.interceptors.impl.EntryWrappingInterceptor) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 28 with BasicComponentRegistry

use of org.infinispan.factories.impl.BasicComponentRegistry in project infinispan by infinispan.

the class AbstractProtocolServer method start.

@Override
public void start(C configuration, EmbeddedCacheManager cacheManager) {
    if (log.isDebugEnabled()) {
        log.debugf("Starting server with configuration: %s", configuration);
    }
    this.configuration = configuration;
    this.cacheManager = cacheManager;
    BasicComponentRegistry bcr = SecurityActions.getGlobalComponentRegistry(cacheManager).getComponent(BasicComponentRegistry.class.getName());
    ComponentRef<ServerStateManager> stateManagerComponentRef = bcr.getComponent(ServerStateManager.class);
    if (stateManagerComponentRef != null) {
        serverStateManager = stateManagerComponentRef.running();
    }
    bcr.replaceComponent(getQualifiedName(), this, false);
    blockingManager = bcr.getComponent(BlockingManager.class).running();
    executor = bcr.getComponent(KnownComponentNames.BLOCKING_EXECUTOR, ExecutorService.class).running();
    manageableThreadPoolExecutorService = new ManageableThreadPoolExecutorService(executor);
    try {
        startInternal();
    } catch (RuntimeException t) {
        stop();
        throw t;
    }
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ManageableThreadPoolExecutorService(org.infinispan.server.core.utils.ManageableThreadPoolExecutorService)

Example 29 with BasicComponentRegistry

use of org.infinispan.factories.impl.BasicComponentRegistry in project infinispan by infinispan.

the class SinglePortEndpointRouter method start.

@Override
public void start(RoutingTable routingTable, EmbeddedCacheManager ecm) {
    this.routingTable = routingTable;
    this.routingTable.streamRoutes().forEach(r -> r.getRouteDestination().getProtocolServer().setEnclosingProtocolServer(this));
    this.cacheManager = ecm;
    InetSocketAddress address = new InetSocketAddress(configuration.host(), configuration.port());
    transport = new NettyTransport(address, configuration, getQualifiedName(), cacheManager);
    transport.initializeHandler(getInitializer());
    if (cacheManager != null) {
        BasicComponentRegistry bcr = getGlobalComponentRegistry(cacheManager).getComponent(BasicComponentRegistry.class);
        bcr.replaceComponent(getQualifiedName(), this, false);
    }
    registerServerMBeans();
    try {
        transport.start();
    } catch (Throwable re) {
        try {
            unregisterServerMBeans();
        } catch (Exception e) {
            re.addSuppressed(e);
        }
        throw re;
    }
    registerMetrics();
    RouterLogger.SERVER.debugf("REST EndpointRouter listening on %s:%d", transport.getHostName(), transport.getPort());
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) InetSocketAddress(java.net.InetSocketAddress) NettyTransport(org.infinispan.server.core.transport.NettyTransport) UnknownHostException(java.net.UnknownHostException)

Example 30 with BasicComponentRegistry

use of org.infinispan.factories.impl.BasicComponentRegistry in project infinispan by infinispan.

the class LifecycleManager method cacheManagerStarting.

@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalCfg) {
    Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers();
    externalizerMap.put(ExternalizerIds.ICKLE_PROTOBUF_CACHE_EVENT_FILTER_CONVERTER, new IckleProtobufCacheEventFilterConverter.Externalizer());
    externalizerMap.put(ExternalizerIds.ICKLE_PROTOBUF_FILTER_AND_CONVERTER, new IckleProtobufFilterAndConverter.Externalizer());
    externalizerMap.put(ExternalizerIds.ICKLE_CONTINUOUS_QUERY_CACHE_EVENT_FILTER_CONVERTER, new IckleContinuousQueryProtobufCacheEventFilterConverter.Externalizer());
    externalizerMap.put(ExternalizerIds.ICKLE_BINARY_PROTOBUF_FILTER_AND_CONVERTER, new IckleBinaryProtobufFilterAndConverter.Externalizer());
    externalizerMap.put(ExternalizerIds.ICKLE_CONTINUOUS_QUERY_RESULT, new ContinuousQueryResultExternalizer());
    externalizerMap.put(ExternalizerIds.ICKLE_FILTER_RESULT, new FilterResultExternalizer());
    BasicComponentRegistry bcr = gcr.getComponent(BasicComponentRegistry.class);
    SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
    ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, new PersistenceContextInitializerImpl());
    ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.GLOBAL, MarshallerRegistration.INSTANCE);
    initProtobufMetadataManager(bcr);
    EmbeddedCacheManager cacheManager = gcr.getComponent(EmbeddedCacheManager.class);
    cacheManager.getClassAllowList().addClasses(QueryRequest.class, QueryRequestExternalizer.class);
}
Also used : IckleContinuousQueryProtobufCacheEventFilterConverter(org.infinispan.query.remote.impl.filter.IckleContinuousQueryProtobufCacheEventFilterConverter) IckleProtobufFilterAndConverter(org.infinispan.query.remote.impl.filter.IckleProtobufFilterAndConverter) IckleBinaryProtobufFilterAndConverter(org.infinispan.query.remote.impl.filter.IckleBinaryProtobufFilterAndConverter) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) FilterResultExternalizer(org.infinispan.query.remote.impl.filter.FilterResultExternalizer) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) PersistenceContextInitializerImpl(org.infinispan.query.remote.impl.persistence.PersistenceContextInitializerImpl) IckleProtobufCacheEventFilterConverter(org.infinispan.query.remote.impl.filter.IckleProtobufCacheEventFilterConverter) AdvancedExternalizer(org.infinispan.commons.marshall.AdvancedExternalizer) ContinuousQueryResultExternalizer(org.infinispan.query.remote.impl.filter.ContinuousQueryResultExternalizer)

Aggregations

BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)30 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)11 AsyncInterceptorChain (org.infinispan.interceptors.AsyncInterceptorChain)7 AdvancedCache (org.infinispan.AdvancedCache)6 Cache (org.infinispan.Cache)5 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)5 GlobalComponentRegistry (org.infinispan.factories.GlobalComponentRegistry)5 InternalCacheRegistry (org.infinispan.registry.InternalCacheRegistry)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 TimeUnit (java.util.concurrent.TimeUnit)3 ConfigurationManager (org.infinispan.configuration.ConfigurationManager)3 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)3 Collections (java.util.Collections)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 Executors (java.util.concurrent.Executors)2 CacheStatusRequestCommand (org.infinispan.commands.topology.CacheStatusRequestCommand)2 TimeService (org.infinispan.commons.time.TimeService)2