Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

v2.31.1 v3.0 RedisClusterJedisProvider Can only get a redis cluster IP bug #2132

Closed
ninyjun opened this issue Mar 17, 2021 · 4 comments
Closed
Labels
type: bug bugs/ bug fixes

Comments

@ninyjun
Copy link

ninyjun commented Mar 17, 2021

//fixed Can only get a redis cluster IP by ninyjun 462711932@qq.com 2021/03/17
Set hosts = new HashSet<>();
for(Host h : hostSupplier.getHosts()){
hosts.add(new HostAndPort(h.getHostName(), h.getPort()));
}
//end

@apanicker-nflx apanicker-nflx added this to Triage in New Issues Mar 17, 2021
@kishorebanala
Copy link
Contributor

@ninyjun Not sure I understand the question here. Can you add more details with the expected behavior please?

@ninyjun
Copy link
Author

ninyjun commented Apr 6, 2021

A redis(3.0+) cluster has multiple IP addresses
like this. x.x.x.111:6379;x.x.x.222:6379;x.x.x.333:6379
A redis(3.0+) cluster has multiple IP addresses
like this x.x.x.111:6379;x.x.x.222:6379;x.x.x.333:6379

RedisClusterJedisProvider.java

public RedisClusterJedisProvider(HostSupplier hostSupplier, DynomiteConfiguration configuration) {
GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
genericObjectPoolConfig.setMaxTotal(configuration.getMaxConnectionsPerHost());
Host host = hostSupplier.getHosts().get(0); //////////// only get a redis cluster IP ??? bug???
this.jedisCluster = new JedisCluster(new redis.clients.jedis.JedisCluster(new HostAndPort(host.getHostName(), host.getPort()),
genericObjectPoolConfig));
}

@ninyjun
Copy link
Author

ninyjun commented Apr 16, 2021

conductor3.0 RedisClusterConfiguration.java

protected JedisCommands createJedisCommands(RedisProperties properties, ConductorProperties conductorProperties,
HostSupplier hostSupplier, TokenMapSupplier tokenMapSupplier) {
GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
genericObjectPoolConfig.setMaxTotal(properties.getMaxConnectionsPerHost());
// Host host = hostSupplier.getHosts().get(0) ; // only get a redis cluster IP ??? bug???

 //fixed
  Set hosts = new HashSet<>();
  for(Host h : hostSupplier.getHosts()){
  hosts.add(new HostAndPort(h.getHostName(), h.getPort()));
  }
    return new JedisCluster(
        new redis.clients.jedis.JedisCluster(hosts, genericObjectPoolConfig));
}

@apanicker-nflx apanicker-nflx removed this from Triage in New Issues Apr 16, 2021
@apanicker-nflx apanicker-nflx added the type: bug bugs/ bug fixes label Apr 16, 2021
@apanicker-nflx
Copy link
Collaborator

@ninyjun Thank you for reporting this. Could you please open a PR with the fix?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug bugs/ bug fixes
Projects
None yet
Development

No branches or pull requests

3 participants