Search in sources :

Example 1 with CounterManagerConfiguration

use of org.infinispan.counter.configuration.CounterManagerConfiguration in project infinispan by infinispan.

the class ConfigurationTest method testReliability.

public void testReliability() {
    final GlobalConfigurationBuilder builder = defaultGlobalConfigurationBuilder(false);
    final CounterManagerConfiguration config = builder.addModule(CounterManagerConfigurationBuilder.class).reliability(Reliability.AVAILABLE).create();
    TestingUtil.withCacheManager(() -> buildCacheManager(builder), cacheManager -> {
        Configuration cacheConfiguration = getCounterCacheConfiguration(cacheManager);
        assertCounterAndCacheConfiguration(config, cacheConfiguration);
    });
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) StrongCounterConfiguration(org.infinispan.counter.configuration.StrongCounterConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) AbstractCounterConfiguration(org.infinispan.counter.configuration.AbstractCounterConfiguration) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) CounterConfiguration(org.infinispan.counter.api.CounterConfiguration) WeakCounterConfiguration(org.infinispan.counter.configuration.WeakCounterConfiguration) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration)

Example 2 with CounterManagerConfiguration

use of org.infinispan.counter.configuration.CounterManagerConfiguration in project infinispan by infinispan.

the class ConfigurationTest method testDefaultConfiguration.

public void testDefaultConfiguration() {
    TestingUtil.withCacheManager(() -> buildCacheManager(defaultGlobalConfigurationBuilder(false)), cacheManager -> {
        CounterManagerConfiguration configuration = CounterManagerConfigurationBuilder.defaultConfiguration();
        Configuration cacheConfiguration = getCounterCacheConfiguration(cacheManager);
        assertCounterAndCacheConfiguration(configuration, cacheConfiguration);
    });
}
Also used : StrongCounterConfiguration(org.infinispan.counter.configuration.StrongCounterConfiguration) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) AbstractCounterConfiguration(org.infinispan.counter.configuration.AbstractCounterConfiguration) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) CounterConfiguration(org.infinispan.counter.api.CounterConfiguration) WeakCounterConfiguration(org.infinispan.counter.configuration.WeakCounterConfiguration) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration)

Example 3 with CounterManagerConfiguration

use of org.infinispan.counter.configuration.CounterManagerConfiguration 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);
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) SerializationContextRegistry(org.infinispan.marshall.protostream.impl.SerializationContextRegistry) PersistenceContextInitializerImpl(org.infinispan.counter.impl.persistence.PersistenceContextInitializerImpl) InternalCacheRegistry(org.infinispan.registry.InternalCacheRegistry) AdvancedExternalizer(org.infinispan.commons.marshall.AdvancedExternalizer) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration)

Example 4 with CounterManagerConfiguration

use of org.infinispan.counter.configuration.CounterManagerConfiguration in project infinispan by infinispan.

the class CounterResource method createCounterConfiguration.

private CounterConfiguration createCounterConfiguration(String json) {
    try (ConfigurationReader reader = ConfigurationReader.from(json).withType(APPLICATION_JSON).build()) {
        ConfigurationBuilderHolder holder = invocationHelper.getParserRegistry().parse(reader, new ConfigurationBuilderHolder());
        CounterManagerConfigurationBuilder counterModule = holder.getGlobalConfigurationBuilder().module(CounterManagerConfigurationBuilder.class);
        CounterManagerConfiguration configuration = counterModule.create();
        return ConvertUtil.parsedConfigToConfig(configuration.counters().values().iterator().next());
    }
}
Also used : ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) CounterManagerConfigurationBuilder(org.infinispan.counter.configuration.CounterManagerConfigurationBuilder) ConfigurationReader(org.infinispan.commons.configuration.io.ConfigurationReader) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration)

Example 5 with CounterManagerConfiguration

use of org.infinispan.counter.configuration.CounterManagerConfiguration in project infinispan by infinispan.

the class ConfigurationSerializerTest method compareExtraGlobalConfiguration.

@Override
protected void compareExtraGlobalConfiguration(GlobalConfiguration configurationBefore, GlobalConfiguration configurationAfter) {
    CounterManagerConfiguration configBefore = configurationBefore.module(CounterManagerConfiguration.class);
    CounterManagerConfiguration configAfter = configurationAfter.module(CounterManagerConfiguration.class);
    assertEquals(configBefore.numOwners(), configAfter.numOwners());
    assertEquals(configBefore.reliability(), configAfter.reliability());
    Map<String, AbstractCounterConfiguration> counterConfigBefore = configBefore.counters();
    Map<String, AbstractCounterConfiguration> counterConfigAfter = configAfter.counters();
    assertSameStrongCounterConfiguration(counterConfigBefore.get("c1"), counterConfigAfter.get("c1"));
    assertSameStrongCounterConfiguration(counterConfigBefore.get("c2"), counterConfigAfter.get("c2"));
    assertSameStrongCounterConfiguration(counterConfigBefore.get("c3"), counterConfigAfter.get("c3"));
    assertSameStrongCounterConfiguration(counterConfigBefore.get("c4"), counterConfigAfter.get("c4"));
    assertSameWeakCounterConfiguration(counterConfigBefore.get("c5"), counterConfigAfter.get("c5"));
}
Also used : AbstractCounterConfiguration(org.infinispan.counter.configuration.AbstractCounterConfiguration) CounterManagerConfiguration(org.infinispan.counter.configuration.CounterManagerConfiguration)

Aggregations

CounterManagerConfiguration (org.infinispan.counter.configuration.CounterManagerConfiguration)9 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)6 AbstractCounterConfiguration (org.infinispan.counter.configuration.AbstractCounterConfiguration)6 Configuration (org.infinispan.configuration.cache.Configuration)4 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)4 CounterConfiguration (org.infinispan.counter.api.CounterConfiguration)4 StrongCounterConfiguration (org.infinispan.counter.configuration.StrongCounterConfiguration)4 WeakCounterConfiguration (org.infinispan.counter.configuration.WeakCounterConfiguration)4 ConfigurationBuilderHolder (org.infinispan.configuration.parsing.ConfigurationBuilderHolder)2 CounterManagerConfigurationBuilder (org.infinispan.counter.configuration.CounterManagerConfigurationBuilder)2 ConfigurationReader (org.infinispan.commons.configuration.io.ConfigurationReader)1 AdvancedExternalizer (org.infinispan.commons.marshall.AdvancedExternalizer)1 ParserRegistry (org.infinispan.configuration.parsing.ParserRegistry)1 EmbeddedCounterManagerFactory.asCounterManager (org.infinispan.counter.EmbeddedCounterManagerFactory.asCounterManager)1 CounterManager (org.infinispan.counter.api.CounterManager)1 PersistenceContextInitializerImpl (org.infinispan.counter.impl.persistence.PersistenceContextInitializerImpl)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 SerializationContextRegistry (org.infinispan.marshall.protostream.impl.SerializationContextRegistry)1