org.infinispan.counter.configuration.WeakCounterConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-clustered-counter Show documentation
Show all versions of infinispan-clustered-counter Show documentation
Infinispan Clustered Counter module
package org.infinispan.counter.configuration;
import static org.infinispan.counter.logging.Log.CONTAINER;
import org.infinispan.commons.configuration.Combine;
import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
/**
* {@link org.infinispan.counter.api.WeakCounter} configuration.
*
* @author Pedro Ruivo
* @since 9.0
*/
public class WeakCounterConfiguration extends AbstractCounterConfiguration {
static final AttributeDefinition CONCURRENCY_LEVEL = AttributeDefinition
.builder(Attribute.CONCURRENCY_LEVEL, 16)
.validator(value -> {
if (value < 1) {
throw CONTAINER.invalidConcurrencyLevel(value);
}
})
.immutable()
.build();
WeakCounterConfiguration(AttributeSet attributes) {
super(attributes);
}
public static AttributeSet attributeDefinitionSet() {
return new AttributeSet(WeakCounterConfiguration.class, AbstractCounterConfiguration.attributeDefinitionSet(),
CONCURRENCY_LEVEL);
}
public int concurrencyLevel() {
return attributes.attribute(CONCURRENCY_LEVEL).get();
}
@Override
CounterConfigurationBuilder, ?> toBuilder(CounterManagerConfigurationBuilder manager) {
WeakCounterConfigurationBuilder builder = new WeakCounterConfigurationBuilder(manager);
builder.attributes.read(attributes, Combine.DEFAULT);
return builder;
}
}