Skip to content

Commit

Permalink
add sentinelPassword
Browse files Browse the repository at this point in the history
  • Loading branch information
PeppaO committed Oct 14, 2023
1 parent 8cc6704 commit 54f29c5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 5 additions & 0 deletions common/src/main/java/io/seata/common/ConfigurationKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,11 @@ public interface ConfigurationKeys {
*/
String STORE_REDIS_SENTINEL_HOST = STORE_REDIS_SENTINEL_PREFIX + "sentinelHosts";

/**
* STORE_REDIS_SENTINEL_PASSWORD.
*/
String STORE_REDIS_SENTINEL_PASSWORD = STORE_REDIS_SENTINEL_PREFIX + "sentinelPassword";

/**
* The constant CLIENT_DEGRADE_CHECK_PERIOD.
*/
Expand Down
2 changes: 1 addition & 1 deletion dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<kafka-appender.version>0.2.0-RC2</kafka-appender.version>

<!-- redis -->
<jedis.version>3.2.0</jedis.version>
<jedis.version>3.8.0</jedis.version>

<!-- # for database -->
<!-- db -->
Expand Down
1 change: 1 addition & 0 deletions script/config-center/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ store.redis.single.host=127.0.0.1
store.redis.single.port=6379
store.redis.sentinel.masterName=
store.redis.sentinel.sentinelHosts=
store.redis.sentinel.sentinelPassword=
store.redis.maxConn=10
store.redis.minConn=1
store.redis.maxTotal=100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
import io.seata.core.constants.ConfigurationKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolAbstract;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.jedis.*;

import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_IDLE;
import static io.seata.common.DefaultValues.DEFAULT_REDIS_MAX_TOTAL;
Expand Down Expand Up @@ -59,7 +55,7 @@ public class JedisPooledFactory {

/**
* get the RedisPool instance (singleton)
*
*
* @return redisPool
*/
public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisPools) {
Expand Down Expand Up @@ -98,7 +94,8 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP
Set<String> sentinels = new HashSet<>(SENTINEL_HOST_NUMBER);
String[] sentinelHosts = CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SENTINEL_HOST).split(",");
Arrays.asList(sentinelHosts).forEach(sentinelHost -> sentinels.add(sentinelHost));
tempJedisPool = new JedisSentinelPool(masterName, sentinels, poolConfig, 60000, password, CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_DATABASE, DATABASE));
tempJedisPool = new JedisSentinelPool(masterName, sentinels, poolConfig, 60000, 60000, password, CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_DATABASE, DATABASE),
null, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SENTINEL_PASSWORD), null);
} else if (mode.equals(ConfigurationKeys.REDIS_SINGLE_MODE)) {
String host = CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SINGLE_HOST);
host = StringUtils.isBlank(host) ? CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_HOST, HOST) : host;
Expand All @@ -121,7 +118,7 @@ public static JedisPoolAbstract getJedisPoolInstance(JedisPoolAbstract... jedisP

/**
* get an instance of Jedis (connection) from the connection pool
*
*
* @return jedis
*/
public static Jedis getJedisInstance() {
Expand Down

0 comments on commit 54f29c5

Please sign in to comment.