/** * Create a {@link LettuceConnectionProvider} given {@link AbstractRedisClient} and {@link RedisCodec}. Configuration * of this connection factory specifies the type of the created connection provider. This method creates either a * {@link LettuceConnectionProvider} for either {@link RedisClient} or {@link RedisClusterClient}. Subclasses may * override this method to decorate the connection provider. * * @param client either {@link RedisClient} or {@link RedisClusterClient}, must not be {@literal null}. * @param codec used for connection creation, must not be {@literal null}. By default, a {@code byte[]} codec. * Reactive connections require a {@link java.nio.ByteBuffer} codec. * @return the connection provider. * @since 2.1 */ protected LettuceConnectionProvider doCreateConnectionProvider(AbstractRedisClient client, RedisCodec<?, ?> codec) { ReadFrom readFrom = getClientConfiguration().getReadFrom().orElse(null); if (isStaticMasterReplicaAware()) { List<RedisURI> nodes = ((RedisStaticMasterReplicaConfiguration) configuration).getNodes().stream() // .map(it -> createRedisURIAndApplySettings(it.getHostName(), it.getPort())) // .peek(it -> it.setDatabase(getDatabase())) // .collect(Collectors.toList()); return new StaticMasterReplicaConnectionProvider((RedisClient) client, codec, nodes, readFrom); } if (isClusterAware()) { return new ClusterConnectionProvider((RedisClusterClient) client, codec, readFrom); } return new StandaloneConnectionProvider((RedisClient) client, codec, readFrom); }
/** * Create a {@link LettuceConnectionProvider} given {@link AbstractRedisClient} and {@link RedisCodec}. Configuration * of this connection factory specifies the type of the created connection provider. This method creates either a * {@link LettuceConnectionProvider} for either {@link RedisClient} or {@link RedisClusterClient}. Subclasses may * override this method to decorate the connection provider. * * @param client either {@link RedisClient} or {@link RedisClusterClient}, must not be {@literal null}. * @param codec used for connection creation, must not be {@literal null}. By default, a {@code byte[]} codec. * Reactive connections require a {@link java.nio.ByteBuffer} codec. * @return the connection provider. * @since 2.1 */ protected LettuceConnectionProvider doCreateConnectionProvider(AbstractRedisClient client, RedisCodec<?, ?> codec) { ReadFrom readFrom = getClientConfiguration().getReadFrom().orElse(null); if (isStaticMasterReplicaAware()) { List<RedisURI> nodes = ((RedisStaticMasterReplicaConfiguration) configuration).getNodes().stream() // .map(it -> createRedisURIAndApplySettings(it.getHostName(), it.getPort())) // .peek(it -> it.setDatabase(getDatabase())) // .collect(Collectors.toList()); return new StaticMasterReplicaConnectionProvider((RedisClient) client, codec, nodes, readFrom); } if (isClusterAware()) { return new ClusterConnectionProvider((RedisClusterClient) client, codec, readFrom); } return new StandaloneConnectionProvider((RedisClient) client, codec, readFrom); }
/** * Create a {@link LettuceConnectionProvider} given {@link AbstractRedisClient} and {@link RedisCodec}. Configuration * of this connection factory specifies the type of the created connection provider. This method creates either a * {@link LettuceConnectionProvider} for either {@link RedisClient} or {@link RedisClusterClient}. Subclasses may * override this method to decorate the connection provider. * * @param client either {@link RedisClient} or {@link RedisClusterClient}, must not be {@literal null}. * @param codec used for connection creation, must not be {@literal null}. By default, a {@code byte[]} codec. * Reactive connections require a {@link java.nio.ByteBuffer} codec. * @return the connection provider. * @since 2.1 */ protected LettuceConnectionProvider doCreateConnectionProvider(AbstractRedisClient client, RedisCodec<?, ?> codec) { ReadFrom readFrom = getClientConfiguration().getReadFrom().orElse(null); if (isStaticMasterReplicaAware()) { List<RedisURI> nodes = ((RedisStaticMasterReplicaConfiguration) configuration).getNodes().stream() // .map(it -> createRedisURIAndApplySettings(it.getHostName(), it.getPort())) // .peek(it -> it.setDatabase(getDatabase())) // .collect(Collectors.toList()); return new StaticMasterReplicaConnectionProvider((RedisClient) client, codec, nodes, readFrom); } if (isClusterAware()) { return new ClusterConnectionProvider((RedisClusterClient) client, codec, readFrom); } return new StandaloneConnectionProvider((RedisClient) client, codec, readFrom); }
public static void assertNoPoolProperties(RedisConnectionFactory connector) { if (connector instanceof JedisConnectionFactory) { assertFalse(((JedisConnectionFactory) connector).getUsePool()); } else if (connector instanceof LettuceConnectionFactory) { LettuceClientConfiguration config = ((LettuceConnectionFactory) connector).getClientConfiguration(); assertThat(config, instanceOf(LettuceClientConfiguration.class)); } }
public static void assertPoolProperties(RedisConnectionFactory connector, int maxActive, int minIdle, long maxWait) { GenericObjectPoolConfig poolConfig = null; if (connector instanceof JedisConnectionFactory) { poolConfig = ((JedisConnectionFactory) connector).getPoolConfig(); } else if (connector instanceof LettuceConnectionFactory) { LettuceClientConfiguration config = ((LettuceConnectionFactory) connector).getClientConfiguration(); assertThat(config, instanceOf(LettucePoolingClientConfiguration.class)); poolConfig = ((LettucePoolingClientConfiguration) config).getPoolConfig(); } assertCommonsPoolProperties(poolConfig, maxActive, minIdle, maxWait); }