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/12/04 05:39:13 UTC

[dubbo] branch grpc-protocol-enhancement created (now 2d442df)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a change to branch grpc-protocol-enhancement
in repository https://gitbox.apache.org/repos/asf/dubbo.git.


      at 2d442df  Ehance gRPC protocol and configurator reExport procedure.

This branch includes the following new commits:

     new 2d442df  Ehance gRPC protocol and configurator reExport procedure.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[dubbo] 01/01: Ehance gRPC protocol and configurator reExport procedure.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch grpc-protocol-enhancement
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 2d442dfe7171ae1c7d1ccb2f32a81629105aa1da
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Dec 4 13:38:55 2019 +0800

    Ehance gRPC protocol and configurator reExport procedure.
---
 .../cluster/configurator/AbstractConfigurator.java |  6 ++-
 .../dubbo/common/constants/CommonConstants.java    |  2 +
 .../registry/integration/RegistryProtocol.java     |  2 +-
 .../dubbo/rpc/protocol/grpc/GrpcProtocol.java      | 57 ----------------------
 4 files changed, 7 insertions(+), 60 deletions(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java
index 0c70b89..4e4c1b6 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/configurator/AbstractConfigurator.java
@@ -26,20 +26,21 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import static org.apache.dubbo.rpc.cluster.Constants.CONFIG_VERSION_KEY;
-import static org.apache.dubbo.rpc.cluster.Constants.OVERRIDE_PROVIDERS_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
 import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
 import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
 import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.INTERFACES;
 import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
 import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
 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.DYNAMIC_KEY;
+import static org.apache.dubbo.rpc.cluster.Constants.CONFIG_VERSION_KEY;
+import static org.apache.dubbo.rpc.cluster.Constants.OVERRIDE_PROVIDERS_KEY;
 
 /**
  * AbstractOverrideConfigurator
@@ -128,6 +129,7 @@ public abstract class AbstractConfigurator implements Configurator {
                     conditionKeys.add(SIDE_KEY);
                     conditionKeys.add(CONFIG_VERSION_KEY);
                     conditionKeys.add(COMPATIBLE_CONFIG_KEY);
+                    conditionKeys.add(INTERFACES);
                     for (Map.Entry<String, String> entry : configuratorUrl.getParameters().entrySet()) {
                         String key = entry.getKey();
                         String value = entry.getValue();
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
index 1717301..1709994 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
@@ -290,4 +290,6 @@ public interface CommonConstants {
 
     String DUBBO_INVOCATION_PREFIX = "_DUBBO_IGNORE_ATTACH_";
 
+    String INTERFACES = "interfaces";
+
 }
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index 41cd542..fb3d0e9 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -569,7 +569,7 @@ public class RegistryProtocol implements Protocol {
             //The current, may have been merged many times
             URL currentUrl = exporter.getInvoker().getUrl();
             //Merged with this configuration
-            URL newUrl = getConfigedInvokerUrl(configurators, originUrl);
+            URL newUrl = getConfigedInvokerUrl(configurators, currentUrl);
             newUrl = getConfigedInvokerUrl(providerConfigurationListener.getConfigurators(), newUrl);
             newUrl = getConfigedInvokerUrl(serviceConfigurationListeners.get(originUrl.getServiceKey())
                     .getConfigurators(), newUrl);
diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
index 8a1188f..a3fcb49 100644
--- a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
@@ -18,12 +18,8 @@ package org.apache.dubbo.rpc.protocol.grpc;/*
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.logger.Logger;
 import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.rpc.Exporter;
-import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.ProtocolServer;
-import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcException;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.model.ProviderModel;
@@ -43,8 +39,6 @@ import java.lang.reflect.Method;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import static org.apache.dubbo.rpc.Constants.INTERFACES;
-
 /**
  *
  */
@@ -101,11 +95,6 @@ public class GrpcProtocol extends AbstractProxyProtocol {
     }
 
     @Override
-    public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
-        return super.export(new GrpcServerProxyInvoker<>(invoker));
-    }
-
-    @Override
     protected <T> Invoker<T> protocolBindingRefer(final Class<T> type, final URL url) throws RpcException {
         Class<?> enclosingClass = type.getEnclosingClass();
 
@@ -204,50 +193,4 @@ public class GrpcProtocol extends AbstractProxyProtocol {
         }
     }
 
-    /**
-     * TODO, If IGreeter extends BindableService we can avoid the existence of this wrapper invoker.
-     *
-     * @param <T>
-     */
-    private class GrpcServerProxyInvoker<T> implements Invoker<T> {
-
-        private Invoker<T> invoker;
-
-        public GrpcServerProxyInvoker(Invoker<T> invoker) {
-            this.invoker = invoker;
-        }
-
-        @Override
-        public Class<T> getInterface() {
-            return invoker.getInterface();
-        }
-
-        @Override
-        public Result invoke(Invocation invocation) throws RpcException {
-            return invoker.invoke(invocation);
-        }
-
-        @Override
-        public URL getUrl() {
-            URL url = invoker.getUrl();
-            String interfaces = url.getParameter(INTERFACES);
-            if (StringUtils.isNotEmpty(interfaces)) {
-                interfaces += ("," + BindableService.class.getName());
-            } else {
-                interfaces = BindableService.class.getName();
-            }
-            return url.addParameter(INTERFACES, interfaces);
-        }
-
-        @Override
-        public boolean isAvailable() {
-            return invoker.isAvailable();
-        }
-
-        @Override
-        public void destroy() {
-            invoker.destroy();
-        }
-    }
-
 }