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

org.infinispan.hotrod.impl.counter.BaseCounter Maven / Gradle / Ivy

There is a newer version: 14.0.32.Final
Show newest version
package org.infinispan.hotrod.impl.counter;

import java.util.concurrent.CompletableFuture;

import org.infinispan.counter.api.CounterConfiguration;
import org.infinispan.counter.api.CounterListener;
import org.infinispan.counter.api.Handle;

public class BaseCounter {
   protected final String name;
   protected final CounterConfiguration configuration;
   protected final CounterOperationFactory factory;
   private final NotificationManager notificationManager;

   BaseCounter(CounterConfiguration configuration, String name, CounterOperationFactory factory,
         NotificationManager notificationManager) {
      this.configuration = configuration;
      this.name = name;
      this.factory = factory;
      this.notificationManager = notificationManager;
   }

   public String getName() {
      return name;
   }

   public CompletableFuture reset() {
      return factory.newResetOperation(name, useConsistentHash()).execute().toCompletableFuture();
   }

   public CompletableFuture remove() {
      return factory.newRemoveOperation(name, useConsistentHash()).execute().toCompletableFuture();
   }

   public CounterConfiguration getConfiguration() {
      return configuration;
   }

   public  Handle addListener(T listener) {
      return notificationManager.addListener(name, listener);
   }

   boolean useConsistentHash() {
      return false;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy