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

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

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.client.hotrod.counter.impl;

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();
   }

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

   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