use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class ClusterRoleMapper method setContext.
@Override
public void setContext(PrincipalRoleMapperContext 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 registry = SecurityActions.getGlobalComponentRegistry(cacheManager);
InternalCacheRegistry internalCacheRegistry = registry.getComponent(InternalCacheRegistry.class);
internalCacheRegistry.registerInternalCache(CLUSTER_ROLE_MAPPER_CACHE, cfg.build(), EnumSet.of(InternalCacheRegistry.Flag.PERSISTENT));
registry.registerComponent(this, PrincipalRoleMapper.class);
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class DefaultCacheManager method getCacheNames.
@Override
public Set<String> getCacheNames() {
// Get the XML/programmatically defined caches
Set<String> names = new HashSet<>(configurationManager.getDefinedCaches());
// Add the caches created dynamically without explicit config
names.addAll(caches.keySet());
InternalCacheRegistry internalCacheRegistry = globalComponentRegistry.getComponent(InternalCacheRegistry.class);
internalCacheRegistry.filterPrivateCaches(names);
if (names.isEmpty())
return Collections.emptySet();
else
return Immutables.immutableSetWrap(names);
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class CounterModuleLifecycle method cacheManagerStarting.
@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
final Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalConfiguration.serialization().advancedExternalizers();
// Only required by GlobalMarshaller
addAdvancedExternalizer(externalizerMap, ResetFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, ReadFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, InitializeCounterFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, AddFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CompareAndSwapFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CreateAndCASFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CreateAndAddFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, RemoveFunction.EXTERNALIZER);
BasicComponentRegistry bcr = gcr.getComponent(BasicComponentRegistry.class);
EmbeddedCacheManager cacheManager = bcr.getComponent(EmbeddedCacheManager.class).wired();
InternalCacheRegistry internalCacheRegistry = bcr.getComponent(InternalCacheRegistry.class).running();
SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, new PersistenceContextInitializerImpl());
CounterManagerConfiguration counterManagerConfiguration = extractConfiguration(globalConfiguration);
if (gcr.getGlobalConfiguration().isClustered()) {
// only attempts to create the caches if the cache manager is clustered.
registerCounterCache(internalCacheRegistry, counterManagerConfiguration);
} else {
// local only cache manager.
registerLocalCounterCache(internalCacheRegistry);
}
registerCounterNotificationManager(bcr);
registerCounterManager(cacheManager, bcr, globalConfiguration);
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class HotRodSingleClusteredTest method testLoopbackPutOnProtectedCache.
public void testLoopbackPutOnProtectedCache(Method m) {
InternalCacheRegistry internalCacheRegistry = manager(0).getGlobalComponentRegistry().getComponent(InternalCacheRegistry.class);
internalCacheRegistry.registerInternalCache("MyInternalCache", hotRodCacheConfiguration().build(), EnumSet.of(InternalCacheRegistry.Flag.USER, InternalCacheRegistry.Flag.PROTECTED));
TestResponse resp = hotRodClient.execute(0xA0, (byte) 0x01, "MyInternalCache", k(m), 0, 0, v(m), 0, (byte) 1, 0);
assertEquals(Success, resp.status);
}
use of org.infinispan.registry.InternalCacheRegistry in project infinispan by infinispan.
the class CheckAddressTask method checkCacheIsAvailable.
private boolean checkCacheIsAvailable(String cacheName, byte hotRodVersion, long messageId) {
InternalCacheRegistry icr = SecurityActions.getGlobalComponentRegistry(cacheManager).getComponent(InternalCacheRegistry.class);
boolean keep;
if (icr.isPrivateCache(cacheName)) {
throw new RequestParsingException(String.format("Remote requests are not allowed to private caches. Do no send remote requests to cache '%s'", cacheName), hotRodVersion, messageId);
} else if (icr.internalCacheHasFlag(cacheName, InternalCacheRegistry.Flag.PROTECTED)) {
// We want to make sure the cache access is checked every time, so don't store it as a "known" cache.
// More expensive, but these caches should not be accessed frequently
keep = false;
} else if (!cacheName.isEmpty() && !cacheManager.getCacheNames().contains(cacheName)) {
throw new CacheNotFoundException(String.format("Cache with name '%s' not found amongst the configured caches", cacheName), hotRodVersion, messageId);
} else if (cacheName.isEmpty() && !hasDefaultCache) {
throw new CacheNotFoundException("Default cache requested but not configured", hotRodVersion, messageId);
} else {
keep = true;
}
return keep;
}
Aggregations