Search in sources :

Example 11 with InternalCacheRegistry

use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.

the class ClusterPermissionMapper method setContext.

@Override
public void setContext(AuthorizationMapperContext context) {
    this.cacheManager = context.getCacheManager();
    GlobalConfiguration globalConfiguration = SecurityActions.getCacheManagerConfiguration(cacheManager);
    CacheMode cacheMode = globalConfiguration.isClustered() ? CacheMode.REPL_SYNC : CacheMode.LOCAL;
    ConfigurationBuilder cfg = new ConfigurationBuilder();
    cfg.clustering().cacheMode(cacheMode).stateTransfer().fetchInMemoryState(true).awaitInitialTransfer(false).security().authorization().disable();
    GlobalComponentRegistry gcr = SecurityActions.getGlobalComponentRegistry(cacheManager);
    InternalCacheRegistry internalCacheRegistry = gcr.getComponent(InternalCacheRegistry.class);
    internalCacheRegistry.registerInternalCache(CLUSTER_PERMISSION_MAPPER_CACHE, cfg.build(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT));
    gcr.registerComponent(this, RolePermissionMapper.class);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) CacheMode(org.infinispan.configuration.cache.CacheMode) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry)

Example 12 with InternalCacheRegistry

use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.

the class ClusteredLockModuleLifecycle method cacheManagerStarting.

@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
    if (!globalConfiguration.isClustered()) {
        log.configurationNotClustered();
        return;
    }
    final Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalConfiguration.serialization().advancedExternalizers();
    externalizerMap.put(ClusteredLockKey.EXTERNALIZER.getId(), ClusteredLockKey.EXTERNALIZER);
    externalizerMap.put(ClusteredLockValue.EXTERNALIZER.getId(), ClusteredLockValue.EXTERNALIZER);
    externalizerMap.put(LockFunction.EXTERNALIZER.getId(), LockFunction.EXTERNALIZER);
    externalizerMap.put(UnlockFunction.EXTERNALIZER.getId(), UnlockFunction.EXTERNALIZER);
    externalizerMap.put(IsLocked.EXTERNALIZER.getId(), IsLocked.EXTERNALIZER);
    externalizerMap.put(ClusteredLockFilter.EXTERNALIZER.getId(), ClusteredLockFilter.EXTERNALIZER);
    ClusteredLockManagerConfiguration config = extractConfiguration(gcr);
    InternalCacheRegistry internalCacheRegistry = gcr.getComponent(InternalCacheRegistry.class);
    Configuration lockConfig = createClusteredLockCacheConfiguration(config, globalConfiguration);
    internalCacheRegistry.registerInternalCache(CLUSTERED_LOCK_CACHE_NAME, lockConfig, EnumSet.of(InternalCacheRegistry.Flag.EXCLUSIVE));
    registerClusteredLockManager(gcr.getComponent(BasicComponentRegistry.class), globalConfiguration, config);
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ClusteredLockManagerConfiguration(org.infinispan.lock.configuration.ClusteredLockManagerConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) HashConfiguration(org.infinispan.configuration.cache.HashConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) ClusteredLockManagerConfiguration(org.infinispan.lock.configuration.ClusteredLockManagerConfiguration) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) AdvancedExternalizer(org.infinispan.commons.marshall.AdvancedExternalizer)

Example 13 with InternalCacheRegistry

use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.

the class LifecycleCallbacks method cacheManagerStarting.

@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration gc) {
    ScriptingManagerImpl scriptingManager = new ScriptingManagerImpl();
    gcr.registerComponent(scriptingManager, ScriptingManager.class);
    SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
    ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, new PersistenceContextInitializerImpl());
    BasicComponentRegistry bcr = gcr.getComponent(BasicComponentRegistry.class);
    InternalCacheRegistry internalCacheRegistry = bcr.getComponent(InternalCacheRegistry.class).wired();
    internalCacheRegistry.registerInternalCache(SCRIPT_CACHE, getScriptCacheConfiguration(gc).build(), EnumSet.of(InternalCacheRegistry.Flag.USER, InternalCacheRegistry.Flag.PROTECTED, InternalCacheRegistry.Flag.PERSISTENT, InternalCacheRegistry.Flag.GLOBAL));
}
Also used : SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry)

Example 14 with InternalCacheRegistry

use of org.infinispan.registry.InternalCacheRegistry 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 15 with InternalCacheRegistry

use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.

the class CheckAddressTask method stop.

@Override
public void stop() {
    if (log.isDebugEnabled())
        log.debugf("Stopping server %s listening at %s:%d", getQualifiedName(), configuration.host(), configuration.port());
    AggregateCompletionStage<Void> removeAllStage = CompletionStages.aggregateCompletionStage();
    if (removeCacheListener != null) {
        removeAllStage.dependsOn(SecurityActions.removeListenerAsync(cacheManager, removeCacheListener));
    }
    if (viewChangeListener != null) {
        removeAllStage.dependsOn(SecurityActions.removeListenerAsync(cacheManager, viewChangeListener));
    }
    if (topologyChangeListener != null) {
        removeAllStage.dependsOn(SecurityActions.removeListenerAsync(addressCache, topologyChangeListener));
    }
    CompletionStages.join(removeAllStage.freeze());
    if (cacheManager != null && Configurations.isClustered(SecurityActions.getCacheManagerConfiguration(cacheManager))) {
        InternalCacheRegistry internalCacheRegistry = SecurityActions.getGlobalComponentRegistry(cacheManager).getComponent(InternalCacheRegistry.class);
        if (internalCacheRegistry != null)
            internalCacheRegistry.unregisterInternalCache(configuration.topologyCacheName());
    }
    if (scheduledExecutor != null) {
        scheduledExecutor.shutdownNow();
    }
    if (clientListenerRegistry != null)
        clientListenerRegistry.stop();
    if (clientCounterNotificationManager != null)
        clientCounterNotificationManager.stop();
    super.stop();
}
Also used : InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry)

Aggregations

InternalCacheRegistry (org.infinispan.registry.InternalCacheRegistry)20 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)5 AdvancedCache (org.infinispan.AdvancedCache)4 Cache (org.infinispan.Cache)4 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)4 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 SerializationContextRegistry (org.infinispan.marshall.protostream.impl.SerializationContextRegistry)3 LocalQueryStatistics (org.infinispan.query.core.stats.impl.LocalQueryStatistics)3 AdvancedExternalizer (org.infinispan.commons.marshall.AdvancedExternalizer)2 AggregatedClassLoader (org.infinispan.commons.util.AggregatedClassLoader)2 CacheMode (org.infinispan.configuration.cache.CacheMode)2 Configuration (org.infinispan.configuration.cache.Configuration)2 GlobalComponentRegistry (org.infinispan.factories.GlobalComponentRegistry)2 ReflectionEntityNamesResolver (org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver)2 KeyTransformationHandler (org.infinispan.query.backend.KeyTransformationHandler)2 IndexStatistics (org.infinispan.query.core.stats.IndexStatistics)2 LocalIndexStatistics (org.infinispan.query.stats.impl.LocalIndexStatistics)2 SearchMapping (org.infinispan.search.mapper.mapping.SearchMapping)2 TestResponse (org.infinispan.server.hotrod.test.TestResponse)2