List of usage examples for org.springframework.data.redis.connection ClusterCommandExecutor ClusterCommandExecutor
public ClusterCommandExecutor(ClusterTopologyProvider topologyProvider,
ClusterNodeResourceProvider resourceProvider, ExceptionTranslationStrategy exceptionTranslation)
From source file:org.springframework.data.redis.connection.jedis.JedisClusterConnection.java
/** * Create new {@link JedisClusterConnection} utilizing native connections via {@link JedisCluster}. * * @param cluster must not be {@literal null}. *//*from w ww . ja v a 2s . com*/ public JedisClusterConnection(JedisCluster cluster) { Assert.notNull(cluster, "JedisCluster must not be null."); this.cluster = cluster; closed = false; topologyProvider = new JedisClusterTopologyProvider(cluster); clusterCommandExecutor = new ClusterCommandExecutor(topologyProvider, new JedisClusterNodeResourceProvider(cluster, topologyProvider), EXCEPTION_TRANSLATION); disposeClusterCommandExecutorOnClose = true; try { DirectFieldAccessor dfa = new DirectFieldAccessor(cluster); clusterCommandExecutor.setMaxRedirects((Integer) dfa.getPropertyValue("maxRedirections")); } catch (Exception e) { // ignore it and work with the executor default } }
From source file:org.springframework.data.redis.connection.jedis.JedisConnectionFactory.java
private JedisCluster createCluster() { JedisCluster cluster = createCluster(this.clusterConfig, this.poolConfig); this.clusterCommandExecutor = new ClusterCommandExecutor( new JedisClusterConnection.JedisClusterTopologyProvider(cluster), new JedisClusterConnection.JedisClusterNodeResourceProvider(cluster), EXCEPTION_TRANSLATION); return cluster; }
From source file:org.springframework.data.redis.connection.lettuce.LettuceClusterConnection.java
/** * Creates new {@link LettuceClusterConnection} using {@link LettuceConnectionProvider} running commands across the * cluster via given {@link ClusterCommandExecutor}. * * @param connectionProvider must not be {@literal null}. * @since 2.0/*from w w w. ja v a 2s . co m*/ */ public LettuceClusterConnection(LettuceConnectionProvider connectionProvider) { super(null, connectionProvider, RedisURI.DEFAULT_TIMEOUT_DURATION.toMillis(), 0); Assert.isTrue(connectionProvider instanceof ClusterConnectionProvider, "LettuceConnectionProvider must be a ClusterConnectionProvider."); this.clusterClient = getClient(); this.topologyProvider = new LettuceClusterTopologyProvider(this.clusterClient); this.clusterCommandExecutor = new ClusterCommandExecutor(this.topologyProvider, new LettuceClusterNodeResourceProvider(getConnectionProvider()), exceptionConverter); this.disposeClusterCommandExecutorOnClose = true; }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.java
private AbstractRedisClient createRedisClient() { if (isRedisSentinelAware()) { RedisURI redisURI = getSentinelRedisURI(); if (clientResources == null) { return RedisClient.create(redisURI); }// w w w . j ava2 s .c om return RedisClient.create(clientResources, redisURI); } if (isClusterAware()) { List<RedisURI> initialUris = new ArrayList<RedisURI>(); for (RedisNode node : this.clusterConfiguration.getClusterNodes()) { initialUris.add(createRedisURIAndApplySettings(node.getHost(), node.getPort())); } RedisClusterClient clusterClient = clientResources != null ? RedisClusterClient.create(clientResources, initialUris) : RedisClusterClient.create(initialUris); this.clusterCommandExecutor = new ClusterCommandExecutor( new LettuceClusterConnection.LettuceClusterTopologyProvider(clusterClient), new LettuceClusterConnection.LettuceClusterNodeResourceProvider(clusterClient), EXCEPTION_TRANSLATION); return clusterClient; } if (pool != null) { return pool.getClient(); } RedisURI uri = createRedisURIAndApplySettings(hostName, port); return clientResources != null ? RedisClient.create(clientResources, uri) : RedisClient.create(uri); }