CounterConfiguration$Builder
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.infinispan.counter.api.CounterConfiguration$Builder(Showing top 15 results out of 315)

  • Common ways to obtain CounterConfiguration$Builder
private void myMethod () {
CounterConfiguration$Builder c =
  • CounterType type;CounterConfiguration.builder(type)
  • AI code suggestions by Codota
}
origin: infinispan/infinispan

@Override
protected List<CounterConfiguration> configurationToTest() {
 return Arrays.asList(
    CounterConfiguration.builder(CounterType.WEAK).initialValue(10).concurrencyLevel(10).build(),
    CounterConfiguration.builder(CounterType.WEAK).initialValue(20).concurrencyLevel(20).build(),
    CounterConfiguration.builder(CounterType.WEAK).build()
 );
}
origin: infinispan/infinispan

private void setStorage(byte flags) {
 Storage storage = decodeStorage(flags);
 builder.storage(storage);
 logDecoded("storage", storage);
}
origin: infinispan/infinispan

private void doCreationTest(String name, CounterConfiguration config) {
 List<CounterManager> remoteCounterManagers = allRemoteCounterManagerSupplier.get();
 assertTrue(remoteCounterManagers.get(0).defineCounter(name, config));
 remoteCounterManagers.forEach(cm -> assertFalse(cm.defineCounter(name, builder(CounterType.WEAK).build())));
 remoteCounterManagers.forEach(cm -> assertTrue(cm.isDefined(name)));
 remoteCounterManagers.forEach(cm -> assertEquals(config, cm.getConfiguration(name)));
 //test single embedded counter manager to check if everything is correctly stored
 EmbeddedCacheManager cacheManager = cacheManagerSupplier.get();
 CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager(cacheManager);
 assertTrue(counterManager.isDefined(name));
 assertEquals(config, counterManager.getConfiguration(name));
}
origin: infinispan/infinispan

public void testRemove() {
 checkRemove("A", builder(CounterType.WEAK).initialValue(10).build(), 121, 20,
    s -> addToWeakCounter(s, 111),
    s -> addToWeakCounter(s, 10),
    this::getWeakCounterValue);
 checkRemove("B", builder(CounterType.UNBOUNDED_STRONG).initialValue(-10).build(), -11, -9,
    s -> addToStrongCounter(s, -1, false),
    s -> addToStrongCounter(s, 1, false),
    this::getStrongCounterValue);
}
origin: infinispan/infinispan

  @Override
  protected TestCounter createCounter(CounterManager counterManager, String counterName) {
   counterManager.defineCounter(counterName, CounterConfiguration.builder(CounterType.UNBOUNDED_STRONG).build());
   return new StrongTestCounter(counterManager.getStrongCounter(counterName));
  }
}
origin: infinispan/infinispan

@Override
public void testUpperBoundedStrongCounter(Method method) {
 final Random random = generateRandom();
 final String counterName = method.getName();
 CounterConfiguration config = builder(CounterType.BOUNDED_STRONG)
    .initialValue(5)
    .upperBound(15)
    .storage(random.nextBoolean() ? Storage.VOLATILE : Storage.PERSISTENT)
    .build();
 doCreationTest(counterName, config);
}
origin: infinispan/infinispan

private void setUpperBound(long value) {
 builder.upperBound(value);
 decodeState = DecodeState.DECODE_INITIAL_VALUE;
 logDecoded("upper-bound", value);
}
origin: infinispan/infinispan

public void testGetConfiguration() {
 assertConfiguration("A", createWeakCounterProperties(),
    builder(CounterType.WEAK).initialValue(10).concurrencyLevel(1).build());
 assertConfiguration("B", createUnboundedCounterProperties(),
    builder(CounterType.UNBOUNDED_STRONG).initialValue(5).build());
 assertConfiguration("C", createBoundedCounterProperties(),
    builder(CounterType.BOUNDED_STRONG).initialValue(5).lowerBound(0).upperBound(10).build());
}
origin: infinispan/infinispan

@Override
protected StrongTestCounter createCounter(CounterManager counterManager, String counterName, long initialValue) {
 counterManager.defineCounter(counterName,
    CounterConfiguration.builder(CounterType.UNBOUNDED_STRONG).initialValue(initialValue).build());
 return new StrongTestCounter(counterManager.getStrongCounter(counterName));
}
origin: infinispan/infinispan

public void testGetValueAndReset() throws Exception {
 checkValueAndReset("A", builder(CounterType.WEAK).initialValue(10).build(), 20,
    s -> addToWeakCounter(s, 10),
    this::resetWeakCounter);
 checkValueAndReset("B", builder(CounterType.UNBOUNDED_STRONG).initialValue(-10).build(), 5,
    s -> addToStrongCounter(s, 15, false),
    this::resetStrongCounter);
 checkValueAndReset("C", builder(CounterType.BOUNDED_STRONG).initialValue(1).lowerBound(0).upperBound(2).build(),
    2,
    s -> addToStrongCounter(s, 3, true),
    this::resetStrongCounter);
}
origin: infinispan/infinispan

  @Override
  protected WeakTestCounter createCounter(CounterManager counterManager, String counterName, long initialValue) {
   counterManager.defineCounter(counterName,
      CounterConfiguration.builder(CounterType.WEAK).initialValue(initialValue).concurrencyLevel(4).build());
   return new WeakTestCounter(counterManager.getWeakCounter(counterName));
  }
}
origin: infinispan/infinispan

@Override
List<CounterConfiguration> configurationsToTest() {
 return asList(
    builder(UNBOUNDED_STRONG).initialValue(5).build(),
    builder(BOUNDED_STRONG).initialValue(0).lowerBound(-1).upperBound(1).build()
 );
}
origin: infinispan/infinispan

private static WeakCounterImpl getCounter(EmbeddedCacheManager manager, String counterName) {
 CounterManager counterManager = asCounterManager(manager);
 counterManager
    .defineCounter(counterName, CounterConfiguration.builder(CounterType.WEAK).concurrencyLevel(128).build());
 return (WeakCounterImpl) counterManager.getWeakCounter(counterName);
}
origin: infinispan/infinispan

@Override
public void testUnboundedStrongCounter(Method method) {
 final Random random = generateRandom();
 final String counterName = method.getName();
 CounterConfiguration config = builder(CounterType.UNBOUNDED_STRONG)
    .initialValue(random.nextInt())
    .storage(random.nextBoolean() ? Storage.VOLATILE : Storage.PERSISTENT)
    .build();
 doCreationTest(counterName, config);
}
origin: infinispan/infinispan

@Override
void define(CounterManager manager, String name) {
 manager.defineCounter(name,
    builder(CounterType.BOUNDED_STRONG).initialValue(10).lowerBound(0).upperBound(20).build());
}
org.infinispan.counter.apiCounterConfiguration$Builder

Javadoc

The builder of CounterConfiguration.

Most used methods

  • build
  • initialValue
    Sets the initial value. The default value is zero.
  • storage
    Sets the storage mode of the counter. The default value is Storage#VOLATILE.
  • concurrencyLevel
    Sets the concurrency level of the counter. Only for CounterType#WEAK. The concurrency level set
  • lowerBound
    Sets the lower bound (inclusive) of the counter. Only for CounterType#BOUNDED_STRONG counters. The
  • upperBound
    Sets the upper bound (inclusive) of the counter. Only for CounterType#BOUNDED_STRONG counters. The
  • <init>

Popular classes and methods

  • startActivity (Activity)
  • setScale (BigDecimal)
    Returns a new BigDecimal instance with the specified scale. If the new scale is greater than the old
  • Window (java.awt)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ArrayList (java.util)
    Resizable-array implementation of the List interface.
  • HashSet (java.util)
    This class implements the Set interface, backed by a java.util.HashMap.
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)