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/05 06:52:00 UTC
[dubbo] branch master updated: Ehance gRPC protocol and
configurator reExport procedure (#5423)
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
The following commit(s) were added to refs/heads/master by this push:
new 1cd29b6 Ehance gRPC protocol and configurator reExport procedure (#5423)
1cd29b6 is described below
commit 1cd29b6f8ebf6c5b0180071a5d1a963889a80a01
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu Dec 5 14:51:43 2019 +0800
Ehance gRPC protocol and configurator reExport procedure (#5423)
---
.../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 8381a3f..afc50db 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,13 +18,9 @@ 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.config.ReferenceConfigBase;
-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;
@@ -44,8 +40,6 @@ import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import static org.apache.dubbo.rpc.Constants.INTERFACES;
-
/**
*
*/
@@ -102,11 +96,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();
@@ -211,50 +200,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();
- }
- }
-
}