@SuppressWarnings({ "unchecked", "rawtypes" }) private void init() { if (connection == null) { connection = provider.getConnection(StatefulRedisSentinelConnection.class); } }
@SuppressWarnings("unchecked") protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() { return connectionProvider.getConnection(StatefulConnection.class); }
/** * {@link #close()} the current connection and open a new pub/sub connection to the Redis server. * * @return never {@literal null}. */ @SuppressWarnings("unchecked") protected StatefulRedisPubSubConnection<byte[], byte[]> switchToPubSub() { close(); return connectionProvider.getConnection(StatefulRedisPubSubConnection.class); }
@Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) { GenericObjectPool<StatefulConnection<?, ?>> pool = pools.computeIfAbsent(connectionType, poolType -> { return ConnectionPoolSupport.createGenericObjectPool(() -> connectionProvider.getConnection(connectionType), poolConfig, false); }); try { StatefulConnection<?, ?> connection = pool.borrowObject(); poolRef.put(connection, pool); return connectionType.cast(connection); } catch (Exception e) { throw new PoolException("Could not get a resource from the pool", e); } }
@Override @SuppressWarnings("unchecked") public RedisClusterCommands<byte[], byte[]> getResourceForSpecificNode(RedisClusterNode node) { Assert.notNull(node, "Node must not be null!"); if (connection == null) { synchronized (this) { if (connection == null) { this.connection = connectionProvider.getConnection(StatefulRedisClusterConnection.class); } } } try { return connection.getConnection(node.getHost(), node.getPort()).sync(); } catch (RedisException e) { throw new DataAccessResourceFailureException(e.getMessage(), e); } }
/** * Obtain a connection from the associated {@link LettuceConnectionProvider}. * * @return the connection. */ private StatefulConnection<E, E> getNativeConnection() { try { StatefulConnection<E, E> connection = connectionProvider.getConnection(StatefulConnection.class); if (connection instanceof StatefulRedisConnection && getDatabase() > 0) { ((StatefulRedisConnection) connection).sync().select(getDatabase()); } return connection; } catch (RedisException e) { throw new RedisConnectionFailureException("Unable to connect to Redis", e); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private void init() { if (connection == null) { connection = provider.getConnection(StatefulRedisSentinelConnection.class); } }
@SuppressWarnings("unchecked") protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() { return connectionProvider.getConnection(StatefulConnection.class); }
@SuppressWarnings("unchecked") protected StatefulConnection<byte[], byte[]> doGetAsyncDedicatedConnection() { return connectionProvider.getConnection(StatefulConnection.class); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private void init() { if (connection == null) { connection = provider.getConnection(StatefulRedisSentinelConnection.class); } }
/** * {@link #close()} the current connection and open a new pub/sub connection to the Redis server. * * @return never {@literal null}. */ @SuppressWarnings("unchecked") protected StatefulRedisPubSubConnection<byte[], byte[]> switchToPubSub() { close(); return connectionProvider.getConnection(StatefulRedisPubSubConnection.class); }
/** * {@link #close()} the current connection and open a new pub/sub connection to the Redis server. * * @return never {@literal null}. */ @SuppressWarnings("unchecked") protected StatefulRedisPubSubConnection<byte[], byte[]> switchToPubSub() { close(); return connectionProvider.getConnection(StatefulRedisPubSubConnection.class); }
@Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) { GenericObjectPool<StatefulConnection<?, ?>> pool = pools.computeIfAbsent(connectionType, poolType -> { return ConnectionPoolSupport.createGenericObjectPool(() -> connectionProvider.getConnection(connectionType), poolConfig, false); }); try { StatefulConnection<?, ?> connection = pool.borrowObject(); poolRef.put(connection, pool); return connectionType.cast(connection); } catch (Exception e) { throw new PoolException("Could not get a resource from the pool", e); } }
@SuppressWarnings("unchecked") AsyncConnect(LettuceConnectionProvider connectionProvider, Class<? extends T> connectionType) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.connectionProvider = connectionProvider; Mono<T> defer = Mono.defer(() -> Mono.<T> just(connectionProvider.getConnection(connectionType))); this.connectionPublisher = defer.subscribeOn(Schedulers.elastic()); }
@SuppressWarnings("unchecked") AsyncConnect(LettuceConnectionProvider connectionProvider, Class<? extends T> connectionType) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.connectionProvider = connectionProvider; Mono<T> defer = Mono.defer(() -> Mono.<T> just(connectionProvider.getConnection(connectionType))); this.connectionPublisher = defer.subscribeOn(Schedulers.elastic()); }
@Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> connectionType) { GenericObjectPool<StatefulConnection<?, ?>> pool = pools.computeIfAbsent(connectionType, poolType -> { return ConnectionPoolSupport.createGenericObjectPool(() -> connectionProvider.getConnection(connectionType), poolConfig, false); }); try { StatefulConnection<?, ?> connection = pool.borrowObject(); poolRef.put(connection, pool); return connectionType.cast(connection); } catch (Exception e) { throw new PoolException("Could not get a resource from the pool", e); } }
@Override @SuppressWarnings("unchecked") public RedisClusterCommands<byte[], byte[]> getResourceForSpecificNode(RedisClusterNode node) { Assert.notNull(node, "Node must not be null!"); if (connection == null) { synchronized (this) { if (connection == null) { this.connection = connectionProvider.getConnection(StatefulRedisClusterConnection.class); } } } try { return connection.getConnection(node.getHost(), node.getPort()).sync(); } catch (RedisException e) { throw new DataAccessResourceFailureException(e.getMessage(), e); } }
@Override @SuppressWarnings("unchecked") public RedisClusterCommands<byte[], byte[]> getResourceForSpecificNode(RedisClusterNode node) { Assert.notNull(node, "Node must not be null!"); if (connection == null) { synchronized (this) { if (connection == null) { this.connection = connectionProvider.getConnection(StatefulRedisClusterConnection.class); } } } try { return connection.getConnection(node.getHost(), node.getPort()).sync(); } catch (RedisException e) { throw new DataAccessResourceFailureException(e.getMessage(), e); } }
/** * Obtain a connection from the associated {@link LettuceConnectionProvider}. * * @return the connection. */ private StatefulConnection<E, E> getNativeConnection() { try { StatefulConnection<E, E> connection = connectionProvider.getConnection(StatefulConnection.class); if (connection instanceof StatefulRedisConnection && getDatabase() > 0) { ((StatefulRedisConnection) connection).sync().select(getDatabase()); } return connection; } catch (RedisException e) { throw new RedisConnectionFailureException("Unable to connect to Redis", e); } }
/** * Obtain a connection from the associated {@link LettuceConnectionProvider}. * * @return the connection. */ private StatefulConnection<E, E> getNativeConnection() { try { StatefulConnection<E, E> connection = connectionProvider.getConnection(StatefulConnection.class); if (connection instanceof StatefulRedisConnection && getDatabase() > 0) { ((StatefulRedisConnection) connection).sync().select(getDatabase()); } return connection; } catch (RedisException e) { throw new RedisConnectionFailureException("Unable to connect to Redis", e); } }