All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.counter.configuration.CounterManagerConfiguration Maven / Gradle / Ivy

package org.infinispan.counter.configuration;

import static org.infinispan.counter.logging.Log.CONTAINER;

import java.util.Collections;
import java.util.List;

import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.configuration.serializing.SerializedWith;

/**
 * The {@link org.infinispan.counter.api.CounterManager} configuration.
 * 

* It configures the number of owners (number of copies in the cluster) of a counter and the {@link Reliability} mode. * * @author Pedro Ruivo * @since 9.0 */ @SerializedWith(CounterConfigurationSerializer.class) public class CounterManagerConfiguration { static final AttributeDefinition RELIABILITY = AttributeDefinition .builder("reliability", Reliability.AVAILABLE) .validator(value -> { if (value == null) { throw CONTAINER.invalidReliabilityMode(); } }) .immutable().build(); static final AttributeDefinition NUM_OWNERS = AttributeDefinition.builder("numOwners", 2) .validator(value -> { if (value < 1) { throw CONTAINER.invalidNumOwners(value); } }) .immutable().build(); private final AttributeSet attributes; private final List counters; CounterManagerConfiguration(AttributeSet attributes, List counters) { this.attributes = attributes; this.counters = counters; } static AttributeSet attributeDefinitionSet() { return new AttributeSet(CounterManagerConfiguration.class, NUM_OWNERS, RELIABILITY); } public int numOwners() { return attributes.attribute(NUM_OWNERS).get(); } public Reliability reliability() { return attributes.attribute(RELIABILITY).get(); } AttributeSet attributes() { return attributes; } public List counters() { return Collections.unmodifiableList(counters); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy