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);
}
}
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());
}
}
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;
}
}
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());
}
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);
}
Aggregations