Search in sources :

Example 1 with GlobalComponentRegistry

use of org.infinispan.factories.GlobalComponentRegistry in project radargun by radargun.

the class Infinispan60InternalsExposition method getValues.

@Override
public Map<String, Number> getValues() {
    if (!service.internalsExpositionEnabled) {
        return Collections.EMPTY_MAP;
    }
    Map<String, Number> values = new HashMap<>();
    GlobalComponentRegistry globalComponentRegistry = service.cacheManager.getGlobalComponentRegistry();
    addValues(findTPE(globalComponentRegistry.getComponent(KnownComponentNames.ASYNC_TRANSPORT_EXECUTOR)), "Async Transport Executor", values);
    addValues(findTPE(globalComponentRegistry.getComponent(KnownComponentNames.REMOTE_COMMAND_EXECUTOR)), "Remote Commands Executor", values);
    JGroupsTransport transport = (JGroupsTransport) service.cacheManager.getTransport();
    if (transport != null) {
        TP tp = (TP) transport.getChannel().getProtocolStack().getBottomProtocol();
        addValues((ThreadPoolExecutor) tp.getOOBThreadPool(), "OOB", values);
    }
    return values;
}
Also used : JGroupsTransport(org.infinispan.remoting.transport.jgroups.JGroupsTransport) HashMap(java.util.HashMap) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) TP(org.jgroups.protocols.TP)

Example 2 with GlobalComponentRegistry

use of org.infinispan.factories.GlobalComponentRegistry 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);
}
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 3 with GlobalComponentRegistry

use of org.infinispan.factories.GlobalComponentRegistry in project infinispan by infinispan.

the class HealthImpl method getHealth.

private CacheHealth getHealth(String cacheName) {
    try {
        GlobalComponentRegistry gcr = SecurityActions.getGlobalComponentRegistry(embeddedCacheManager);
        ComponentRegistry cr = gcr.getNamedComponentRegistry(cacheName);
        if (cr == null)
            return new InvalidCacheHealth(cacheName);
        return new CacheHealthImpl(cr);
    } catch (CacheException cacheException) {
        return new InvalidCacheHealth(cacheName);
    }
}
Also used : GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) ComponentRegistry(org.infinispan.factories.ComponentRegistry) CacheException(org.infinispan.commons.CacheException) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry)

Example 4 with GlobalComponentRegistry

use of org.infinispan.factories.GlobalComponentRegistry in project infinispan by infinispan.

the class StartCacheFromListenerTest method testStartSameCache.

public void testStartSameCache() {
    final EmbeddedCacheManager cacheManager = manager(0);
    GlobalComponentRegistry registry = TestingUtil.extractGlobalComponentRegistry(cacheManager);
    List<ModuleLifecycle> lifecycles = new LinkedList<>();
    TestingUtil.replaceField(lifecycles, "moduleLifecycles", registry, GlobalComponentRegistry.class);
    lifecycles.add(new ModuleLifecycle() {

        @Override
        public void cacheStarted(ComponentRegistry cr, String cacheName) {
            Cache cache = cacheManager.getCache("single");
            cache.put("k1", "v1");
        }
    });
    Cache<Object, Object> some = cacheManager.getCache("single");
    some.put("k2", "v2");
    assertEquals("v1", cacheManager.getCache("single").get("k1"));
    assertEquals("v2", cacheManager.getCache("single").get("k2"));
}
Also used : ModuleLifecycle(org.infinispan.lifecycle.ModuleLifecycle) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) ComponentRegistry(org.infinispan.factories.ComponentRegistry) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) LinkedList(java.util.LinkedList) Cache(org.infinispan.Cache)

Example 5 with GlobalComponentRegistry

use of org.infinispan.factories.GlobalComponentRegistry in project infinispan by infinispan.

the class InfinispanRegionFactory method getCacheCommandFactory.

private CacheCommandFactory getCacheCommandFactory() {
    final GlobalComponentRegistry globalCr = manager.getGlobalComponentRegistry();
    final Map<Byte, ModuleCommandFactory> factories = globalCr.getComponent("org.infinispan.modules.command.factories");
    for (ModuleCommandFactory factory : factories.values()) {
        if (factory instanceof CacheCommandFactory) {
            return (CacheCommandFactory) factory;
        }
    }
    throw log.cannotInstallCommandFactory();
}
Also used : ModuleCommandFactory(org.infinispan.commands.module.ModuleCommandFactory) CacheCommandFactory(org.infinispan.hibernate.cache.commons.util.CacheCommandFactory) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry)

Aggregations

GlobalComponentRegistry (org.infinispan.factories.GlobalComponentRegistry)26 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)7 ComponentRegistry (org.infinispan.factories.ComponentRegistry)7 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)7 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)7 ConfigurationManager (org.infinispan.configuration.ConfigurationManager)5 Cache (org.infinispan.Cache)4 CacheException (org.infinispan.commons.CacheException)4 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 Transport (org.infinispan.remoting.transport.Transport)4 CacheMode (org.infinispan.configuration.cache.CacheMode)3 Configuration (org.infinispan.configuration.cache.Configuration)3 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)3 ModuleLifecycle (org.infinispan.lifecycle.ModuleLifecycle)3 JGroupsTransport (org.infinispan.remoting.transport.jgroups.JGroupsTransport)3 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Properties (java.util.Properties)2 AdvancedCache (org.infinispan.AdvancedCache)2