use of org.infinispan.server.hotrod.counter.op.CounterListenerOp in project infinispan by infinispan.
the class TestCounterNotificationManager method add.
private List<UserListener<?>> add(String counterName, List<UserListener<?>> list, UserListener<?> listener) {
if (list == null) {
CounterListenerOp op = createListener(client.protocolVersion(), counterName, listenerId.getBytes());
TestResponse response = client.execute(op);
switch(response.getStatus()) {
case Success:
break;
case OperationNotExecuted:
break;
case KeyDoesNotExist:
throw new CounterException("Counter " + counterName + " doesn't exist");
default:
throw new IllegalStateException("Unknown status " + response.getStatus());
}
list = new CopyOnWriteArrayList<>();
}
list.add(listener);
return list;
}
use of org.infinispan.server.hotrod.counter.op.CounterListenerOp in project infinispan by infinispan.
the class TestCounterNotificationManager method remove.
private void remove(String counterName, UserListener<?> listener) {
userListenerList.computeIfPresent(counterName, (name, list) -> {
list.remove(listener);
if (list.isEmpty()) {
CounterListenerOp op = removeListener(client.protocolVersion(), counterName, listenerId.getBytes());
TestResponse response = client.execute(op);
switch(response.getStatus()) {
case Success:
break;
case OperationNotExecuted:
break;
case KeyDoesNotExist:
throw new CounterException("Counter " + counterName + " doesn't exist");
default:
throw new IllegalStateException("Unknown status " + response.getStatus());
}
return null;
}
return list;
});
}
Aggregations