-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
optimize: redis registry push empty protection optimize #6164
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 2.x #6164 +/- ##
============================================
+ Coverage 48.98% 49.03% +0.04%
- Complexity 4782 4797 +15
============================================
Files 913 915 +2
Lines 31697 31861 +164
Branches 3823 3842 +19
============================================
+ Hits 15528 15622 +94
- Misses 14632 14684 +52
- Partials 1537 1555 +18
|
if (socketAddresses.size() == 1 && socketAddresses.contains(inetSocketAddress)) { | ||
String txServiceGroupName = ConfigurationFactory.getInstance() | ||
.getConfig(ConfigurationKeys.TX_SERVICE_GROUP); | ||
String clusterName = getServiceGroup(txServiceGroupName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check txServiceGroupName
if null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that if txServiceGroupName is null, you should not use it as a parameter to get the clusterName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already optimized it.
if (socketAddresses.size() == 1 && socketAddresses.contains(inetSocketAddress)) { | ||
String txServiceGroupName = ConfigurationFactory.getInstance() | ||
.getConfig(ConfigurationKeys.TX_SERVICE_GROUP); | ||
String clusterName = getServiceGroup(txServiceGroupName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经有clustername了,为什么还要通过事务分组再次读取?
I already have clustername, why read it again through transaction grouping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notifyCluserName 是注册中心回调通知的clusterName, 需要和当前正在使用的clusterName做对比.
notifyCluserName is the clusterName of the registration center callback notification, which needs to be compared with the clusterName currently in use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterName
为什么要跟当前的做对比?而不是直接用他回调的去删除缓存中的? 变化的是回调的那个cluster,如果你不需要改变,为什么不是取消对其的订阅?
Why compare it with the current one? Instead of directly using what he called back to delete the one in the cache? What changes is the cluster that called back. If you don't need to change it, why not unsubscribe to it?
|
||
Set<InetSocketAddress> socketAddresses = CLUSTER_ADDRESS_MAP.getOrDefault(notifyCluserName, Collections.emptySet()); | ||
InetSocketAddress inetSocketAddress = NetUtil.toInetSocketAddress(serverAddr); | ||
if (socketAddresses.size() == 1 && socketAddresses.contains(inetSocketAddress)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请考虑并发性问题
Please consider concurrency issues
… into redis_push_empty_protection
public void accept(RedisMessage redisMessage) { | ||
reentrantLock.lock(); | ||
try { | ||
if (redisMessage.getMessageType() == MessageType.SUBSCRIBE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么messagetype不是add或者remove?而是scan和SUBSCRIBE?我希望是scan那部分找到的列表能跟当前的cluster中的集合做对比,将需要add或者remove的事件发出,而不是在这里面写ifelse,结果还是各玩各的。我希望这里只是一个动作触发,要么是remove,要么是add
Why is messagetype not add or remove? But scan and SUBSCRIBE? I hope that the list found in the scan part can be compared with the collection in the current cluster, and the events that need to be added or removed will be sent out, instead of writing ifelse in it, the result is still different. I hope this is just an action trigger, either remove or add.
32837a3
to
85a4b72
Compare
Welcome to Codecov 🎉Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment. Thanks for integrating Codecov - We've got you covered ☂️ |
…teIfAbsent, there is a performance problem in jdk8. 2. optimize unit test.
...very-redis/src/test/java/io/seata/discovery/registry/redis/RedisRegisterServiceImplTest.java
Outdated
Show resolved
Hide resolved
...very-redis/src/test/java/io/seata/discovery/registry/redis/RedisRegisterServiceImplTest.java
Outdated
Show resolved
Hide resolved
...very-redis/src/test/java/io/seata/discovery/registry/redis/RedisRegisterServiceImplTest.java
Outdated
Show resolved
Hide resolved
...very-redis/src/test/java/io/seata/discovery/registry/redis/RedisRegisterServiceImplTest.java
Outdated
Show resolved
Hide resolved
…ry/registry/redis/RedisRegisterServiceImplTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
当收到 redis 注册中心 回调的服务器下线消息时,检查 服务器地址 是否是地址列表中唯一的地址 并且 回调的集群是当前使用的集群,如果是开启 空推 保护,否则 将该服务器地址移除掉.
when receive server offline message from redis registry check the serverAddr is unique in the address list and
the callback cluster is current cluster, then enable push-empty protection
Otherwise, remove it.
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews