use of org.infinispan.counter.api.CounterConfiguration in project infinispan by infinispan.
the class MultiResourceTest method createCounters.
private void createCounters(String... names) {
CounterConfiguration configuration = CounterConfiguration.builder(CounterType.BOUNDED_STRONG).lowerBound(0).upperBound(100).initialValue(0).build();
for (String counterName : names) {
AbstractCounterConfiguration config = ConvertUtil.configToParsedConfig(counterName, configuration);
RestResponse response = join(client.counter(counterName).create(RestEntity.create(APPLICATION_JSON, counterConfigToJson(config))));
ResponseAssertion.assertThat(response).isOk();
}
}
use of org.infinispan.counter.api.CounterConfiguration in project quarkus by quarkusio.
the class TestServlet method incrementCounter.
@Path("incr/{id}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public CompletionStage<Long> incrementCounter(@PathParam("id") String id) {
ensureStart();
CounterConfiguration configuration = counterManager.getConfiguration(id);
if (configuration == null) {
configuration = CounterConfiguration.builder(CounterType.BOUNDED_STRONG).build();
counterManager.defineCounter(id, configuration);
}
StrongCounter strongCounter = counterManager.getStrongCounter(id);
return strongCounter.incrementAndGet();
}
use of org.infinispan.counter.api.CounterConfiguration in project infinispan by infinispan.
the class RemoteCounterManager method createStrongCounter.
private StrongCounter createStrongCounter(String counterName) {
CounterConfiguration configuration = getConfiguration(counterName);
if (configuration == null) {
throw commonsLog.undefinedCounter(counterName);
}
assertStrongCounter(configuration);
return new StrongCounterImpl(counterName, configuration, factory, notificationManager);
}
use of org.infinispan.counter.api.CounterConfiguration in project infinispan by infinispan.
the class RemoteCounterManager method createWeakCounter.
private WeakCounter createWeakCounter(String counterName) {
CounterConfiguration configuration = getConfiguration(counterName);
if (configuration == null) {
throw commonsLog.undefinedCounter(counterName);
}
assertWeakCounter(configuration);
return new WeakCounterImpl(counterName, configuration, factory, notificationManager);
}
use of org.infinispan.counter.api.CounterConfiguration in project infinispan by infinispan.
the class AbstractCounterTest method testGetConfigurationAndGetName.
public void testGetConfigurationAndGetName(Method method) {
final String counterNamePrefix = method.getName();
final CounterManager counterManager = counterManager(0);
int suffix = 0;
for (CounterConfiguration configuration : configurationToTest()) {
T counter = createCounter(counterManager, counterNamePrefix + suffix, configuration);
assertEquals(configuration, counter.getConfiguration());
assertEquals(counterNamePrefix + suffix, counter.getName());
suffix++;
}
}
Aggregations