Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复rtc分析时获取redis集群连接有密码失败的bug #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.newegg.ec.redis.util.RedisUtil;
import com.newegg.ec.redis.util.SignUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.*;
Expand All @@ -18,6 +19,7 @@
import java.nio.charset.StandardCharsets;
import java.util.*;

import static com.newegg.ec.redis.client.RedisURI.MAX_ATTEMPTS;
import static com.newegg.ec.redis.client.RedisURI.TIMEOUT;
import static com.newegg.ec.redis.util.RedisUtil.*;

Expand Down Expand Up @@ -738,7 +740,12 @@ public Map<String, String> clusterNodesIP(Cluster cluster) {
String redisUrl = cluster.getNodes().split(",")[0];
String redisHost = redisUrl.split(":")[0];
int redisPort = Integer.parseInt(redisUrl.split(":")[1]);
JedisCluster jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort));
JedisCluster jedisCluster = null;
if (Strings.isNullOrEmpty(cluster.getRedisPassword())) {
jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort));
} else {
jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort), TIMEOUT, TIMEOUT, MAX_ATTEMPTS, cluster.getRedisPassword(), new GenericObjectPoolConfig());
}
Map<String, JedisPool> nodes = jedisCluster.getClusterNodes();
Map<String, String> clusterNodesIP = new HashMap<>();
nodes.forEach((k, v) -> {
Expand Down Expand Up @@ -861,7 +868,12 @@ public Map<String, List<String>> clusterNodesMap(Cluster cluster) {
String redisUrl = cluster.getNodes().split(",")[0];
String redisHost = redisUrl.split(":")[0];
int redisPort = Integer.parseInt(redisUrl.split(":")[1]);
JedisCluster jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort));
JedisCluster jedisCluster = null;
if (Strings.isNullOrEmpty(cluster.getRedisPassword())) {
jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort));
} else {
jedisCluster = new JedisCluster(new HostAndPort(redisHost,redisPort), TIMEOUT, TIMEOUT, MAX_ATTEMPTS, cluster.getRedisPassword(), new GenericObjectPoolConfig());
}
Map<String, JedisPool> nodes = jedisCluster.getClusterNodes();
Map<String, List<String>> clusterNodes = new HashMap<>();

Expand Down