org.infinispan.hotrod.impl.counter.BaseCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infinispan-hotrod-jakarta Show documentation
Show all versions of infinispan-hotrod-jakarta Show documentation
Infinispan Hot Rod Client Jakarta EE
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;
}
}