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);
});
}
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);
});
}
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);
}
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());
}
}
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"));
}
Aggregations