use of org.infinispan.counter.configuration.AbstractCounterConfiguration in project infinispan by infinispan.
the class ConfigurationTest method assertUnboundedStrongCounter.
private void assertUnboundedStrongCounter(CounterManagerConfiguration config) {
for (AbstractCounterConfiguration counterConfig : config.counters().values()) {
if (counterConfig.name().equals("unbounded-strong-1")) {
assertTrue(counterConfig instanceof StrongCounterConfiguration);
assertEquals(1, counterConfig.initialValue());
assertEquals(-1, ((StrongCounterConfiguration) counterConfig).lifespan());
assertEquals(Storage.VOLATILE, counterConfig.storage());
return;
}
}
fail();
}
use of org.infinispan.counter.configuration.AbstractCounterConfiguration in project infinispan by infinispan.
the class ConfigurationTest method assertWeakCounter.
private void assertWeakCounter(CounterManagerConfiguration config) {
for (AbstractCounterConfiguration counterConfig : config.counters().values()) {
if (counterConfig.name().equals("weak-5")) {
assertTrue(counterConfig instanceof WeakCounterConfiguration);
assertEquals(5, counterConfig.initialValue());
assertEquals(Storage.VOLATILE, counterConfig.storage());
assertEquals(10, ((WeakCounterConfiguration) counterConfig).concurrencyLevel());
return;
}
}
fail();
}
use of org.infinispan.counter.configuration.AbstractCounterConfiguration in project infinispan by infinispan.
the class CounterResourceTest method createCounter.
private void createCounter(String name, CounterConfiguration configuration) {
AbstractCounterConfiguration config = ConvertUtil.configToParsedConfig(name, configuration);
RestEntity restEntity = RestEntity.create(APPLICATION_JSON, counterConfigToJson(config));
CompletionStage<RestResponse> response = client.counter(name).create(restEntity);
assertThat(response).isOk();
}
use of org.infinispan.counter.configuration.AbstractCounterConfiguration in project infinispan by infinispan.
the class CounterResource method getConfig.
private CompletionStage<RestResponse> getConfig(RestRequest request) {
NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder();
String counterName = request.variables().get("counterName");
return invocationHelper.getCounterManager().getConfigurationAsync(counterName).thenApply(cfg -> {
if (cfg == null)
return responseBuilder.status(NOT_FOUND).build();
AbstractCounterConfiguration parsedConfig = ConvertUtil.configToParsedConfig(counterName, cfg);
CounterConfigurationSerializer ccs = new CounterConfigurationSerializer();
StringBuilderWriter sw = new StringBuilderWriter();
try (ConfigurationWriter w = ConfigurationWriter.to(sw).withType(APPLICATION_JSON).build()) {
ccs.serializeConfiguration(w, parsedConfig);
}
return responseBuilder.entity(sw.toString()).contentType(APPLICATION_JSON).build();
});
}
Aggregations