Search in sources :

Example 6 with InternalCacheRegistry

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();
        }
    }
}
Also used : SerializationContext(org.infinispan.protostream.SerializationContext) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) EntityLoader(org.infinispan.query.impl.EntityLoader) SearchMappingCommonBuilding(org.infinispan.search.mapper.mapping.SearchMappingCommonBuilding) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) LocalIndexStatistics(org.infinispan.query.stats.impl.LocalIndexStatistics) IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) KeyTransformationHandler(org.infinispan.query.backend.KeyTransformationHandler) LocalQueryStatistics(org.infinispan.query.core.stats.impl.LocalQueryStatistics) Cache(org.infinispan.Cache) AdvancedCache(org.infinispan.AdvancedCache)

Example 7 with InternalCacheRegistry

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));
        }
    }
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) CacheException(org.infinispan.commons.CacheException) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry)

Example 8 with InternalCacheRegistry

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());
}
Also used : InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry)

Example 9 with InternalCacheRegistry

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);
    }
}
Also used : ReflectionEntityNamesResolver(org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) Cache(org.infinispan.Cache) AdvancedCache(org.infinispan.AdvancedCache) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 10 with InternalCacheRegistry

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;
    }
}
Also used : RecoveryManager(org.infinispan.transaction.xa.recovery.RecoveryManager) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

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