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