You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/11/06 08:27:28 UTC
[dubbo] 02/02: uncomment router filter
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit 0a746cc262a4155e346922af919dc5acc8ffd07b
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Nov 6 16:26:18 2019 +0800
uncomment router filter
---
.../registry/integration/RegistryDirectory.java | 61 ++++++++--------------
1 file changed, 23 insertions(+), 38 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 7b90501..939ec54 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
@@ -18,6 +18,7 @@ package org.apache.dubbo.registry.integration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
+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;
@@ -34,6 +35,7 @@ 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.Cluster;
import org.apache.dubbo.rpc.cluster.Configurator;
import org.apache.dubbo.rpc.cluster.Router;
@@ -570,44 +572,27 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
@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);
-// }
-//
-//
-// // FIXME Is there any need of failing back to Constants.ANY_VALUE or the first available method invokers when invokers is null?
-// /*Map<String, List<Invoker<T>>> localMethodInvokerMap = this.methodInvokerMap; // local reference
-// if (localMethodInvokerMap != null && localMethodInvokerMap.size() > 0) {
-// String methodName = RpcUtils.getMethodName(invocation);
-// invokers = localMethodInvokerMap.get(methodName);
-// if (invokers == null) {
-// invokers = localMethodInvokerMap.get(Constants.ANY_VALUE);
-// }
-// if (invokers == null) {
-// Iterator<List<Invoker<T>>> iterator = localMethodInvokerMap.values().iterator();
-// if (iterator.hasNext()) {
-// invokers = iterator.next();
-// }
-// }
-// }*/
-// return invokers == null ? Collections.emptyList() : invokers;
- return invokers;
+ 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