use of org.infinispan.counter.configuration.CounterManagerConfigurationBuilder in project infinispan by infinispan.
the class RestartCounterTest method configure.
@Override
protected GlobalConfigurationBuilder configure(int nodeId) {
GlobalConfigurationBuilder builder = GlobalConfigurationBuilder.defaultClusteredBuilder();
builder.globalState().enable().persistentLocation(Paths.get(PERSISTENT_FOLDER, Integer.toString(nodeId)).toString()).temporaryLocation(Paths.get(TEMP_PERSISTENT_FOLDER, Integer.toString(nodeId)).toString()).sharedPersistentLocation(Paths.get(SHARED_PERSISTENT_FOLDER, Integer.toString(nodeId)).toString());
CounterManagerConfigurationBuilder counterBuilder = builder.addModule(CounterManagerConfigurationBuilder.class);
defaultCounters.forEach(counterDefinition -> counterDefinition.define(counterBuilder));
return builder;
}
use of org.infinispan.counter.configuration.CounterManagerConfigurationBuilder in project infinispan by infinispan.
the class ConfigurationTest method testStrongCounterUpperBound.
public void testStrongCounterUpperBound() {
final GlobalConfigurationBuilder builder = defaultGlobalConfigurationBuilder(false);
CounterManagerConfigurationBuilder counterBuilder = builder.addModule(CounterManagerConfigurationBuilder.class);
counterBuilder.addStrongCounter().name("valid").initialValue(10).upperBound(10);
// no exception!
builder.build();
counterBuilder.clearCounters();
counterBuilder.addStrongCounter().name("valid").initialValue(10).upperBound(11);
builder.build();
counterBuilder.clearCounters();
counterBuilder.addStrongCounter().name("invalid").initialValue(10).upperBound(9);
assertCounterConfigurationException(builder);
}
use of org.infinispan.counter.configuration.CounterManagerConfigurationBuilder in project infinispan by infinispan.
the class ConfigurationTest method testMissingCounterName.
public void testMissingCounterName() {
final GlobalConfigurationBuilder builder = defaultGlobalConfigurationBuilder(false);
CounterManagerConfigurationBuilder counterBuilder = builder.addModule(CounterManagerConfigurationBuilder.class);
counterBuilder.addStrongCounter();
assertCounterConfigurationException(builder);
counterBuilder.clearCounters();
counterBuilder.addWeakCounter();
assertCounterConfigurationException(builder);
}
use of org.infinispan.counter.configuration.CounterManagerConfigurationBuilder in project infinispan by infinispan.
the class ConfigurationTest method testInvalidNumOwner.
public void testInvalidNumOwner() {
final GlobalConfigurationBuilder builder = defaultGlobalConfigurationBuilder(false);
CounterManagerConfigurationBuilder counterBuilder = builder.addModule(CounterManagerConfigurationBuilder.class);
counterBuilder.numOwner(0);
assertCounterConfigurationException(builder);
counterBuilder.numOwner(-1);
assertCounterConfigurationException(builder);
counterBuilder.numOwner(1);
builder.build();
}
use of org.infinispan.counter.configuration.CounterManagerConfigurationBuilder 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());
}
}
Aggregations