This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new b6904c8 Remove duplicate code in RegistryDirectory (#7684)
b6904c8 is described below
commit b6904c80c5b1aa75023ab619d9f3ca281d937abc
Author: 灼华 <[email protected]>
AuthorDate: Tue May 11 09:54:41 2021 +0800
Remove duplicate code in RegistryDirectory (#7684)
* Remove duplicate code in RegistryDirectory
* Remove unused import
* Fix code-style check
---
.../registry/integration/RegistryDirectory.java | 69 ----------------------
1 file changed, 69 deletions(-)
diff --git
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
index f120327..8fce468 100644
---
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
+++
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.registry.integration;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
@@ -30,13 +29,10 @@ import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.registry.AddressListener;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.remoting.Constants;
-import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
-import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.Configurator;
import org.apache.dubbo.rpc.cluster.Router;
-import org.apache.dubbo.rpc.cluster.RouterChain;
import org.apache.dubbo.rpc.cluster.directory.StaticDirectory;
import org.apache.dubbo.rpc.cluster.support.ClusterUtils;
import org.apache.dubbo.rpc.model.ApplicationModel;
@@ -64,7 +60,6 @@ import static
org.apache.dubbo.common.constants.RegistryConstants.APP_DYNAMIC_CO
import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
import static
org.apache.dubbo.common.constants.RegistryConstants.COMPATIBLE_CONFIG_KEY;
import static
org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
-import static
org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY;
import static
org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
import static
org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_CONFIGURATORS_CATEGORY;
import static
org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL;
@@ -72,8 +67,6 @@ import static
org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATE
import static
org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY;
import static
org.apache.dubbo.common.constants.RegistryConstants.ROUTE_PROTOCOL;
import static org.apache.dubbo.registry.Constants.CONFIGURATORS_SUFFIX;
-import static
org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.DEFAULT_REGISTER_CONSUMER_KEYS;
-import static org.apache.dubbo.remoting.Constants.CHECK_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.ROUTER_KEY;
@@ -481,60 +474,6 @@ public class RegistryDirectory<T> extends
DynamicDirectory<T> implements NotifyL
}
@Override
- public List<Invoker<T>> doList(Invocation invocation) {
- if (forbidden) {
- // 1. No service provider 2. Service providers are disabled
- throw new RpcException(RpcException.FORBIDDEN_EXCEPTION, "No
provider available from registry " +
- getUrl().getAddress() + " for service " +
getConsumerUrl().getServiceKey() + " on consumer " +
- NetUtils.getLocalHost() + " use dubbo version " +
Version.getVersion() +
- ", please check status of providers(disabled, not
registered or in blacklist).");
- }
-
- if (multiGroup) {
- return this.invokers == null ? Collections.emptyList() :
this.invokers;
- }
-
- List<Invoker<T>> invokers = null;
- try {
- // Get invokers from cache, only runtime routers will be executed.
- invokers = routerChain.route(getConsumerUrl(), invocation);
- } catch (Throwable t) {
- logger.error("Failed to execute router: " + getUrl() + ", cause: "
+ t.getMessage(), t);
- }
-
- return invokers == null ? Collections.emptyList() : invokers;
- }
-
- @Override
- public Class<T> getInterface() {
- return serviceType;
- }
-
- @Override
- public List<Invoker<T>> getAllInvokers() {
- return invokers;
- }
-
- @Override
- public URL getConsumerUrl() {
- return this.overrideDirectoryUrl;
- }
-
- public URL getRegisteredConsumerUrl() {
- return registeredConsumerUrl;
- }
-
- public void setRegisteredConsumerUrl(URL url) {
- if (!shouldSimplified) {
- this.registeredConsumerUrl = url.addParameters(CATEGORY_KEY,
CONSUMERS_CATEGORY, CHECK_KEY,
- String.valueOf(false));
- } else {
- this.registeredConsumerUrl = URL.valueOf(url,
DEFAULT_REGISTER_CONSUMER_KEYS, null).addParameters(
- CATEGORY_KEY, CONSUMERS_CATEGORY, CHECK_KEY,
String.valueOf(false));
- }
- }
-
- @Override
public boolean isAvailable() {
if (isDestroyed()) {
return false;
@@ -551,10 +490,6 @@ public class RegistryDirectory<T> extends
DynamicDirectory<T> implements NotifyL
return false;
}
- public void buildRouterChain(URL url) {
- this.setRouterChain(RouterChain.buildChain(url));
- }
-
/**
* Haomin: added for test purpose
*/
@@ -562,10 +497,6 @@ public class RegistryDirectory<T> extends
DynamicDirectory<T> implements NotifyL
return urlInvokerMap;
}
- public List<Invoker<T>> getInvokers() {
- return invokers;
- }
-
private boolean isValidCategory(URL url) {
String category = url.getParameter(CATEGORY_KEY, DEFAULT_CATEGORY);
if ((ROUTERS_CATEGORY.equals(category) ||
ROUTE_PROTOCOL.equals(url.getProtocol())) ||