use of io.lettuce.core.RedisCommandExecutionException in project api-layer by zowe.
the class RedisOperatorTest method givenRedisExecutionExceptionNotOutOfMemory_thenThrowRetryableRedisException.
@Test
void givenRedisExecutionExceptionNotOutOfMemory_thenThrowRetryableRedisException() throws ExecutionException, InterruptedException {
RedisFuture<Boolean> future = (RedisFuture<Boolean>) mock(RedisFuture.class);
when(redisCommands.hsetnx(any(), any(), any())).thenReturn(future);
when(future.get()).thenThrow(new ExecutionException(new RedisCommandExecutionException("error")));
assertThrows(RetryableRedisException.class, () -> underTest.create(REDIS_ENTRY));
}
use of io.lettuce.core.RedisCommandExecutionException in project lettuce-core by lettuce-io.
the class AsyncCommandUnitTests method awaitAllWithExecutionException.
@Test
void awaitAllWithExecutionException() {
sut.completeExceptionally(new RedisCommandExecutionException("error"));
assertThatThrownBy(() -> Futures.await(0, TimeUnit.SECONDS, sut)).isInstanceOf(RedisException.class);
}
use of io.lettuce.core.RedisCommandExecutionException in project lettuce-core by lettuce-io.
the class RedisCommandsIntegrationTests method doesNotFailIfCommandRetrievalFails.
@Test
void doesNotFailIfCommandRetrievalFails() {
StatefulRedisConnection connectionMock = Mockito.mock(StatefulRedisConnection.class);
RedisCommands commandsMock = Mockito.mock(RedisCommands.class);
when(connectionMock.sync()).thenReturn(commandsMock);
doThrow(new RedisCommandExecutionException("ERR unknown command 'COMMAND'")).when(commandsMock).command();
RedisCommandFactory factory = new RedisCommandFactory(connectionMock);
assertThat(factory).hasFieldOrPropertyWithValue("verifyCommandMethods", false);
}
use of io.lettuce.core.RedisCommandExecutionException in project lettuce-core by lettuce-io.
the class NodeSelectionInvocationHandler method createExecutionException.
private RedisCommandExecutionException createExecutionException(Map<RedisClusterNode, CompletionStage<?>> executions) {
List<RedisClusterNode> failed = new ArrayList<>();
executions.forEach((redisClusterNode, completionStage) -> {
if (!completionStage.toCompletableFuture().isCompletedExceptionally()) {
failed.add(redisClusterNode);
}
});
RedisCommandExecutionException e = ExceptionFactory.createExecutionException("Multi-node command execution failed on node(s): " + getNodeDescription(failed));
executions.forEach((redisClusterNode, completionStage) -> {
CompletableFuture<?> completableFuture = completionStage.toCompletableFuture();
if (completableFuture.isCompletedExceptionally()) {
try {
completableFuture.get();
} catch (Exception innerException) {
if (innerException instanceof ExecutionException) {
e.addSuppressed(innerException.getCause());
} else {
e.addSuppressed(innerException);
}
}
}
});
return e;
}
use of io.lettuce.core.RedisCommandExecutionException in project lettuce-core by lettuce-io.
the class RedisCommandsBatchingIntegrationTests method shouldHandleAsynchronousBatchErrors.
@Test
void shouldHandleAsynchronousBatchErrors() throws Exception {
RedisCommandFactory factory = new RedisCommandFactory(redis.getStatefulConnection());
Batching api = factory.getCommands(Batching.class);
api.setAsync("k1", value);
api.setAsync("k2", value);
api.llen("k2");
api.setAsync("k4", value);
assertThat(redis.get("k1")).isNull();
RedisFuture<Long> llen = api.llenAsync("k4");
llen.await(1, TimeUnit.SECONDS);
assertThat(redis.get("k1")).isEqualTo(value);
assertThat(redis.get("k4")).isEqualTo(value);
try {
Futures.await(1, TimeUnit.SECONDS, llen);
fail("Missing RedisCommandExecutionException");
} catch (Exception e) {
assertThat(e).isInstanceOf(RedisCommandExecutionException.class);
}
}
Aggregations