You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by os...@apache.org on 2023/01/28 00:54:27 UTC
[rocketmq] branch develop updated: [ISSUE #5916] Fix availableNamesrvAddrMap can not remove old nameserver address (#5917)
This is an automated email from the ASF dual-hosted git repository.
osgooli pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new ae9f11943 [ISSUE #5916] Fix availableNamesrvAddrMap can not remove old nameserver address (#5917)
ae9f11943 is described below
commit ae9f119431a2ba369a8361b5f1c49a6dd3824e4c
Author: rongtong <ji...@163.com>
AuthorDate: Sat Jan 28 08:54:17 2023 +0800
[ISSUE #5916] Fix availableNamesrvAddrMap can not remove old nameserver address (#5917)
* Fix availableNamesrvAddrMap can not remove old nameserver address
* Fix availableNamesrvAddrMap can not remove old nameserver address
* Pass the code style
---
.../rocketmq/remoting/netty/NettyRemotingClient.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index 84bf83adc..94acf0288 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -861,10 +861,17 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
private void scanAvailableNameSrv() {
List<String> nameServerList = this.namesrvAddrList.get();
if (nameServerList == null) {
- LOGGER.debug("scanAvailableNameSrv Addresses of name server is empty!");
+ LOGGER.debug("scanAvailableNameSrv addresses of name server is null!");
return;
}
+ for (String address : NettyRemotingClient.this.availableNamesrvAddrMap.keySet()) {
+ if (!nameServerList.contains(address)) {
+ LOGGER.warn("scanAvailableNameSrv remove invalid address {}", address);
+ NettyRemotingClient.this.availableNamesrvAddrMap.remove(address);
+ }
+ }
+
for (final String namesrvAddr : nameServerList) {
scanExecutor.execute(new Runnable() {
@Override
@@ -874,7 +881,10 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
if (channel != null) {
NettyRemotingClient.this.availableNamesrvAddrMap.putIfAbsent(namesrvAddr, true);
} else {
- NettyRemotingClient.this.availableNamesrvAddrMap.remove(namesrvAddr);
+ Boolean value = NettyRemotingClient.this.availableNamesrvAddrMap.remove(namesrvAddr);
+ if (value != null) {
+ LOGGER.warn("scanAvailableNameSrv remove unconnected address {}", namesrvAddr);
+ }
}
} catch (Exception e) {
LOGGER.error("scanAvailableNameSrv get channel of {} failed, ", namesrvAddr, e);
@@ -882,7 +892,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
});
}
-
}
static class ChannelWrapper {