Polishing.
Delegate RedisClientProvider.getClient() across connection providers. Use SimpleAsyncTaskExecutor as default in ClusterCommandExecutor to avoid ThreadPoolTaskExecutor pollution. See #2575
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.core.task.AsyncTaskExecutor;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.ClusterRedirectException;
|
||||
import org.springframework.data.redis.ClusterStateFailureException;
|
||||
@@ -87,9 +88,7 @@ public class ClusterCommandExecutor implements DisposableBean {
|
||||
|
||||
{
|
||||
if (executor == null) {
|
||||
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
|
||||
threadPoolTaskExecutor.initialize();
|
||||
this.executor = threadPoolTaskExecutor;
|
||||
this.executor = new SimpleAsyncTaskExecutor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ class LettucePoolingConnectionProvider implements LettuceConnectionProvider, Red
|
||||
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);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import io.lettuce.core.AbstractRedisClient;
|
||||
import io.lettuce.core.ReadFrom;
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.RedisURI;
|
||||
@@ -44,7 +45,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
class StandaloneConnectionProvider implements LettuceConnectionProvider, TargetAware {
|
||||
class StandaloneConnectionProvider implements LettuceConnectionProvider, TargetAware, RedisClientProvider {
|
||||
|
||||
private final RedisClient client;
|
||||
private final RedisCodec<?, ?> codec;
|
||||
@@ -142,6 +143,11 @@ class StandaloneConnectionProvider implements LettuceConnectionProvider, TargetA
|
||||
.failed(new UnsupportedOperationException("Connection type " + connectionType + " not supported"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractRedisClient getRedisClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
private StatefulRedisConnection masterReplicaConnection(RedisURI redisUri, ReadFrom readFrom) {
|
||||
|
||||
StatefulRedisMasterReplicaConnection<?, ?> connection = MasterReplica.connect(client, codec, redisUri);
|
||||
|
||||
Reference in New Issue
Block a user