You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ho...@apache.org on 2021/09/15 02:35:20 UTC
[dubbo-admin] branch develop updated: optimize some code for
RegistryServerSync (#822)
This is an automated email from the ASF dual-hosted git repository.
horizonzy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-admin.git
The following commit(s) were added to refs/heads/develop by this push:
new cc5e780 optimize some code for RegistryServerSync (#822)
cc5e780 is described below
commit cc5e7800c9eca98a0e9d2a9571d9c10bb061d430
Author: Wang Chengming <63...@qq.com>
AuthorDate: Wed Sep 15 10:35:08 2021 +0800
optimize some code for RegistryServerSync (#822)
---
.../org/apache/dubbo/admin/service/RegistryServerSync.java | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
index 475bb31..3e66694 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryServerSync.java
@@ -28,6 +28,7 @@ import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
+
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -41,7 +42,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicLong;
@Component
public class RegistryServerSync implements DisposableBean, NotifyListener {
@@ -60,8 +60,6 @@ public class RegistryServerSync implements DisposableBean, NotifyListener {
Constants.ENABLED_KEY, Constants.ANY_VALUE,
Constants.CHECK_KEY, String.valueOf(false));
- private static final AtomicLong ID = new AtomicLong();
-
/**
* Make sure ID never changed when the same url notified many times
*/
@@ -88,7 +86,7 @@ public class RegistryServerSync implements DisposableBean, NotifyListener {
registry.unsubscribe(SUBSCRIBE, this);
}
- // Notification of of any service with any type (override、subcribe、route、provider) is full.
+ // Notification of any service with any type (override、subscribe、route、provider) is full.
@Override
public void notify(List<URL> urls) {
if (urls == null || urls.isEmpty()) {
@@ -157,12 +155,12 @@ public class RegistryServerSync implements DisposableBean, NotifyListener {
String category = categoryEntry.getKey();
ConcurrentMap<String, Map<String, URL>> services = interfaceRegistryCache.get(category);
if (services == null) {
- services = new ConcurrentHashMap<String, Map<String, URL>>();
+ services = new ConcurrentHashMap<>();
interfaceRegistryCache.put(category, services);
} else {// Fix map can not be cleared when service is unregistered: when a unique “group/service:version” service is unregistered, but we still have the same services with different version or group, so empty protocols can not be invoked.
- Set<String> keys = new HashSet<String>(services.keySet());
+ Set<String> keys = new HashSet<>(services.keySet());
for (String key : keys) {
- if (Tool.getInterface(key).equals(interfaceName) && !categoryEntry.getValue().entrySet().contains(key)) {
+ if (Tool.getInterface(key).equals(interfaceName) && !categoryEntry.getValue().containsKey(key)) {
services.remove(key);
}
}