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

feature: support redis sentinel mode #3348

Merged
merged 8 commits into from
Dec 29, 2020
Merged

Conversation

lj2018110133
Copy link
Contributor

@lj2018110133 lj2018110133 commented Dec 8, 2020

Ⅰ. Describe what this PR did

supports transaction session storage for redis sentinel mode

Ⅱ. Does this pull request fix one issue?

fixes #3339

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@funky-eyes
Copy link
Contributor

script/config-center/config.txt 需要修改

@caohdgege
Copy link
Contributor

application.properties, application.yml这些文件也要改一下

@caohdgege
Copy link
Contributor

additional-spring-configuration-metadata.json 这个文件把配置提示加上。
顺便参考seata.client.log.exception-rate,标记一下原来Redis的配置会被迁移到sington上,建议大家不要用旧的了。

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调整一下import顺序和不要用*配置

if (StringUtils.isBlank(masterName)) {
throw new RedisException("The masterName is null in redis sentinel mode");
}
Set<String> sentinels = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initsize?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以,因为set存sentinel节点信息,节点数量固定是3

@@ -40,8 +40,19 @@ store {

## redis store property
redis {
host = "127.0.0.1"
port = "6379"
## redis mode: single、sentinel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调整一下缩进

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

jedisPool = new JedisSentinelPool(masterName, sentinels, poolConfig, 60000, password,
CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_DATABASE, DATABASE));
} else if (mode.equals(ConfigurationKeys.REDIS_SINGLE_MODE)) {
String host = StringUtils.isBlank(CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SINGLE_HOST)) ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIGURATION.getConfig(ConfigurationKeys.STORE_REDIS_SINGLE_HOST) 调了两次,可以用个变量接一下,下面的CONFIGURATION.getInt(ConfigurationKeys.STORE_REDIS_SINGLE_PORT)也是

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我优化下

@funky-eyes funky-eyes added this to the 1.5.0 milestone Dec 10, 2020
@funky-eyes funky-eyes added module/server server module TC/store store mode labels Dec 10, 2020
@@ -125,3 +125,38 @@ seata.registry.custom.name=

seata.registry.load-balance=RandomLoadBalance
seata.registry.load-balance-virtual-nodes=10

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是改错文件了?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经更改过来了

@codecov-io
Copy link

codecov-io commented Dec 27, 2020

Codecov Report

Merging #3348 (9cbd694) into develop (fb3a644) will decrease coverage by 0.01%.
The diff coverage is 5.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3348      +/-   ##
=============================================
- Coverage      51.72%   51.71%   -0.02%     
- Complexity      3347     3353       +6     
=============================================
  Files            617      617              
  Lines          20256    20271      +15     
  Branches        2540     2544       +4     
=============================================
+ Hits           10478    10483       +5     
- Misses          8727     8740      +13     
+ Partials        1051     1048       -3     
Impacted Files Coverage Δ Complexity Δ
...ava/io/seata/core/constants/ConfigurationKeys.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...seata/server/storage/redis/JedisPooledFactory.java 25.00% <5.00%> (-15.00%) 4.00 <0.00> (ø)
...in/java/io/seata/server/session/GlobalSession.java 84.09% <0.00%> (+0.45%) 72.00% <0.00%> (+1.00%)
...o/seata/server/coordinator/DefaultCoordinator.java 55.15% <0.00%> (+0.51%) 30.00% <0.00%> (+2.00%)
...n/src/main/java/io/seata/common/util/IdWorker.java 83.33% <0.00%> (+6.25%) 12.00% <0.00%> (+1.00%)

Copy link
Contributor

@caohdgege caohdgege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. please update 'changes' folder 1.5.0.md

@funky-eyes funky-eyes added the type: feature Category issues or prs related to feature request. label Dec 27, 2020
Copy link
Contributor

@ph3636 ph3636 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/server server module TC/store store mode type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

supports transaction session storage for redis sentinel mode
6 participants