use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class LifecycleManager method cacheStarting.
/**
* Registers the interceptor in the ___protobuf_metadata cache before it gets started. Also creates query components
* for user caches.
*/
@Override
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
BasicComponentRegistry gcr = cr.getGlobalComponentRegistry().getComponent(BasicComponentRegistry.class);
LocalQueryStatistics queryStatistics = cr.getComponent(LocalQueryStatistics.class);
if (PROTOBUF_METADATA_CACHE_NAME.equals(cacheName)) {
// a protobuf metadata cache is starting, need to register the interceptor
ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) gcr.getComponent(ProtobufMetadataManager.class).running();
protobufMetadataManager.addProtobufMetadataManagerInterceptor(cr.getComponent(BasicComponentRegistry.class));
}
InternalCacheRegistry icr = gcr.getComponent(InternalCacheRegistry.class).running();
if (!icr.isInternalCache(cacheName)) {
// a stop dependency must be added for each non-internal cache
ProtobufMetadataManagerImpl protobufMetadataManager = (ProtobufMetadataManagerImpl) gcr.getComponent(ProtobufMetadataManager.class).running();
protobufMetadataManager.addCacheDependency(cacheName);
// a remote query manager must be added for each non-internal cache
SerializationContext serCtx = protobufMetadataManager.getSerializationContext();
RemoteQueryManager remoteQueryManager = buildQueryManager(cfg, serCtx, cr);
cr.registerComponent(remoteQueryManager, RemoteQueryManager.class);
SearchMappingCommonBuilding commonBuilding = cr.getComponent(SearchMappingCommonBuilding.class);
SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
if (commonBuilding != null && searchMapping == null) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache().withStorageMediaType().withWrapping(ByteArrayWrapper.class, ProtobufWrapper.class);
KeyTransformationHandler keyTransformationHandler = ComponentRegistryUtils.getKeyTransformationHandler(cache);
EntityLoader<?> entityLoader = new EntityLoader<>(queryStatistics, cache, keyTransformationHandler);
searchMapping = new LazySearchMapping(commonBuilding, entityLoader, serCtx, cache, protobufMetadataManager);
cr.registerComponent(searchMapping, SearchMapping.class);
BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
bcr.replaceComponent(IndexStatistics.class.getName(), new LocalIndexStatistics(), true);
bcr.rewire();
}
}
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class CacheResource method prepareAndValidateBackup.
@Override
public void prepareAndValidateBackup() {
InternalCacheRegistry icr = SecurityActions.getGlobalComponentRegistry(cm).getComponent(InternalCacheRegistry.class);
Set<String> caches = wildcard ? cm.getCacheConfigurationNames() : resources;
for (String cache : caches) {
Configuration config = SecurityActions.getCacheConfiguration(cm, cache);
if (wildcard) {
// For wildcard resources, we ignore internal caches, however explicitly requested internal caches are allowed
if (config == null || config.isTemplate() || icr.isInternalCache(cache) || MEMCACHED_CACHE.equals(cache)) {
continue;
}
resources.add(cache);
} else if (config == null) {
throw log.unableToFindResource(type.toString(), cache);
} else if (config.isTemplate()) {
throw new CacheException(String.format("Unable to backup %s '%s' as it is a template not a cache", type, cache));
}
}
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class RestServerHelper method clear.
public void clear() {
InternalCacheRegistry registry = cacheManager.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
cacheManager.getCacheNames().stream().filter(cacheName -> !registry.isInternalCache(cacheName)).filter(cacheManager::isRunning).forEach(cacheName -> cacheManager.getCache(cacheName).getAdvancedCache().getDataContainer().clear());
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan-quarkus by infinispan.
the class Target_SearchQueryMaker method cacheStarting.
@Substitute
public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
if (cfg.indexing().enabled()) {
Util.unsupportedOperationException("Indexing", "Cache " + cacheName + " has it enabled!");
}
InternalCacheRegistry icr = cr.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
if (!icr.isInternalCache(cacheName) || icr.internalCacheHasFlag(cacheName, InternalCacheRegistry.Flag.QUERYABLE)) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
cr.registerComponent(ObjectReflectionMatcher.create(new ReflectionEntityNamesResolver(getClass().getClassLoader()), null), ObjectReflectionMatcher.class);
cr.registerComponent(new QueryEngine<>(cache, false), QueryEngine.class);
}
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class RecoveryManagerFactory method construct.
@Override
public Object construct(String name) {
if (configuration.transaction().recovery().enabled()) {
String recoveryCacheName = configuration.transaction().recovery().recoveryInfoCacheName();
log.tracef("Using recovery cache name %s", recoveryCacheName);
EmbeddedCacheManager cm = componentRegistry.getGlobalComponentRegistry().getComponent(EmbeddedCacheManager.class);
boolean useDefaultCache = recoveryCacheName.equals(RecoveryConfiguration.DEFAULT_RECOVERY_INFO_CACHE);
// if use a defined cache
if (!useDefaultCache) {
// check to see that the cache is defined
if (!cm.getCacheConfigurationNames().contains(recoveryCacheName)) {
throw new CacheConfigurationException("Recovery cache (" + recoveryCacheName + ") does not exist!!");
}
} else {
InternalCacheRegistry internalCacheRegistry = componentRegistry.getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
internalCacheRegistry.registerInternalCache(recoveryCacheName, getDefaultRecoveryCacheConfig());
}
return (RecoveryManager) buildRecoveryManager(componentRegistry.getCacheName(), recoveryCacheName, cm, useDefaultCache);
} else {
return null;
}
}
Aggregations