findMethodsByService(String serviceName);
-
- Provider findByServiceAndAddress(String service, String address);
-
/**
* Get a set of service data object.
- *
+ *
* ServiceDTO object contains base information include
* service name , application, group and version.
*
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryCache.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryCache.java
new file mode 100644
index 000000000..0335909e2
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/RegistryCache.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.admin.service;
+
+import java.util.function.Function;
+
+/**
+ * cache registry url
+ */
+public interface RegistryCache {
+
+ /**
+ * put cache
+ *
+ * @param key key
+ * @param value value
+ */
+ void put(K key, V value);
+
+ /**
+ * get cache
+ *
+ * @param key key
+ * @return value
+ */
+ V get(K key);
+
+
+ default V computeIfAbsent(K key, Function super K, ? extends V> mappingFunction) {
+ return null;
+ }
+
+}
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 f57cdb3d1..dab1a4371 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
@@ -19,6 +19,8 @@
import org.apache.dubbo.admin.common.util.CoderUtil;
import org.apache.dubbo.admin.common.util.Constants;
import org.apache.dubbo.admin.common.util.Tool;
+import org.apache.dubbo.admin.service.impl.InterfaceRegistryCache;
+import org.apache.dubbo.common.BaseServiceMetadata;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@@ -69,13 +71,11 @@ public class RegistryServerSync implements DisposableBean, NotifyListener {
* ConcurrentMap>>
* registryCache
*/
- private final ConcurrentMap>> registryCache = new ConcurrentHashMap<>();
@Autowired
private Registry registry;
- public ConcurrentMap>> getRegistryCache() {
- return registryCache;
- }
+ @Autowired
+ private InterfaceRegistryCache interfaceRegistryCache;
@EventListener(classes = ApplicationReadyEvent.class)
public void startSubscribe() {
@@ -98,16 +98,19 @@ public void notify(List urls) {
final Map>> categories = new HashMap<>();
String interfaceName = null;
for (URL url : urls) {
- String category = url.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
+ String category = url.getUrlParam().getParameter(Constants.CATEGORY_KEY);
+ if (category == null) {
+ category = Constants.PROVIDERS_CATEGORY;
+ }
// NOTE: group and version in empty protocol is *
if (Constants.EMPTY_PROTOCOL.equalsIgnoreCase(url.getProtocol())) {
- ConcurrentMap> services = registryCache.get(category);
+ ConcurrentMap> services = interfaceRegistryCache.get(category);
if (services != null) {
- String group = url.getParameter(Constants.GROUP_KEY);
- String version = url.getParameter(Constants.VERSION_KEY);
+ String group = url.getUrlParam().getParameter(Constants.GROUP_KEY);
+ String version = url.getUrlParam().getParameter(Constants.VERSION_KEY);
// NOTE: group and version in empty protocol is *
if (!Constants.ANY_VALUE.equals(group) && !Constants.ANY_VALUE.equals(version)) {
- services.remove(url.getServiceKey());
+ services.remove(url.getServiceInterface());
} else {
for (Map.Entry> serviceEntry : services.entrySet()) {
String service = serviceEntry.getKey();
@@ -128,7 +131,9 @@ public void notify(List urls) {
services = new HashMap<>();
categories.put(category, services);
}
- String service = url.getServiceKey();
+ String group = url.getUrlParam().getParameter(Constants.GROUP_KEY);
+ String version = url.getUrlParam().getParameter(Constants.VERSION_KEY);
+ String service = BaseServiceMetadata.buildServiceKey(url.getServiceInterface(), group, version);
Map ids = services.get(service);
if (ids == null) {
ids = new HashMap<>();
@@ -150,10 +155,10 @@ public void notify(List urls) {
}
for (Map.Entry>> categoryEntry : categories.entrySet()) {
String category = categoryEntry.getKey();
- ConcurrentMap> services = registryCache.get(category);
+ ConcurrentMap> services = interfaceRegistryCache.get(category);
if (services == null) {
services = new ConcurrentHashMap>();
- registryCache.put(category, services);
+ 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 keys = new HashSet(services.keySet());
for (String key : keys) {
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/AbstractService.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/AbstractService.java
index f7bae0d49..501b13eca 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/AbstractService.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/AbstractService.java
@@ -18,7 +18,6 @@
import org.apache.dubbo.admin.registry.config.GovernanceConfiguration;
import org.apache.dubbo.admin.registry.metadata.MetaDataCollector;
-import org.apache.dubbo.admin.service.RegistryServerSync;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
@@ -42,10 +41,10 @@ public class AbstractService {
protected MetaDataCollector metaDataCollector;
@Autowired
- private RegistryServerSync sync;
+ private InterfaceRegistryCache interfaceRegistryCache;
- public ConcurrentMap>> getRegistryCache() {
- return sync.getRegistryCache();
+ public ConcurrentMap>> getInterfaceRegistryCache() {
+ return interfaceRegistryCache.getRegistryCache();
}
}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ConsumerServiceImpl.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ConsumerServiceImpl.java
index 4a803ed63..0d0f2e595 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ConsumerServiceImpl.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ConsumerServiceImpl.java
@@ -52,7 +52,7 @@ public String getConsumerMetadata(MetadataIdentifier consumerIdentifier) {
private Map findAllConsumerUrl() {
Map filter = new HashMap();
filter.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@@ -69,7 +69,7 @@ private Map findConsumerUrlByAddress(String address) {
filter.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
filter.put(SyncUtils.ADDRESS_FILTER_KEY, address);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
public Map findConsumerUrlByService(String service) {
@@ -77,7 +77,7 @@ public Map findConsumerUrlByService(String service) {
filter.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
filter.put(SyncUtils.SERVICE_FILTER_KEY, service);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@Override
@@ -85,7 +85,7 @@ public String findVersionInApplication(String application) {
Map filter = new HashMap<>();
filter.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
filter.put(Constants.APPLICATION_KEY, application);
- Map stringURLMap = SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ Map stringURLMap = SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
if (stringURLMap == null || stringURLMap.isEmpty()) {
throw new ParamValidationException("there is no consumer for application: " + application);
}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryCache.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryCache.java
new file mode 100644
index 000000000..9f1b5acaa
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryCache.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.admin.service.impl;
+
+import org.apache.dubbo.admin.service.RegistryCache;
+import org.apache.dubbo.registry.client.InstanceAddressURL;
+
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.function.Function;
+
+/**
+ * instance registry url {@link InstanceAddressURL} cache
+ * key --> category,value --> ConcurrentMap>>
+ */
+@Component
+public class InstanceRegistryCache implements RegistryCache>>> {
+
+ private final ConcurrentMap>>> registryCache = new ConcurrentHashMap<>();
+
+ @Override
+ public void put(String key, ConcurrentMap>> value) {
+ registryCache.put(key, value);
+ }
+
+ @Override
+ public ConcurrentMap>> get(String key) {
+ return registryCache.get(key);
+ }
+
+ @Override
+ public ConcurrentMap>> computeIfAbsent(String key,
+ Function super String, ? extends ConcurrentMap>>> mappingFunction) {
+ return registryCache.computeIfAbsent(key, mappingFunction);
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java
new file mode 100644
index 000000000..6391d4c88
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.admin.service.impl;
+
+import org.apache.dubbo.admin.common.util.Constants;
+import org.apache.dubbo.admin.model.domain.Provider;
+import org.apache.dubbo.admin.model.domain.RegistrySource;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.registry.client.InstanceAddressURL;
+import org.apache.dubbo.registry.client.ServiceInstance;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.stream.Collectors;
+
+@Component
+public class InstanceRegistryQueryHelper {
+
+ private final InstanceRegistryCache instanceRegistryCache;
+
+ public InstanceRegistryQueryHelper(InstanceRegistryCache instanceRegistryCache) {
+ this.instanceRegistryCache = instanceRegistryCache;
+ }
+
+
+ public Set findServices() {
+ Set services = Sets.newHashSet();
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null) {
+ return services;
+ }
+ appInterfaceMap.values().forEach(serviceUrlMap ->
+ serviceUrlMap.forEach((service, urls) -> {
+ if (CollectionUtils.isNotEmpty(urls)) {
+ services.add(service);
+ }
+ }));
+ return services;
+ }
+
+ public Set findApplications() {
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null) {
+ return Sets.newHashSet();
+ }
+ return Sets.newHashSet(appInterfaceMap.keySet());
+ }
+
+ public List findByService(String serviceName) {
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null) {
+ return Lists.newArrayList();
+ }
+ List providerUrls = Lists.newArrayList();
+ appInterfaceMap.values().forEach(serviceUrlMap ->
+ serviceUrlMap.forEach((service, urls) -> {
+ if (CollectionUtils.isNotEmpty(urls) && service.equals(serviceName)) {
+ providerUrls.addAll(urls);
+ }
+ }));
+ return urlsToProviderList(providerUrls).stream()
+ .filter(provider -> provider.getService().equals(serviceName))
+ .collect(Collectors.toList());
+ }
+
+ public List findByAddress(String providerAddress) {
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null) {
+ return Lists.newArrayList();
+ }
+ List providerUrls = Lists.newArrayList();
+ appInterfaceMap.values().forEach(serviceUrlMap ->
+ serviceUrlMap.forEach((service, urls) -> {
+ if (CollectionUtils.isNotEmpty(urls)) {
+ urls.forEach(url -> {
+ if ((url.getInstance().getHost().equals(providerAddress))) {
+ providerUrls.add(url);
+ }
+ });
+ }
+ }));
+ return urlsToProviderList(providerUrls);
+ }
+
+ public List findByApplication(String application) {
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null || appInterfaceMap.get(application) == null) {
+ return Lists.newArrayList();
+ }
+ List providerUrls = Lists.newArrayList();
+ appInterfaceMap.get(application).forEach((service, urls) -> providerUrls.addAll(urls));
+ return urlsToProviderList(providerUrls);
+ }
+
+ public String findVersionInApplication(String application) {
+ ConcurrentMap>> appInterfaceMap = instanceRegistryCache.get(Constants.PROVIDERS_CATEGORY);
+ if (appInterfaceMap == null || appInterfaceMap.get(application) == null) {
+ return null;
+ }
+ Map> urlsMap = appInterfaceMap.get(application);
+ for (Map.Entry> entry : urlsMap.entrySet()) {
+ List urls = entry.getValue();
+ if (CollectionUtils.isNotEmpty(urls)) {
+ return urls.get(0).getParameter(Constants.SPECIFICATION_VERSION_KEY, "3.0.0");
+ }
+ }
+ return null;
+ }
+
+ private List urlsToProviderList(List urls) {
+ List providers = Lists.newArrayList();
+ urls.stream().distinct().forEach(url -> {
+ ServiceInstance instance = url.getInstance();
+ MetadataInfo metadataInfo = url.getMetadataInfo();
+
+ metadataInfo.getServices().forEach((serviceKey, serviceInfo) -> {
+ Provider p = new Provider();
+ String service = serviceInfo.getServiceKey();
+ p.setService(service);
+ p.setAddress(url.getAddress());
+ p.setApplication(instance.getServiceName());
+ p.setUrl(url.toParameterString());
+ p.setDynamic(url.getParameter("dynamic", true));
+ p.setEnabled(url.getParameter(Constants.ENABLED_KEY, true));
+ p.setWeight(url.getParameter(Constants.WEIGHT_KEY, Constants.DEFAULT_WEIGHT));
+ p.setUsername(url.getParameter("owner"));
+ p.setRegistrySource(RegistrySource.INSTANCE);
+ providers.add(p);
+ });
+ });
+ return providers;
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InterfaceRegistryCache.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InterfaceRegistryCache.java
new file mode 100644
index 000000000..ab5b3be48
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InterfaceRegistryCache.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.admin.service.impl;
+
+import org.apache.dubbo.admin.service.RegistryCache;
+import org.apache.dubbo.common.URL;
+
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * interface registry url cache
+ * key --> category,value --> ConcurrentMap>
+ */
+@Component
+public class InterfaceRegistryCache implements RegistryCache>> {
+
+ private final ConcurrentMap>> registryCache = new ConcurrentHashMap<>();
+
+ @Override
+ public void put(String key, ConcurrentMap> value) {
+ registryCache.put(key, value);
+ }
+
+ @Override
+ public ConcurrentMap> get(String key) {
+ return registryCache.get(key);
+ }
+
+ public ConcurrentMap>> getRegistryCache() {
+ return registryCache;
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ProviderServiceImpl.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ProviderServiceImpl.java
index 0d8308153..1defce765 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ProviderServiceImpl.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/ProviderServiceImpl.java
@@ -18,16 +18,14 @@
import org.apache.dubbo.admin.common.exception.ParamValidationException;
import org.apache.dubbo.admin.common.util.Constants;
-import org.apache.dubbo.admin.common.util.Pair;
-import org.apache.dubbo.admin.common.util.ParseUtils;
import org.apache.dubbo.admin.common.util.SyncUtils;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.admin.model.domain.Provider;
import org.apache.dubbo.admin.model.dto.ServiceDTO;
-import org.apache.dubbo.admin.service.OverrideService;
import org.apache.dubbo.admin.service.ProviderService;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -37,7 +35,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
@@ -49,7 +46,7 @@
public class ProviderServiceImpl extends AbstractService implements ProviderService {
@Autowired
- OverrideService overrideService;
+ private InstanceRegistryQueryHelper instanceRegistryQueryHelper;
@Override
public void create(Provider provider) {
@@ -63,57 +60,27 @@ public String getProviderMetaData(MetadataIdentifier providerIdentifier) {
return metaDataCollector.getProviderMetaData(providerIdentifier);
}
-
- @Override
- public void deleteStaticProvider(String id) {
- URL oldProvider = findProviderUrl(id);
- if (oldProvider == null) {
- throw new IllegalStateException("Provider was changed!");
- }
- registry.unregister(oldProvider);
- }
-
- @Override
- public void updateProvider(Provider provider) {
- String hash = provider.getHash();
- if (hash == null) {
- throw new IllegalStateException("no provider id");
- }
-
- URL oldProvider = findProviderUrl(hash);
- if (oldProvider == null) {
- throw new IllegalStateException("Provider was changed!");
- }
- URL newProvider = provider.toUrl();
-
- registry.unregister(oldProvider);
- registry.register(newProvider);
- }
-
- @Override
- public Provider findProvider(String id) {
- return SyncUtils.url2Provider(findProviderUrlPair(id));
- }
-
- public Pair findProviderUrlPair(String id) {
- return SyncUtils.filterFromCategory(getRegistryCache(), Constants.PROVIDERS_CATEGORY, id);
- }
-
@Override
public Set findServices() {
Set ret = new HashSet<>();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (providerUrls != null){
+ ConcurrentMap> providerUrls = getInterfaceRegistryCache().get(Constants.PROVIDERS_CATEGORY);
+ if (providerUrls != null) {
ret.addAll(providerUrls.keySet());
}
+ ret.addAll(instanceRegistryQueryHelper.findServices());
return ret;
}
+ @Override
+ public Set findInstanceApplications() {
+ return instanceRegistryQueryHelper.findApplications();
+ }
+
@Override
public List findAddresses() {
List ret = new ArrayList();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
+ ConcurrentMap> providerUrls = getInterfaceRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if (null == providerUrls) {
return ret;
}
@@ -128,80 +95,15 @@ public List findAddresses() {
}
}
}
-
- return ret;
- }
-
- @Override
- public List findAddressesByApplication(String application) {
- List ret = new ArrayList();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- for (Map.Entry> e1 : providerUrls.entrySet()) {
- Map value = e1.getValue();
- for (Map.Entry e2 : value.entrySet()) {
- URL u = e2.getValue();
- if (application.equals(u.getParameter(Constants.APPLICATION))) {
- String addr = u.getAddress();
- if (addr != null) {
- ret.add(addr);
- }
- }
- }
- }
-
- return ret;
- }
-
- @Override
- public List findAddressesByService(String service) {
- List ret = new ArrayList();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (null == providerUrls) {
- return ret;
- }
-
- for (Map.Entry e2 : providerUrls.get(service).entrySet()) {
- URL u = e2.getValue();
- String app = u.getAddress();
- if (app != null) {
- ret.add(app);
- }
- }
-
- return ret;
- }
-
- @Override
- public List findApplicationsByServiceName(String service) {
- List ret = new ArrayList();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (null == providerUrls) {
- return ret;
- }
-
- Map value = providerUrls.get(service);
- if (value == null) {
- return ret;
- }
- for (Map.Entry e2 : value.entrySet()) {
- URL u = e2.getValue();
- String app = u.getParameter(Constants.APPLICATION);
- if (app != null){
- ret.add(app);
- }
- }
-
return ret;
}
@Override
public List findByService(String serviceName) {
- return SyncUtils.url2ProviderList(findProviderUrlByService(serviceName));
- }
-
- @Override
- public List findByAppandService(String app, String serviceName) {
- return SyncUtils.url2ProviderList(findProviderUrlByAppandService(app, serviceName));
+ List instanceProviders = instanceRegistryQueryHelper.findByService(serviceName);
+ List interfaceProviders = SyncUtils.url2ProviderList(findProviderUrlByService(serviceName));
+ instanceProviders.addAll(interfaceProviders);
+ return instanceProviders;
}
private Map findProviderUrlByService(String service) {
@@ -209,7 +111,7 @@ private Map findProviderUrlByService(String service) {
filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
filter.put(SyncUtils.SERVICE_FILTER_KEY, service);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@Override
@@ -220,12 +122,15 @@ public List findAll() {
private Map findAllProviderUrl() {
Map filter = new HashMap();
filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@Override
public List findByAddress(String providerAddress) {
- return SyncUtils.url2ProviderList(findProviderUrlByAddress(providerAddress));
+ List instanceProviders = instanceRegistryQueryHelper.findByAddress(providerAddress);
+ List interfaceProviders = SyncUtils.url2ProviderList(findProviderUrlByAddress(providerAddress));
+ instanceProviders.addAll(interfaceProviders);
+ return instanceProviders;
}
public Map findProviderUrlByAddress(String address) {
@@ -233,37 +138,14 @@ public Map findProviderUrlByAddress(String address) {
filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
filter.put(SyncUtils.ADDRESS_FILTER_KEY, address);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
- }
-
- @Override
- public List findServicesByAddress(String address) {
- List ret = new ArrayList();
-
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (providerUrls == null || address == null || address.length() == 0) {
- return ret;
- }
-
- for (Map.Entry> e1 : providerUrls.entrySet()) {
- Map value = e1.getValue();
- for (Map.Entry e2 : value.entrySet()) {
- URL u = e2.getValue();
- if (address.equals(u.getAddress())) {
- ret.add(e1.getKey());
- break;
- }
- }
- }
-
- return ret;
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@Override
public Set findApplications() {
- Set ret = new HashSet<>();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (providerUrls == null){
+ Set ret = instanceRegistryQueryHelper.findApplications();
+ ConcurrentMap> providerUrls = getInterfaceRegistryCache().get(Constants.PROVIDERS_CATEGORY);
+ if (providerUrls == null) {
return ret;
}
@@ -283,11 +165,18 @@ public Set findApplications() {
@Override
public List findByApplication(String application) {
- return SyncUtils.url2ProviderList(findProviderUrlByApplication(application));
+ List instanceProviders = instanceRegistryQueryHelper.findByApplication(application);
+ List interfaceProviders = SyncUtils.url2ProviderList(findProviderUrlByApplication(application));
+ instanceProviders.addAll(interfaceProviders);
+ return instanceProviders;
}
@Override
public String findVersionInApplication(String application) {
+ String version = instanceRegistryQueryHelper.findVersionInApplication(application);
+ if (StringUtils.isNotBlank(version)){
+ return version;
+ }
List services = findServicesByApplication(application);
if (services == null || services.size() == 0) {
throw new ParamValidationException("there is no service for application: " + application);
@@ -313,23 +202,22 @@ private Map findProviderUrlByAppandService(String app, String servi
filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
filter.put(Constants.APPLICATION, app);
filter.put(SyncUtils.SERVICE_FILTER_KEY, service);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
-
private Map findProviderUrlByApplication(String application) {
Map filter = new HashMap<>();
filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
filter.put(Constants.APPLICATION, application);
- return SyncUtils.filterFromCategory(getRegistryCache(), filter);
+ return SyncUtils.filterFromCategory(getInterfaceRegistryCache(), filter);
}
@Override
public List findServicesByApplication(String application) {
List ret = new ArrayList();
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
+ ConcurrentMap> providerUrls = getInterfaceRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if (providerUrls == null || application == null || application.length() == 0) {
return ret;
}
@@ -348,59 +236,6 @@ public List findServicesByApplication(String application) {
return ret;
}
- @Override
- public List findMethodsByService(String service) {
- List ret = new ArrayList();
-
- ConcurrentMap> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
- if (providerUrls == null || service == null || service.length() == 0){
- return ret;
- }
-
- Map providers = providerUrls.get(service);
- if (null == providers || providers.isEmpty()) {
- return ret;
- }
-
- Entry p = providers.entrySet().iterator().next();
- String value = p.getValue().getParameter("methods");
- if (value == null || value.length() == 0) {
- return ret;
- }
- String[] methods = value.split(ParseUtils.METHOD_SPLIT);
- if (methods == null || methods.length == 0) {
- return ret;
- }
-
- for (String m : methods) {
- ret.add(m);
- }
- return ret;
- }
-
- private URL findProviderUrl(String id) {
- return findProvider(id).toUrl();
- }
-
- @Override
- public Provider findByServiceAndAddress(String service, String address) {
- return SyncUtils.url2Provider(findProviderUrl(service, address));
- }
-
- private Pair findProviderUrl(String service, String address) {
- Map filter = new HashMap();
- filter.put(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY);
- filter.put(SyncUtils.ADDRESS_FILTER_KEY, address);
-
- Map ret = SyncUtils.filterFromCategory(getRegistryCache(), filter);
- if (ret.isEmpty()) {
- return null;
- } else {
- String key = ret.entrySet().iterator().next().getKey();
- return new Pair(key, ret.get(key));
- }
- }
-
@Override
public Set getServiceDTOS(String pattern, String filter, String env) {
List providers = new ArrayList<>();
@@ -420,15 +255,14 @@ public Set getServiceDTOS(String pattern, String filter, String env)
candidates = findServices();
} else if (Constants.APPLICATION.equals(pattern)) {
candidates = findApplications();
- }
- else if (Constants.IP.equals(pattern)) {
+ } else if (Constants.IP.equals(pattern)) {
candidates = findAddresses().stream().collect(Collectors.toSet());
}
// replace dot symbol and asterisk symbol to java-based regex pattern
filter = filter.toLowerCase().replace(Constants.PUNCTUATION_POINT, Constants.PUNCTUATION_SEPARATOR_POINT);
// filter start with [* 、? 、+] will triggering PatternSyntaxException
if (filter.startsWith(Constants.ANY_VALUE)
- || filter.startsWith(Constants.INTERROGATION_POINT) || filter.startsWith(Constants.PLUS_SIGNS)) {
+ || filter.startsWith(Constants.INTERROGATION_POINT) || filter.startsWith(Constants.PLUS_SIGNS)) {
filter = Constants.PUNCTUATION_POINT + filter;
}
// search with no case insensitive
@@ -438,19 +272,16 @@ else if (Constants.IP.equals(pattern)) {
if (matcher.matches() || matcher.lookingAt()) {
if (Constants.SERVICE.equals(pattern)) {
providers.addAll(findByService(candidate));
- }
- else if (Constants.IP.equals(pattern)) {
+ } else if (Constants.IP.equals(pattern)) {
providers.addAll(findByAddress(candidate));
- }
- else {
+ } else {
providers.addAll(findByApplication(candidate));
}
}
}
}
- Set result = convertProviders2DTO(providers);
- return result;
+ return convertProviders2DTO(providers);
}
/**
@@ -472,6 +303,7 @@ public Set convertProviders2DTO(List providers) {
s.setService(interfaze);
s.setGroup(group);
s.setVersion(version);
+ s.setRegistrySource(provider.getRegistrySource());
result.add(s);
}
return result;
diff --git a/dubbo-admin-server/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.admin.registry.mapping.ServiceMapping b/dubbo-admin-server/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.admin.registry.mapping.ServiceMapping
new file mode 100644
index 000000000..83709e762
--- /dev/null
+++ b/dubbo-admin-server/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.admin.registry.mapping.ServiceMapping
@@ -0,0 +1 @@
+zookeeper=org.apache.dubbo.admin.registry.mapping.impl.ZookeeperServiceMapping
\ No newline at end of file
diff --git a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
index a8ecc7cc1..1be485d1d 100644
--- a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
+++ b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/service/RegistryServerSyncTest.java
@@ -18,16 +18,22 @@
package org.apache.dubbo.admin.service;
import org.apache.dubbo.admin.common.util.Constants;
+import org.apache.dubbo.admin.service.impl.InterfaceRegistryCache;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.url.component.URLParam;
import org.apache.dubbo.registry.Registry;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.util.ReflectionTestUtils;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
@@ -46,9 +52,11 @@ public class RegistryServerSyncTest {
@InjectMocks
private RegistryServerSync registryServerSync;
- @Test
- public void testGetRegistryCache() {
- registryServerSync.getRegistryCache();
+ private InterfaceRegistryCache interfaceRegistryCache = new InterfaceRegistryCache();
+
+ @Before
+ public void setUp() throws Exception {
+ ReflectionTestUtils.setField(registryServerSync, "interfaceRegistryCache", interfaceRegistryCache);
}
@Test
@@ -71,27 +79,32 @@ public void testNotify() {
// when url.getProtocol is not empty protocol
URL consumerUrl = mock(URL.class);
URL providerUrl = mock(URL.class);
-
- when(consumerUrl.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY)).thenReturn(Constants.CONSUMER_PROTOCOL);
+ HashMap consumerUrlParam = new HashMap<>();
+ consumerUrlParam.put(Constants.CATEGORY_KEY,Constants.CONSUMER_PROTOCOL);
+ HashMap providerUrlParam = new HashMap<>();
+ providerUrlParam.put(Constants.CATEGORY_KEY,Constants.PROVIDER_PROTOCOL);
+ when(consumerUrl.getUrlParam()).thenReturn(URLParam.parse(consumerUrlParam));
when(consumerUrl.getServiceInterface()).thenReturn("org.apache.dubbo.consumer");
- when(consumerUrl.getServiceKey()).thenReturn("org.apache.dubbo.consumer");
when(consumerUrl.toFullString()).thenReturn("consumer://192.168.1.10/sunbufu.dubbo.consumer?application=dubbo&category=consumer&check=false&dubbo=2.7.0&interface=sunbufu.dubbo.consumer&loadbalabce=roundrobin&mehods=sayHi,sayGoodBye&owner=sunbufu&pid=18&protocol=dubbo&side=consumer&timeout=3000×tamp=1548127407769");
+ when(providerUrl.getUrlParam()).thenReturn(URLParam.parse(providerUrlParam));
when(providerUrl.getParameter(Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY)).thenReturn(Constants.PROVIDER_PROTOCOL);
when(providerUrl.getServiceInterface()).thenReturn("org.apache.dubbo.provider");
- when(providerUrl.getServiceKey()).thenReturn("org.apache.dubbo.provider");
when(providerUrl.toFullString()).thenReturn("consumer://192.168.1.10/sunbufu.dubbo.consumer?application=dubbo&category=consumer&check=false&dubbo=2.6.2&interface=sunbufu.dubbo.consumer&loadbalabce=roundrobin&mehods=sayHi,sayGoodBye&owner=sunbufu&pid=18&protocol=dubbo&side=consumer&timeout=3000×tamp=1548127407769");
registryServerSync.notify(Arrays.asList(consumerUrl, consumerUrl, providerUrl));
- ConcurrentMap> consumerMap = registryServerSync.getRegistryCache().get(Constants.CONSUMER_PROTOCOL);
+ ConcurrentMap> consumerMap = interfaceRegistryCache.get(Constants.CONSUMER_PROTOCOL);
assertTrue(consumerMap.keySet().contains("org.apache.dubbo.consumer"));
- ConcurrentMap> providerMap = registryServerSync.getRegistryCache().get(Constants.PROVIDER_PROTOCOL);
+ ConcurrentMap> providerMap = interfaceRegistryCache.get(Constants.PROVIDER_PROTOCOL);
assertTrue(providerMap.keySet().contains("org.apache.dubbo.provider"));
// when url.getProtocol is empty protocol
when(consumerUrl.getProtocol()).thenReturn(Constants.EMPTY_PROTOCOL);
- when(consumerUrl.getParameter(Constants.GROUP_KEY)).thenReturn("dubbo");
- when(consumerUrl.getParameter(Constants.VERSION_KEY)).thenReturn("2.7.0");
+ consumerUrlParam = new HashMap<>();
+ consumerUrlParam.put(Constants.CATEGORY_KEY,Constants.CONSUMER_PROTOCOL);
+ consumerUrlParam.put(Constants.GROUP_KEY,"dubbo");
+ consumerUrlParam.put(Constants.VERSION_KEY,"2.7.0");
+ when(consumerUrl.getUrlParam()).thenReturn(URLParam.parse(consumerUrlParam));
registryServerSync.notify(Collections.singletonList(consumerUrl));
assertTrue(!consumerMap.keySet().contains("org.apache.dubbo.consumer"));
diff --git a/dubbo-admin-ui/src/components/ServiceDetail.vue b/dubbo-admin-ui/src/components/ServiceDetail.vue
index 366b5ffcd..79fa779f8 100644
--- a/dubbo-admin-ui/src/components/ServiceDetail.vue
+++ b/dubbo-admin-ui/src/components/ServiceDetail.vue
@@ -54,6 +54,7 @@
{{getIp(props.item.address)}} |
{{getPort(props.item.address)}} |
+ {{props.item.registrySource}} |
|
|
{{props.item.weight}} |
@@ -166,6 +167,10 @@
text: this.$t('port'),
value: 'port'
},
+ {
+ text: this.$t('registrySource'),
+ value: 'registrySource'
+ },
{
text: this.$t('timeout'),
value: 'timeout'
@@ -204,7 +209,16 @@
this.$axios.get('/service/' + service)
.then(response => {
this.providerDetails = response.data.providers
+ const instanceRegistry = this.$t('instanceRegistry')
+ const interfaceRegistry = this.$t('interfaceRegistry')
for (let i = 0; i < this.providerDetails.length; i++) {
+ if (this.providerDetails[i].registrySource === 'INSTANCE') {
+ this.providerDetails[i].registrySource = instanceRegistry
+ }
+ if (this.providerDetails[i].registrySource === 'INTERFACE') {
+ this.providerDetails[i].registrySource = interfaceRegistry
+ }
+ console.log(this.providerDetails[i])
this.$set(this.providerDetails[i], 'hint', 'url')
}
this.consumerDetails = response.data.consumers
diff --git a/dubbo-admin-ui/src/components/ServiceSearch.vue b/dubbo-admin-ui/src/components/ServiceSearch.vue
index c7fa2c8e6..c5ce4fbe2 100644
--- a/dubbo-admin-ui/src/components/ServiceSearch.vue
+++ b/dubbo-admin-ui/src/components/ServiceSearch.vue
@@ -81,11 +81,12 @@
{{props.item.group}} |
{{props.item.version}} |
{{props.item.appName}} |
+ {{props.item.registrySource}} |
{{ $t('detail') }}
@@ -112,7 +113,7 @@
{{ $t(item.title) }}
@@ -198,7 +199,17 @@ export default {
if (!this.resultPage || !this.resultPage.content) {
return []
}
- return this.resultPage.content
+ const instanceRegistry = this.$t('instanceRegistry')
+ const interfaceRegistry = this.$t('interfaceRegistry')
+ return this.resultPage.content.filter(function (item) {
+ if (item.registrySource === 'INSTANCE') {
+ item.registrySource = instanceRegistry
+ }
+ if (item.registrySource === 'INTERFACE') {
+ item.registrySource = interfaceRegistry
+ }
+ return item
+ })
}
},
watch: {
@@ -243,6 +254,11 @@ export default {
value: 'application',
align: 'left'
},
+ {
+ text: this.$t('registrySource'),
+ value: 'registry',
+ align: 'left'
+ },
{
text: this.$t('operation'),
value: 'operation',
diff --git a/dubbo-admin-ui/src/components/governance/MeshRule.vue b/dubbo-admin-ui/src/components/governance/MeshRule.vue
index f29b5a43f..d55fd5bae 100644
--- a/dubbo-admin-ui/src/components/governance/MeshRule.vue
+++ b/dubbo-admin-ui/src/components/governance/MeshRule.vue
@@ -403,7 +403,7 @@
},
mounted: function () {
this.setHeaders()
- this.$store.dispatch('loadAppItems')
+ this.$store.dispatch('loadInstanceAppItems')
this.ruleText = this.template
let query = this.$route.query
let filter = null
diff --git a/dubbo-admin-ui/src/lang/en.js b/dubbo-admin-ui/src/lang/en.js
index c239380da..f04721811 100644
--- a/dubbo-admin-ui/src/lang/en.js
+++ b/dubbo-admin-ui/src/lang/en.js
@@ -46,6 +46,9 @@ export default {
serialization: 'serialization',
appName: 'Application Name',
serviceName: 'Service Name',
+ registrySource: 'Registry Source',
+ instanceRegistry: 'Instance Registry',
+ interfaceRegistry: 'Interface Registry',
operation: 'Operation',
searchResult: 'Search Result',
search: 'Search',
diff --git a/dubbo-admin-ui/src/lang/zh.js b/dubbo-admin-ui/src/lang/zh.js
index 1116702a7..084a12917 100644
--- a/dubbo-admin-ui/src/lang/zh.js
+++ b/dubbo-admin-ui/src/lang/zh.js
@@ -46,6 +46,9 @@ export default {
serialization: '序列化',
appName: '应用名',
serviceName: '服务名',
+ registrySource: '注册来源',
+ instanceRegistry: '应用级',
+ interfaceRegistry: '接口级',
operation: '操作',
searchResult: '查询结果',
search: '搜索',
diff --git a/dubbo-admin-ui/src/store/index.js b/dubbo-admin-ui/src/store/index.js
index d553ce851..57484ba5b 100644
--- a/dubbo-admin-ui/src/store/index.js
+++ b/dubbo-admin-ui/src/store/index.js
@@ -70,6 +70,18 @@ export const store = new Vuex.Store({
}
})
},
+ /**
+ * Load instance registry application items from server, put results into storage.
+ */
+ loadInstanceAppItems ({commit}) {
+ Vue.prototype.$axios.get('/applications/instance')
+ .then(response => {
+ if (response.status === 200) {
+ const appItems = response.data
+ commit('setAppItems', appItems)
+ }
+ })
+ },
/**
* Load application items from consumer, put results into storage.
*/
diff --git a/pom.xml b/pom.xml
index f83214725..5c8a312c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,8 +56,9 @@
0.3.0-SNAPSHOT
${project.basedir}
3.7
- 2.7.12
- 2.12.0
+ 3.0.2
+ 2.7.13
+ 4.0.1
4.1.0
1.2.67
2.9.2
@@ -128,7 +129,7 @@
org.apache.dubbo
dubbo-serialization-kryo
- ${dubbo-version}
+ ${serialization-kryo-version}
@@ -154,6 +155,19 @@
+
+
+ org.apache.curator
+ curator-x-discovery
+ ${curator-version}
+
+
+ org.apache.zookeeper
+ zookeeper
+
+
+
+
com.alibaba
fastjson
From 9b3095bb3705db475996846bec4e4096c0dc109f Mon Sep 17 00:00:00 2001
From: haoyann <1064645534@qq.com>
Date: Tue, 31 Aug 2021 11:48:19 +0800
Subject: [PATCH 2/4] fix checkstyle
---
.../dubbo/admin/service/impl/InstanceRegistryQueryHelper.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java
index 6391d4c88..aae6e6579 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/InstanceRegistryQueryHelper.java
@@ -27,7 +27,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
From 88b319736475f3cc1edfea1e1c7cccd9eb1051cb Mon Sep 17 00:00:00 2001
From: haoyann <1064645534@qq.com>
Date: Tue, 31 Aug 2021 12:37:38 +0800
Subject: [PATCH 3/4] fix ci
---
.../apache/dubbo/admin/AbstractSpringIntegrationTest.java | 2 +-
.../dubbo/admin/controller/MeshRouteControllerTest.java | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
index 9448a9388..0626da2c6 100644
--- a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
+++ b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/AbstractSpringIntegrationTest.java
@@ -73,7 +73,7 @@ public void initialize(ConfigurableApplicationContext configurableApplicationCon
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext,
"admin.registry.address=zookeeper://" + zkServer.getConnectString());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext,
- "admin.metadata.address=zookeeper://" + zkServer.getConnectString());
+ "admin.metadata-report.address=zookeeper://" + zkServer.getConnectString());
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext,
"admin.config-center=zookeeper://" + zkServer.getConnectString());
}
diff --git a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/controller/MeshRouteControllerTest.java b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/controller/MeshRouteControllerTest.java
index 9cf6146e1..8cfdd9f80 100644
--- a/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/controller/MeshRouteControllerTest.java
+++ b/dubbo-admin-server/src/test/java/org/apache/dubbo/admin/controller/MeshRouteControllerTest.java
@@ -20,11 +20,13 @@
import org.apache.dubbo.admin.AbstractSpringIntegrationTest;
import org.apache.dubbo.admin.common.util.Constants;
import org.apache.dubbo.admin.model.dto.MeshRouteDTO;
+import org.apache.dubbo.admin.service.ProviderService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -40,6 +42,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
public class MeshRouteControllerTest extends AbstractSpringIntegrationTest {
@@ -49,6 +52,9 @@ public class MeshRouteControllerTest extends AbstractSpringIntegrationTest {
@Autowired
private ObjectMapper objectMapper;
+ @MockBean
+ private ProviderService providerService;
+
@After
public void tearDown() throws Exception {
if (zkClient.checkExists().forPath("/dubbo") != null) {
@@ -77,6 +83,7 @@ public void createMeshRoute() throws IOException {
// valid mesh rule
meshRoute.setApplication(application);
meshRoute.setMeshRule(getFileContent("/MeshRoute.yml"));
+ when(providerService.findVersionInApplication(application)).thenReturn("3.0.0");
response = restTemplate.postForEntity(url("/api/{env}/rules/route/mesh"), meshRoute, String.class, env);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertTrue(Boolean.valueOf(response.getBody()));
From 36a98a7839fcd90a685537b52dfa78158cbc4bec Mon Sep 17 00:00:00 2001
From: haoyann <1064645534@qq.com>
Date: Tue, 31 Aug 2021 18:29:56 +0800
Subject: [PATCH 4/4] remove useless pom import,modify Chinese comment
---
dubbo-admin-server/pom.xml | 5 -----
.../apache/dubbo/admin/common/util/ServiceTestUtil.java | 5 +----
.../apache/dubbo/admin/common/util/ServiceTestV3Util.java | 5 +----
pom.xml | 7 -------
4 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/dubbo-admin-server/pom.xml b/dubbo-admin-server/pom.xml
index cb3ae75a8..9a5df728a 100644
--- a/dubbo-admin-server/pom.xml
+++ b/dubbo-admin-server/pom.xml
@@ -172,11 +172,6 @@
netty-all
-
-
-
-
-
org.mockito
mockito-core
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/ServiceTestUtil.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/ServiceTestUtil.java
index 5e94ae70f..b9b6bdefe 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/ServiceTestUtil.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/ServiceTestUtil.java
@@ -180,10 +180,7 @@ private static Object generateMapType(ServiceDefinition sd, TypeDefinition td) {
keyType = StringUtils.strip(keyType);
Map
-
- org.apache.dubbo
- dubbo-serialization-kryo
- ${serialization-kryo-version}
-
-
org.apache.curator
curator-framework
|