use of org.infinispan.counter.exception.CounterOutOfBoundsException in project infinispan by infinispan.
the class TestStrongCounter method executeOp.
private <T> CompletableFuture<T> executeOp(CounterOp op, BiConsumer<CompletableFuture<T>, TestResponse> responseHandler, BooleanSupplier canReachUpperBound) {
TestResponse response = client.execute(op);
CompletableFuture<T> future = new CompletableFuture<>();
switch(response.getStatus()) {
case Success:
responseHandler.accept(future, response);
break;
case OperationNotExecuted:
responseHandler.accept(future, response);
break;
case KeyDoesNotExist:
future.completeExceptionally(new IllegalStateException("Counter Not Found!"));
break;
case ServerError:
future.completeExceptionally(new CounterException(((TestErrorResponse) response).msg));
break;
case NotExecutedWithPrevious:
future.completeExceptionally(canReachUpperBound.getAsBoolean() ? new CounterOutOfBoundsException(format(FORMAT_MESSAGE, UPPER_BOUND)) : new CounterOutOfBoundsException(format(FORMAT_MESSAGE, LOWER_BOUND)));
break;
default:
future.completeExceptionally(new Exception("unknown response " + response));
}
return future;
}
Aggregations