io.lettuce.core.RedisException Java Examples
The following examples show how to use
io.lettuce.core.RedisException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractLettuceAccessor.java From sherlock with GNU General Public License v3.0 | 5 votes |
/** * @return a new incremented ID * @throws IOException if an error generating the ID occurs */ protected Integer newId() throws IOException { log.info("Generating a new ID"); try (RedisConnection<String> conn = connect()) { return conn.sync().incr(idName).intValue(); } catch (RedisException e) { log.error("Error while generating new ID!", e); throw new IOException(e.getMessage(), e); } }
Example #2
Source File: AbstractLettuceAccessorTest.java From sherlock with GNU General Public License v3.0 | 5 votes |
@Test public void testNewIdException() throws IOException { mocks(); when(sync.incr(anyString())).thenThrow(new RedisException("error")); when(ala.newId()).thenCallRealMethod(); try { ala.newId(); } catch (IOException e) { assertEquals("error", e.getMessage()); return; } fail(); }
Example #3
Source File: RedisCustomIO.java From feast with Apache License 2.0 | 5 votes |
@StartBundle public void startBundle() { try { redisIngestionClient.connect(); } catch (RedisException e) { log.error("Connection to redis cannot be established ", e); } }
Example #4
Source File: RedisCustomIO.java From feast with Apache License 2.0 | 5 votes |
private void executeBatch( Iterable<FeatureRow> featureRows, Map<String, FeatureSetSpec> featureSetSpecs) throws Exception { this.redisIngestionClient .getBackOffExecutor() .execute( new Retriable() { @Override public void execute() throws ExecutionException, InterruptedException { if (!redisIngestionClient.isConnected()) { redisIngestionClient.connect(); } featureRows.forEach( row -> { redisIngestionClient.set( getKey(row, featureSetSpecs.get(row.getFeatureSet())), getValue(row, featureSetSpecs.get(row.getFeatureSet()))); }); redisIngestionClient.sync(); } @Override public Boolean isExceptionRetriable(Exception e) { return e instanceof RedisException; } @Override public void cleanUpAfterFailure() {} }); }
Example #5
Source File: ProtobufRedisLoadingCache.java From curiostack with MIT License | 5 votes |
@SuppressWarnings("FutureReturnValueIgnored") // Intentional private CompletableFuture<V> loadWithCache( K key, Executor executor, Function<K, ListenableFuture<V>> loader) { final CompletionStage<V> fromCache; try { fromCache = remoteCache.get(key); } catch (RedisException t) { logger.warn("Error reading from remoteCache cache. Computing value anyways.", t); return ListenableFuturesExtra.toCompletableFuture(loader.apply(key)); } return fromCache .handleAsync( (cached, t) -> { if (cached != null) { return CompletableFuture.completedFuture(cached); } if (t != null) { logger.warn("Error reading from remoteCache cache. Computing value anyways.", t); } CompletableFuture<V> loaded = ListenableFuturesExtra.toCompletableFuture(loader.apply(key)); loaded.thenAcceptAsync(val -> remoteCache.set(key, val, setArgs), executor); return loaded; }, executor) // Converts CompletionStage<CompletionStage<U>> to CompletionStage<U> .thenCompose(Function.identity()) .toCompletableFuture(); }