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

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

There is a newer version: 15.1.0.Dev03
Show newest version
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;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy