This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 502b4c86df Tri grpc compatibility (#11544)
502b4c86df is described below
commit 502b4c86dffbc0de3863a5e41ed7b9f633450c1c
Author: earthchen <[email protected]>
AuthorDate: Mon Feb 13 21:16:52 2023 +0800
Tri grpc compatibility (#11544)
---
dubbo-demo/dubbo-demo-triple/pom.xml | 4 -
dubbo-distribution/dubbo-all/pom.xml | 33 +-
dubbo-distribution/dubbo-bom/pom.xml | 6 +-
dubbo-rpc/dubbo-rpc-grpc/pom.xml | 73 ---
.../rpc/protocol/grpc/DubboHandlerRegistry.java | 73 ---
.../dubbo/rpc/protocol/grpc/GrpcConstants.java | 41 --
.../dubbo/rpc/protocol/grpc/GrpcInvoker.java | 118 ----
.../dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java | 257 ---------
.../dubbo/rpc/protocol/grpc/GrpcProtocol.java | 240 --------
.../grpc/ReferenceCountManagedChannel.java | 86 ---
.../grpc/interceptors/ClientInterceptor.java | 27 -
.../grpc/interceptors/GrpcConfigurator.java | 42 --
.../grpc/interceptors/RpcContextInterceptor.java | 101 ----
.../grpc/interceptors/ServerTransportFilter.java | 28 -
.../dubbo/internal/org.apache.dubbo.rpc.Protocol | 1 -
...pc.protocol.grpc.interceptors.ClientInterceptor | 1 -
...pc.protocol.grpc.interceptors.ServerInterceptor | 1 -
.../dubbo/rpc/protocol/grpc/GrpcProtocolTest.java | 125 -----
.../protocol/grpc/support/DubboGreeterGrpc.java | 221 --------
.../rpc/protocol/grpc/support/GreeterGrpc.java | 330 -----------
.../rpc/protocol/grpc/support/GrpcGreeterImpl.java | 31 --
.../rpc/protocol/grpc/support/HelloReply.java | 616 ---------------------
.../protocol/grpc/support/HelloReplyOrBuilder.java | 37 --
.../rpc/protocol/grpc/support/HelloRequest.java | 616 ---------------------
.../grpc/support/HelloRequestOrBuilder.java | 37 --
.../rpc/protocol/grpc/support/HelloWorldProto.java | 90 ---
.../dubbo/rpc/protocol/tri/GrpcHttp2Protocol.java} | 7 +-
.../dubbo/rpc/protocol/tri/GrpcProtocol.java} | 16 +-
.../org.apache.dubbo.remoting.api.WireProtocol | 3 +-
.../dubbo/internal/org.apache.dubbo.rpc.Protocol | 3 +-
dubbo-rpc/pom.xml | 1 -
dubbo-test/dubbo-dependencies-all/pom.xml | 5 +-
32 files changed, 20 insertions(+), 3250 deletions(-)
diff --git a/dubbo-demo/dubbo-demo-triple/pom.xml
b/dubbo-demo/dubbo-demo-triple/pom.xml
index a509b70257..2ae860a5bd 100644
--- a/dubbo-demo/dubbo-demo-triple/pom.xml
+++ b/dubbo-demo/dubbo-demo-triple/pom.xml
@@ -100,10 +100,6 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty4</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-grpc</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>
diff --git a/dubbo-distribution/dubbo-all/pom.xml
b/dubbo-distribution/dubbo-all/pom.xml
index d589d75951..a728b8a8a8 100644
--- a/dubbo-distribution/dubbo-all/pom.xml
+++ b/dubbo-distribution/dubbo-all/pom.xml
@@ -355,13 +355,7 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-grpc</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
+
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-triple</artifactId>
@@ -520,7 +514,6 @@
<include>org.apache.dubbo:dubbo-remoting-zookeeper-curator5</include>
<include>org.apache.dubbo:dubbo-rpc-api</include>
<include>org.apache.dubbo:dubbo-rpc-dubbo</include>
-
<include>org.apache.dubbo:dubbo-rpc-grpc</include>
<include>org.apache.dubbo:dubbo-rpc-injvm</include>
<include>org.apache.dubbo:dubbo-rpc-rest</include>
<include>org.apache.dubbo:dubbo-rpc-triple</include>
@@ -1135,30 +1128,6 @@
META-INF/dubbo/internal/org.apache.dubbo.rpc.model.ScopeModelInitializer
</resource>
</transformer>
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>
-
META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor
- </resource>
- </transformer>
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>
-
META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.GrpcConfigurator
- </resource>
- </transformer>
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>
-
META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor
- </resource>
- </transformer>
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
- <resource>
-
META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerTransportFilter
- </resource>
- </transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>
diff --git a/dubbo-distribution/dubbo-bom/pom.xml
b/dubbo-distribution/dubbo-bom/pom.xml
index ec65010326..4b22ec55f9 100644
--- a/dubbo-distribution/dubbo-bom/pom.xml
+++ b/dubbo-distribution/dubbo-bom/pom.xml
@@ -395,11 +395,7 @@
<artifactId>dubbo-rpc-rest</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-grpc</artifactId>
- <version>${project.version}</version>
- </dependency>
+
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-triple</artifactId>
diff --git a/dubbo-rpc/dubbo-rpc-grpc/pom.xml b/dubbo-rpc/dubbo-rpc-grpc/pom.xml
deleted file mode 100644
index ec84397eed..0000000000
--- a/dubbo-rpc/dubbo-rpc-grpc/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<!--
- 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc</artifactId>
- <version>${revision}</version>
- </parent>
- <artifactId>dubbo-rpc-grpc</artifactId>
- <packaging>jar</packaging>
- <name>${project.artifactId}</name>
- <description>The gRPC integration module</description>
- <properties>
- <skip_maven_deploy>false</skip_maven_deploy>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-http</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-cluster</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-netty</artifactId>
- </dependency>
- <!-- <dependency>-->
- <!-- <groupId>io.grpc</groupId>-->
- <!-- <artifactId>grpc-netty-shaded</artifactId>-->
- <!-- </dependency>-->
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-protobuf</artifactId>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-stub</artifactId>
- </dependency>
- <dependency>
- <groupId>io.grpc</groupId>
- <artifactId>grpc-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
deleted file mode 100644
index 6252e95aa9..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/DubboHandlerRegistry.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-import io.grpc.BindableService;
-import io.grpc.HandlerRegistry;
-import io.grpc.ServerMethodDefinition;
-import io.grpc.ServerServiceDefinition;
-
-import javax.annotation.Nullable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- *
- */
-public class DubboHandlerRegistry extends HandlerRegistry {
-
- private final Map<String, ServerServiceDefinition> services = new
ConcurrentHashMap<>();
- private final Map<String, ServerMethodDefinition<?, ?>> methods = new
ConcurrentHashMap<>();
-
- public DubboHandlerRegistry() {
- }
-
- /**
- * Returns the service definitions in this registry.
- */
- @Override
- public List<ServerServiceDefinition> getServices() {
- return Collections.unmodifiableList(new
ArrayList<>(services.values()));
- }
-
- @Nullable
- @Override
- public ServerMethodDefinition<?, ?> lookupMethod(String methodName,
@Nullable String authority) {
- // TODO (carl-mastrangelo): honor authority header.
- return methods.get(methodName);
- }
-
- void addService(BindableService bindableService, String key) {
- ServerServiceDefinition service = bindableService.bindService();
- services.put(key, service);
- for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
- methods.put(method.getMethodDescriptor().getFullMethodName(),
method);
- }
- }
-
- void removeService(String serviceKey) {
- ServerServiceDefinition service = services.remove(serviceKey);
- if (null != service) {
- for (ServerMethodDefinition<?, ?> method : service.getMethods()) {
-
methods.remove(method.getMethodDescriptor().getFullMethodName(), method);
- }
- }
- }
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConstants.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConstants.java
deleted file mode 100644
index 9982751829..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConstants.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-
-public class GrpcConstants {
-
- public static final String DIERCTOR_KEY = "grpc.director";
- public static final String HANDSHAKE_TIMEOUT = "grpc.handshakeTimeout";
- public static final String MAX_INBOUND_MESSAGE_SIZE =
"grpc.maxInboundMessageSize";
- public static final String MAX_INBOUND_METADATA_SIZE =
"grpc.maxOutboundMessageSize";
- public static final String FLOWCONTROL_WINDOW = "grpc.flowControlWindow";
- public static final String MAX_CONCURRENT_CALLS_PER_CONNECTION =
"grpc.maxConcurrentCallsPerConnection";
-
- public static final String WORKER_THREAD_NUM = "grpc.io.num";
- public static final String BOSS_THREAD_NUM = "grpc.boss.num";
- public static final String CHANNEL_TYPE = "grpc.channel.type";
-
- public static final String SERVER_INTERCEPTORS = "grpc.serverInterceptors";
- public static final String CLIENT_INTERCEPTORS = "grpc.clientInterceptors";
- public static final String TRANSPORT_FILTERS = "grpc.transportFilters";
-
- public static final String EXECUTOR = "grpc.executor";
-
- public static final String CONFIGURATOR = "grpc.configurator";
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcInvoker.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcInvoker.java
deleted file mode 100644
index 4ca6fb796f..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcInvoker.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.rpc.Invocation;
-import org.apache.dubbo.rpc.Invoker;
-import org.apache.dubbo.rpc.Result;
-import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.protocol.AbstractInvoker;
-
-import io.grpc.Status;
-import io.grpc.StatusException;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-public class GrpcInvoker<T> extends AbstractInvoker<T> {
- private final ReentrantLock destroyLock = new ReentrantLock();
-
- private final Invoker<T> target;
- private ReferenceCountManagedChannel channel;
-
-// private static List<Exception> grpcExceptions = new ArrayList<>();
-// static {
-// grpcExceptions.add();
-// }
-
- public GrpcInvoker(Class<T> type, URL url, Invoker<T> target,
ReferenceCountManagedChannel channel) {
- super(type, url);
- this.target = target;
- this.channel = channel;
- }
-
- @Override
- protected Result doInvoke(Invocation invocation) throws Throwable {
- try {
- Result result = target.invoke(invocation);
- // FIXME result is an AsyncRpcResult instance.
- Throwable e = result.getException();
- if (e != null) {
- throw getRpcException(getInterface(), getUrl(), invocation, e);
- }
- return result;
- } catch (RpcException e) {
- if (e.getCode() == RpcException.UNKNOWN_EXCEPTION) {
- e.setCode(getErrorCode(e.getCause()));
- }
- throw e;
- } catch (Throwable e) {
- throw getRpcException(getInterface(), getUrl(), invocation, e);
- }
- }
-
- @Override
- public boolean isAvailable() {
- return super.isAvailable() && !channel.isShutdown() &&
!channel.isTerminated();
- }
-
- @Override
- public boolean isDestroyed() {
- return super.isDestroyed() || channel.isShutdown() ||
channel.isTerminated();
- }
-
- @Override
- public void destroy() {
- if (!super.isDestroyed()) {
- // double check to avoid dup close
- destroyLock.lock();
- try {
- if (super.isDestroyed()) {
- return;
- }
- super.destroy();
- channel.shutdown();
- } finally {
- destroyLock.unlock();
- }
- }
- }
-
- private RpcException getRpcException(Class<?> type, URL url, Invocation
invocation, Throwable e) {
- RpcException re = new RpcException("Failed to invoke remote service: "
+ type + ", method: "
- + invocation.getMethodName() + ", cause: " + e.getMessage(),
e);
- re.setCode(getErrorCode(e));
- return re;
- }
-
- /**
- * FIXME, convert gRPC exceptions to equivalent Dubbo exceptions.
- *
- * @param e
- * @return
- */
- private int getErrorCode(Throwable e) {
- if (e instanceof StatusException) {
- StatusException statusException = (StatusException) e;
- Status status = statusException.getStatus();
- if (status.getCode() == Status.Code.DEADLINE_EXCEEDED) {
- return RpcException.TIMEOUT_EXCEPTION;
- }
- }
- return RpcException.UNKNOWN_EXCEPTION;
- }
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
deleted file mode 100644
index ea8b34c964..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.threadpool.ThreadPool;
-import org.apache.dubbo.common.utils.CollectionUtils;
-import org.apache.dubbo.config.SslConfig;
-import org.apache.dubbo.config.context.ConfigManager;
-import org.apache.dubbo.rpc.model.FrameworkModel;
-import org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor;
-import org.apache.dubbo.rpc.protocol.grpc.interceptors.GrpcConfigurator;
-import org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor;
-import org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerTransportFilter;
-
-import io.grpc.CallOptions;
-import io.grpc.ManagedChannel;
-import io.grpc.ServerBuilder;
-import io.grpc.netty.GrpcSslContexts;
-import io.grpc.netty.NettyChannelBuilder;
-import io.grpc.netty.NettyServerBuilder;
-import io.netty.handler.ssl.ClientAuth;
-import io.netty.handler.ssl.SslContext;
-import io.netty.handler.ssl.SslContextBuilder;
-
-import javax.net.ssl.SSLException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
-import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
-import static
org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY;
-import static
org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_CLOSE_STREAM;
-import static org.apache.dubbo.remoting.Constants.DISPATCHER_KEY;
-import static org.apache.dubbo.rpc.Constants.EXECUTES_KEY;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.CLIENT_INTERCEPTORS;
-import static org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.EXECUTOR;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_CONCURRENT_CALLS_PER_CONNECTION;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_INBOUND_MESSAGE_SIZE;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_INBOUND_METADATA_SIZE;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.SERVER_INTERCEPTORS;
-import static
org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.TRANSPORT_FILTERS;
-
-/**
- * Support gRPC configs in a Dubbo specific way.
- */
-public class GrpcOptionsUtils {
-
- private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(GrpcOptionsUtils.class);
-
- static ServerBuilder buildServerBuilder(URL url, NettyServerBuilder
builder) {
-
- int maxInboundMessageSize = url.getParameter(MAX_INBOUND_MESSAGE_SIZE,
0);
- if (maxInboundMessageSize > 0) {
- builder.maxInboundMessageSize(maxInboundMessageSize);
- }
-
- int maxInboundMetadataSize =
url.getParameter(MAX_INBOUND_METADATA_SIZE, 0);
- if (maxInboundMetadataSize > 0) {
- builder.maxInboundMetadataSize(maxInboundMetadataSize);
- }
-
- if (url.getParameter(SSL_ENABLED_KEY, false)) {
- builder.sslContext(buildServerSslContext(url));
- }
-
- int flowControlWindow = url.getParameter(MAX_INBOUND_MESSAGE_SIZE, 0);
- if (flowControlWindow > 0) {
- builder.flowControlWindow(flowControlWindow);
- }
-
- int maxCalls = url.getParameter(MAX_CONCURRENT_CALLS_PER_CONNECTION,
url.getParameter(EXECUTES_KEY, 0));
- if (maxCalls > 0) {
- builder.maxConcurrentCallsPerConnection(maxCalls);
- }
-
- // server interceptors
- List<ServerInterceptor> serverInterceptors =
url.getOrDefaultFrameworkModel().getExtensionLoader(ServerInterceptor.class)
- .getActivateExtension(url, SERVER_INTERCEPTORS, PROVIDER_SIDE);
- for (ServerInterceptor serverInterceptor : serverInterceptors) {
- builder.intercept(serverInterceptor);
- }
-
- // server filters
- List<ServerTransportFilter> transportFilters =
url.getOrDefaultFrameworkModel().getExtensionLoader(ServerTransportFilter.class)
- .getActivateExtension(url, TRANSPORT_FILTERS, PROVIDER_SIDE);
- for (ServerTransportFilter transportFilter : transportFilters) {
- builder.addTransportFilter(transportFilter.grpcTransportFilter());
- }
-
- String thread = url.getParameter(EXECUTOR,
url.getParameter(DISPATCHER_KEY));
- if ("direct".equals(thread)) {
- builder.directExecutor();
- } else {
-
builder.executor(url.getOrDefaultFrameworkModel().getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url));
- }
-
- // Give users the chance to customize ServerBuilder
- return getConfigurator()
- .map(configurator -> configurator.configureServerBuilder(builder,
url))
- .orElse(builder);
- }
-
- static ManagedChannel buildManagedChannel(URL url) {
-
- NettyChannelBuilder builder =
NettyChannelBuilder.forAddress(url.getHost(), url.getPort());
- if (url.getParameter(SSL_ENABLED_KEY, false)) {
- builder.sslContext(buildClientSslContext(url));
- } else {
- builder.usePlaintext();
- }
-
- builder.disableRetry();
-// builder.directExecutor();
-
- // client interceptors
- List<io.grpc.ClientInterceptor> interceptors = new ArrayList<>(
-
url.getOrDefaultFrameworkModel().getExtensionLoader(ClientInterceptor.class)
- .getActivateExtension(url, CLIENT_INTERCEPTORS, CONSUMER_SIDE)
- );
-
- builder.intercept(interceptors);
-
- return getConfigurator()
- .map(configurator -> configurator.configureChannelBuilder(builder,
url))
- .orElse(builder)
- .build();
- }
-
- static CallOptions buildCallOptions(URL url) {
- // gRPC Deadline starts counting when it's created, so we need to
create and add a new Deadline for each RPC call.
-// CallOptions callOptions = CallOptions.DEFAULT
-// .withDeadline(Deadline.after(url.getParameter(TIMEOUT_KEY,
DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS));
- CallOptions callOptions = CallOptions.DEFAULT;
- return getConfigurator()
- .map(configurator ->
configurator.configureCallOptions(callOptions, url))
- .orElse(callOptions);
- }
-
- private static SslContext buildServerSslContext(URL url) {
- ConfigManager globalConfigManager =
url.getOrDefaultApplicationModel().getApplicationConfigManager();
- SslConfig sslConfig = globalConfigManager.getSsl().orElseThrow(() ->
new IllegalStateException("Ssl enabled, but no ssl cert information
provided!"));
-
- SslContextBuilder sslClientContextBuilder = null;
- InputStream serverKeyCertChainPathStream = null;
- InputStream serverPrivateKeyPathStream = null;
- InputStream trustCertCollectionFilePath = null;
- try {
- serverKeyCertChainPathStream =
sslConfig.getServerKeyCertChainPathStream();
- serverPrivateKeyPathStream =
sslConfig.getServerPrivateKeyPathStream();
- String password = sslConfig.getServerKeyPassword();
- if (password != null) {
- sslClientContextBuilder =
GrpcSslContexts.forServer(serverKeyCertChainPathStream,
- serverPrivateKeyPathStream, password);
- } else {
- sslClientContextBuilder =
GrpcSslContexts.forServer(serverKeyCertChainPathStream,
- serverPrivateKeyPathStream);
- }
-
- trustCertCollectionFilePath =
sslConfig.getServerTrustCertCollectionPathStream();
- if (trustCertCollectionFilePath != null) {
-
sslClientContextBuilder.trustManager(trustCertCollectionFilePath);
- sslClientContextBuilder.clientAuth(ClientAuth.REQUIRE);
- }
- } catch (Exception e) {
- throw new IllegalArgumentException("Could not find certificate
file or the certificate is invalid.", e);
- } finally {
- safeCloseStream(trustCertCollectionFilePath);
- safeCloseStream(serverKeyCertChainPathStream);
- safeCloseStream(serverPrivateKeyPathStream);
- }
- try {
- return sslClientContextBuilder.build();
- } catch (SSLException e) {
- throw new IllegalStateException("Build SslSession failed.", e);
- }
- }
-
- private static SslContext buildClientSslContext(URL url) {
- ConfigManager globalConfigManager =
url.getOrDefaultApplicationModel().getApplicationConfigManager();
- SslConfig sslConfig = globalConfigManager.getSsl().orElseThrow(() ->
new IllegalStateException("Ssl enabled, but no ssl cert information
provided!"));
-
-
- SslContextBuilder builder = GrpcSslContexts.forClient();
- InputStream trustCertCollectionFilePath = null;
- InputStream clientCertChainFilePath = null;
- InputStream clientPrivateKeyFilePath = null;
- try {
- trustCertCollectionFilePath =
sslConfig.getClientTrustCertCollectionPathStream();
- if (trustCertCollectionFilePath != null) {
- builder.trustManager(trustCertCollectionFilePath);
- }
- clientCertChainFilePath =
sslConfig.getClientKeyCertChainPathStream();
- clientPrivateKeyFilePath =
sslConfig.getClientPrivateKeyPathStream();
- if (clientCertChainFilePath != null && clientPrivateKeyFilePath !=
null) {
- String password = sslConfig.getClientKeyPassword();
- if (password != null) {
- builder.keyManager(clientCertChainFilePath,
clientPrivateKeyFilePath, password);
- } else {
- builder.keyManager(clientCertChainFilePath,
clientPrivateKeyFilePath);
- }
- }
- } catch (Exception e) {
- throw new IllegalArgumentException("Could not find certificate
file or find invalid certificate.", e);
- } finally {
- safeCloseStream(trustCertCollectionFilePath);
- safeCloseStream(clientCertChainFilePath);
- safeCloseStream(clientPrivateKeyFilePath);
- }
- try {
- return builder.build();
- } catch (SSLException e) {
- throw new IllegalStateException("Build SslSession failed.", e);
- }
- }
-
- private static Optional<GrpcConfigurator> getConfigurator() {
- // Give users the chance to customize ServerBuilder
- Set<GrpcConfigurator> configurators =
FrameworkModel.defaultModel().getExtensionLoader(GrpcConfigurator.class)
- .getSupportedExtensionInstances();
- if (CollectionUtils.isNotEmpty(configurators)) {
- return Optional.of(configurators.iterator().next());
- }
- return Optional.empty();
- }
-
- private static void safeCloseStream(InputStream stream) {
- if (stream == null) {
- return;
- }
- try {
- stream.close();
- } catch (IOException e) {
- logger.warn(PROTOCOL_FAILED_CLOSE_STREAM, "", "", "Failed to close
a stream.", e);
- }
- }
-}
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
deleted file mode 100644
index 1f5805a298..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.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.ConcurrentHashMapUtils;
-import org.apache.dubbo.rpc.Invoker;
-import org.apache.dubbo.rpc.ProtocolServer;
-import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.model.FrameworkServiceRepository;
-import org.apache.dubbo.rpc.model.ProviderModel;
-import org.apache.dubbo.rpc.protocol.AbstractProxyProtocol;
-
-import io.grpc.BindableService;
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ManagedChannel;
-import io.grpc.Server;
-import io.grpc.netty.NettyServerBuilder;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- *
- */
-public class GrpcProtocol extends AbstractProxyProtocol {
-
- private static final Logger logger =
LoggerFactory.getLogger(GrpcProtocol.class);
-
- public final static int DEFAULT_PORT = 50051;
-
- /* <address, gRPC channels> */
- private final ConcurrentMap<String, ReferenceCountManagedChannel>
channelMap = new ConcurrentHashMap<>();
- private final Object lock = new Object();
-
- @Override
- protected <T> Runnable doExport(T proxiedImpl, Class<T> type, URL url)
throws RpcException {
- String key = url.getAddress();
- ProtocolServer protocolServer =
ConcurrentHashMapUtils.computeIfAbsent(serverMap, key, k -> {
- DubboHandlerRegistry registry = new DubboHandlerRegistry();
-
- NettyServerBuilder builder =
- NettyServerBuilder
- .forPort(url.getPort())
- .fallbackHandlerRegistry(registry);
-
- Server originalServer = GrpcOptionsUtils.buildServerBuilder(url,
builder).build();
- GrpcRemotingServer remotingServer = new
GrpcRemotingServer(originalServer, registry);
- return new ProxyProtocolServer(remotingServer);
- });
-
- GrpcRemotingServer grpcServer = (GrpcRemotingServer)
protocolServer.getRemotingServer();
-
- FrameworkServiceRepository serviceRepository =
frameworkModel.getServiceRepository();
- ProviderModel providerModel =
serviceRepository.lookupExportedService(url.getServiceKey());
- if (providerModel == null) {
- throw new IllegalStateException("Service " + url.getServiceKey() +
"should have already been stored in service repository, " +
- "but failed to find it.");
- }
- Object originalImpl = providerModel.getServiceInstance();
-
- Class<?> implClass = originalImpl.getClass();
- try {
- Method method = implClass.getMethod("setProxiedImpl", type);
- method.invoke(originalImpl, proxiedImpl);
- } catch (Exception e) {
- throw new IllegalStateException("Failed to set dubbo proxied
service impl to stub, please make sure your stub " +
- "was generated by the dubbo-protoc-compiler.", e);
- }
- grpcServer.getRegistry().addService((BindableService) originalImpl,
url.getServiceKey());
-
- if (!grpcServer.isStarted()) {
- grpcServer.start();
- }
-
- return () ->
grpcServer.getRegistry().removeService(url.getServiceKey());
- }
-
- @Override
- protected <T> Invoker<T> protocolBindingRefer(final Class<T> type, final
URL url) throws RpcException {
- Class<?> enclosingClass = type.getEnclosingClass();
-
- if (enclosingClass == null) {
- throw new IllegalArgumentException(type.getName() + " must be
declared inside protobuf generated classes, " +
- "should be something like ServiceNameGrpc.IServiceName.");
- }
-
- final Method dubboStubMethod;
- try {
- dubboStubMethod = enclosingClass.getDeclaredMethod("getDubboStub",
Channel.class, CallOptions.class,
- URL.class);
- } catch (NoSuchMethodException e) {
- throw new IllegalArgumentException("Does not find getDubboStub in
" + enclosingClass.getName() + ", please use the customized
protoc-gen-dubbo-java to update the generated classes.");
- }
-
- // Channel
- ReferenceCountManagedChannel channel = getSharedChannel(url);
-
- // CallOptions
- try {
- @SuppressWarnings("unchecked") final T stub = (T)
dubboStubMethod.invoke(null,
- channel,
- GrpcOptionsUtils.buildCallOptions(url),
- url
- );
- final Invoker<T> target = proxyFactory.getInvoker(stub, type, url);
- GrpcInvoker<T> grpcInvoker = new GrpcInvoker<>(type, url, target,
channel);
- invokers.add(grpcInvoker);
- return grpcInvoker;
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new IllegalStateException("Could not create stub through
reflection.", e);
- }
- }
-
- /**
- * not used
- *
- * @param type
- * @param url
- * @param <T>
- * @return
- * @throws RpcException
- */
- @Override
- protected <T> T doRefer(Class<T> type, URL url) throws RpcException {
- throw new UnsupportedOperationException("not used");
- }
-
- /**
- * Get shared channel connection
- */
- private ReferenceCountManagedChannel getSharedChannel(URL url) {
- String key = url.getAddress();
- ReferenceCountManagedChannel channel = channelMap.get(key);
-
- if (channel != null && !channel.isTerminated()) {
- channel.incrementAndGetCount();
- return channel;
- }
-
- synchronized (lock) {
- channel = channelMap.get(key);
- // dubbo check
- if (channel != null && !channel.isTerminated()) {
- channel.incrementAndGetCount();
- } else {
- channel = new ReferenceCountManagedChannel(initChannel(url));
- channelMap.put(key, channel);
- }
- }
-
- return channel;
- }
-
- /**
- * Create new connection
- *
- * @param url
- */
- private ManagedChannel initChannel(URL url) {
- return GrpcOptionsUtils.buildManagedChannel(url);
- }
-
- @Override
- public int getDefaultPort() {
- return DEFAULT_PORT;
- }
-
- @Override
- public void destroy() {
- if (logger.isInfoEnabled()) {
- logger.info("Destroying protocol [" +
this.getClass().getSimpleName() + "] ...");
- }
- serverMap.values().forEach(ProtocolServer::close);
- channelMap.values().forEach(ReferenceCountManagedChannel::shutdown);
- serverMap.clear();
- channelMap.clear();
- super.destroy();
- }
-
- public class GrpcRemotingServer extends RemotingServerAdapter {
-
- private Server originalServer;
- private DubboHandlerRegistry handlerRegistry;
- private volatile boolean started;
-
- public GrpcRemotingServer(Server server, DubboHandlerRegistry
handlerRegistry) {
- this.originalServer = server;
- this.handlerRegistry = handlerRegistry;
- }
-
- public void start() throws RpcException {
- try {
- originalServer.start();
- started = true;
- } catch (IOException e) {
- throw new RpcException("Starting gRPC server failed. ", e);
- }
- }
-
- public DubboHandlerRegistry getRegistry() {
- return handlerRegistry;
- }
-
- @Override
- public Object getDelegateServer() {
- return originalServer;
- }
-
- public boolean isStarted() {
- return started;
- }
-
- @Override
- public void close() {
- originalServer.shutdown();
- }
- }
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/ReferenceCountManagedChannel.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/ReferenceCountManagedChannel.java
deleted file mode 100644
index a7b2dabca4..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/ReferenceCountManagedChannel.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-import io.grpc.CallOptions;
-import io.grpc.ClientCall;
-import io.grpc.ManagedChannel;
-import io.grpc.MethodDescriptor;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Also see ReferenceCountExchangeClient
- */
-public class ReferenceCountManagedChannel extends ManagedChannel {
-
- private final AtomicInteger referenceCount = new AtomicInteger(0);
-
- private ManagedChannel grpcChannel;
-
- public ReferenceCountManagedChannel(ManagedChannel delegated) {
- this.grpcChannel = delegated;
- }
-
- /**
- * The reference count of current ExchangeClient, connection will be
closed if all invokers destroyed.
- */
- public int incrementAndGetCount() {
- return referenceCount.incrementAndGet();
- }
-
- @Override
- public ManagedChannel shutdown() {
- if (referenceCount.decrementAndGet() <= 0) {
- return grpcChannel.shutdown();
- }
-
- return grpcChannel;
- }
-
- @Override
- public boolean isShutdown() {
- return grpcChannel.isShutdown();
- }
-
- @Override
- public boolean isTerminated() {
- return grpcChannel.isTerminated();
- }
-
- @Override
- public ManagedChannel shutdownNow() {
- // TODO
- return shutdown();
- }
-
- @Override
- public boolean awaitTermination(long timeout, TimeUnit unit) throws
InterruptedException {
- return grpcChannel.awaitTermination(timeout, unit);
- }
-
- @Override
- public <RequestT, ResponseT> ClientCall<RequestT, ResponseT>
newCall(MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions
callOptions) {
- return grpcChannel.newCall(methodDescriptor, callOptions);
- }
-
- @Override
- public String authority() {
- return grpcChannel.authority();
- }
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ClientInterceptor.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ClientInterceptor.java
deleted file mode 100644
index 33beddfbba..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ClientInterceptor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.interceptors;
-
-import org.apache.dubbo.common.extension.ExtensionScope;
-import org.apache.dubbo.common.extension.SPI;
-
-/**
- * Adapt to the standard Dubbo SPI, so that we can leverage the advantages of
Dubbo ExtensionLoader.
- */
-@SPI(scope = ExtensionScope.FRAMEWORK)
-public interface ClientInterceptor extends io.grpc.ClientInterceptor {
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/GrpcConfigurator.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/GrpcConfigurator.java
deleted file mode 100644
index dd551184f8..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/GrpcConfigurator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.interceptors;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionScope;
-import org.apache.dubbo.common.extension.SPI;
-
-import io.grpc.CallOptions;
-import io.grpc.netty.NettyChannelBuilder;
-import io.grpc.netty.NettyServerBuilder;
-
-@SPI(scope = ExtensionScope.FRAMEWORK)
-public interface GrpcConfigurator {
-
- default NettyServerBuilder configureServerBuilder(NettyServerBuilder
builder, URL url) {
- return builder;
- }
-
- default NettyChannelBuilder configureChannelBuilder(NettyChannelBuilder
builder, URL url) {
- return builder;
- }
-
- default CallOptions configureCallOptions(CallOptions options, URL url) {
- return options;
- }
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/RpcContextInterceptor.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/RpcContextInterceptor.java
deleted file mode 100644
index 2230438f92..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/RpcContextInterceptor.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.interceptors;
-
-import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.rpc.RpcContext;
-
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ForwardingClientCall;
-import io.grpc.ForwardingServerCallListener;
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
-import io.grpc.ServerCall;
-import io.grpc.ServerCallHandler;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
-import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
-import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
-
-/**
- * Hand over context information from Dubbo to gRPC.
- */
-@Activate(group = {PROVIDER, CONSUMER})
-public class RpcContextInterceptor implements ClientInterceptor,
ServerInterceptor {
-
- private static final String DUBBO = "D-";
-
- @Override
- public <ReqT, RespT> ClientCall<ReqT, RespT>
interceptCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions,
Channel next) {
- RpcContext rpcContext = RpcContext.getClientAttachment();
- Map<String, Object> attachments = new
HashMap<>(rpcContext.getObjectAttachments());
-
- return new ForwardingClientCall.SimpleForwardingClientCall<ReqT,
RespT>(next.newCall(method, callOptions)) {
- @Override
- public void start(Listener<RespT> responseListener, Metadata
headers) {
- if (!attachments.isEmpty()) {
- for (Map.Entry<String, Object> entry :
attachments.entrySet()) {
- // only used for string
- if (entry.getValue() instanceof String) {
- headers.put(Metadata.Key.of(DUBBO +
entry.getKey(), ASCII_STRING_MARSHALLER), ((String) entry.getValue()));
- }
- }
- }
- super.start(responseListener, headers);
- }
- };
- }
-
- @Override
- public <ReqT, RespT> ServerCall.Listener<ReqT>
interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
- Set<String> keys = headers.keys();
- Map<String, Object> attachments = new HashMap<>(keys.size());
- // filter out all dubbo attachments and save in map
- if (keys != null) {
- keys.stream().filter(k ->
k.toUpperCase().startsWith(DUBBO)).forEach(k ->
- attachments.put(k.substring(DUBBO.length()),
headers.get(Metadata.Key.of(k, Metadata.ASCII_STRING_MARSHALLER)))
- );
- }
-
- return new
ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(next.startCall(call,
headers)) {
- @Override
- public void onHalfClose() {
- // the client completed all message sending and server will
call the biz method if client is not the streaming
- if
(call.getMethodDescriptor().getType().clientSendsOneMessage()) {
-
RpcContext.getServerAttachment().setObjectAttachments(attachments);
- }
- super.onHalfClose();
- }
-
- @Override
- public void onMessage(ReqT message) {
- //server receive the request from client and call the biz
method if client is streaming
- if
(!call.getMethodDescriptor().getType().clientSendsOneMessage()) {
-
RpcContext.getServerAttachment().setObjectAttachments(attachments);
- }
- super.onMessage(message);
- }
- };
- }
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerTransportFilter.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerTransportFilter.java
deleted file mode 100644
index 291163f4ac..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerTransportFilter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.interceptors;
-
-import org.apache.dubbo.common.extension.ExtensionScope;
-import org.apache.dubbo.common.extension.SPI;
-
-/**
- * Adapt to the standard Dubbo SPI, so that we can leverage the advantages of
Dubbo ExtensionLoader.
- */
-@SPI(scope = ExtensionScope.FRAMEWORK)
-public interface ServerTransportFilter {
- io.grpc.ServerTransportFilter grpcTransportFilter();
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
b/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
deleted file mode 100644
index f7acbba063..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
+++ /dev/null
@@ -1 +0,0 @@
-grpc=org.apache.dubbo.rpc.protocol.grpc.GrpcProtocol
\ No newline at end of file
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor
b/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor
deleted file mode 100644
index b9576579d2..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor
+++ /dev/null
@@ -1 +0,0 @@
-context=org.apache.dubbo.rpc.protocol.grpc.interceptors.RpcContextInterceptor
\ No newline at end of file
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor
b/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor
deleted file mode 100644
index b9576579d2..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor
+++ /dev/null
@@ -1 +0,0 @@
-context=org.apache.dubbo.rpc.protocol.grpc.interceptors.RpcContextInterceptor
\ No newline at end of file
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
deleted file mode 100644
index acf9859c45..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.rpc.protocol.grpc;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.dubbo.config.ReferenceConfigBase;
-import org.apache.dubbo.rpc.Protocol;
-import org.apache.dubbo.rpc.ProxyFactory;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.apache.dubbo.rpc.model.AsyncMethodInfo;
-import org.apache.dubbo.rpc.model.ConsumerModel;
-import org.apache.dubbo.rpc.model.ModuleServiceRepository;
-import org.apache.dubbo.rpc.model.ServiceDescriptor;
-import org.apache.dubbo.rpc.model.ServiceMetadata;
-import org.apache.dubbo.rpc.protocol.grpc.support.DubboGreeterGrpc;
-import org.apache.dubbo.rpc.protocol.grpc.support.GrpcGreeterImpl;
-import org.apache.dubbo.rpc.protocol.grpc.support.HelloReply;
-import org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import io.grpc.stub.StreamObserver;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-class GrpcProtocolTest {
- private Protocol protocol =
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
- private ProxyFactory proxy =
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
-
- @Test
- void testDemoProtocol() throws Exception {
- DubboGreeterGrpc.IGreeter serviceImpl = new GrpcGreeterImpl();
-
- int availablePort = NetUtils.getAvailablePort();
-
- URL url = URL.valueOf("grpc://127.0.0.1:" + availablePort + "/" +
DubboGreeterGrpc.IGreeter.class.getName());
-
- ModuleServiceRepository serviceRepository =
ApplicationModel.defaultModel().getDefaultModule().getServiceRepository();
- ServiceDescriptor serviceDescriptor =
serviceRepository.registerService(DubboGreeterGrpc.IGreeter.class);
- serviceRepository.registerProvider(
- url.getServiceKey(),
- serviceImpl,
- serviceDescriptor,
- null,
- new ServiceMetadata()
- );
-
-
- MockReferenceConfig mockReferenceConfig = new MockReferenceConfig();
- mockReferenceConfig.setInterface(DubboGreeterGrpc.IGreeter.class);
-
- ServiceMetadata serviceMetadata = new ServiceMetadata();
-
serviceMetadata.setServiceKey(URL.buildKey(DubboGreeterGrpc.IGreeter.class.getName(),
null, null));
-
- Map<String, AsyncMethodInfo> methodConfigs = new HashMap<>();
- ConsumerModel consumerModel = new
ConsumerModel(serviceMetadata.getServiceKey(), null, serviceDescriptor,
- serviceMetadata, methodConfigs,
mockReferenceConfig.getInterfaceClassLoader());
-
-
ApplicationModel.defaultModel().getDefaultModule().getServiceRepository().registerConsumer(consumerModel);
-
- url = url.setServiceModel(consumerModel);
- protocol.export(proxy.getInvoker(serviceImpl,
DubboGreeterGrpc.IGreeter.class, url));
- serviceImpl =
proxy.getProxy(protocol.refer(DubboGreeterGrpc.IGreeter.class, url));
-
- HelloReply hello =
serviceImpl.sayHello(HelloRequest.newBuilder().setName("World").build());
- Assertions.assertEquals("Hello World", hello.getMessage());
-
- ListenableFuture<HelloReply> future =
serviceImpl.sayHelloAsync(HelloRequest.newBuilder().setName("World").build());
- Assertions.assertEquals("Hello World", future.get().getMessage());
- CountDownLatch latch = new CountDownLatch(1);
-
serviceImpl.sayHello(HelloRequest.newBuilder().setName("World").build(), new
StreamObserver<HelloReply>() {
-
- @Override
- public void onNext(HelloReply helloReply) {
- Assertions.assertEquals("Hello World",
helloReply.getMessage());
- }
-
- @Override
- public void onError(Throwable throwable) {
- throwable.printStackTrace();
- }
-
- @Override
- public void onCompleted() {
- latch.countDown();
- System.out.println("onCompleted");
- }
- });
- // release CPU to run StreamObserver methods.
- latch.await(1000, TimeUnit.MILLISECONDS);
- // resource recycle.
- serviceRepository.destroy();
- System.out.println("serviceRepository destroyed");
- }
-
- class MockReferenceConfig extends ReferenceConfigBase {
-
- @Override
- public Object get() {
- return null;
- }
-
- }
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/DubboGreeterGrpc.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/DubboGreeterGrpc.java
deleted file mode 100644
index 72a30d1ef8..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/DubboGreeterGrpc.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.support;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.config.ReferenceConfigBase;
-
-import java.util.concurrent.TimeUnit;
-
-import static io.grpc.stub.ServerCalls.asyncUnaryCall;
-import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
-import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
-import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
-import static
org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getServiceDescriptor;
-
[email protected](
- value = "by DubboGrpc generator",
- comments = "Source: helloworld.proto")
-public final class DubboGreeterGrpc {
- private DubboGreeterGrpc() {
- }
-
- public static class DubboGreeterStub implements IGreeter {
-
- protected URL url;
-
- protected GreeterGrpc.GreeterBlockingStub blockingStub;
- protected GreeterGrpc.GreeterFutureStub futureStub;
- protected GreeterGrpc.GreeterStub stub;
-
- public DubboGreeterStub(io.grpc.Channel channel, io.grpc.CallOptions
callOptions, URL url) {
- this.url = url;
-
- blockingStub = GreeterGrpc.newBlockingStub(channel).build(channel,
callOptions);
- futureStub = GreeterGrpc.newFutureStub(channel).build(channel,
callOptions);
- stub = GreeterGrpc.newStub(channel).build(channel, callOptions);
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public org.apache.dubbo.rpc.protocol.grpc.support.HelloReply sayHello(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- return blockingStub
- .withDeadlineAfter(url.getParameter(TIMEOUT_KEY,
DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS)
- .sayHello(request);
- }
-
- public
com.google.common.util.concurrent.ListenableFuture<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
sayHelloAsync(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- return futureStub
- .withDeadlineAfter(url.getParameter(TIMEOUT_KEY,
DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS)
- .sayHello(request);
- }
-
- public void
sayHello(org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request,
-
io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
responseObserver) {
- stub
- .withDeadlineAfter(url.getParameter(TIMEOUT_KEY,
DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS)
- .sayHello(request, responseObserver);
- }
-
- }
-
- public static DubboGreeterStub getDubboStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions, URL url) {
- return new DubboGreeterStub(channel, callOptions, url);
- }
-
- public interface IGreeter {
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- default public org.apache.dubbo.rpc.protocol.grpc.support.HelloReply
sayHello(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- throw new UnsupportedOperationException(
- "No need to override this method, extend XxxImplBase and
override all methods it allows.");
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- default public
com.google.common.util.concurrent.ListenableFuture<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
sayHelloAsync(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- throw new UnsupportedOperationException(
- "No need to override this method, extend XxxImplBase and
override all methods it allows.");
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public void
sayHello(org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request,
-
io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
responseObserver);
-
- }
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
- public static abstract class GreeterImplBase implements
io.grpc.BindableService, IGreeter {
-
- private IGreeter proxiedImpl;
-
- public final void setProxiedImpl(IGreeter proxiedImpl) {
- this.proxiedImpl = proxiedImpl;
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- @Override
- public final org.apache.dubbo.rpc.protocol.grpc.support.HelloReply
sayHello(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- throw new UnsupportedOperationException(
- "No need to override this method, extend XxxImplBase and
override all methods it allows.");
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- @Override
- public final
com.google.common.util.concurrent.ListenableFuture<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
sayHelloAsync(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- throw new UnsupportedOperationException(
- "No need to override this method, extend XxxImplBase and
override all methods it allows.");
- }
-
- public void
sayHello(org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request,
-
io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
responseObserver) {
-
asyncUnimplementedUnaryCall(org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getSayHelloMethod(),
responseObserver);
- }
-
- @Override
- public final io.grpc.ServerServiceDefinition bindService() {
- return
io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
- .addMethod(
-
org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getSayHelloMethod(),
- asyncUnaryCall(
- new MethodHandlers<
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>(
- proxiedImpl, METHODID_SAY_HELLO)))
- .build();
- }
- }
-
- private static final int METHODID_SAY_HELLO = 0;
-
- private static final class MethodHandlers
- <Req, Resp> implements
- io.grpc.stub.ServerCalls.UnaryMethod
- <Req, Resp>,
- io.grpc.stub.ServerCalls.ServerStreamingMethod
- <Req, Resp>,
- io.grpc.stub.ServerCalls.ClientStreamingMethod
- <Req, Resp>,
- io.grpc.stub.ServerCalls.BidiStreamingMethod
- <Req, Resp> {
- private final IGreeter serviceImpl;
- private final int methodId;
-
- MethodHandlers(IGreeter serviceImpl, int methodId) {
- this.serviceImpl = serviceImpl;
- this.methodId = methodId;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void invoke(Req request, io.grpc.stub.StreamObserver
- <Resp> responseObserver) {
- switch (methodId) {
- case METHODID_SAY_HELLO:
-
serviceImpl.sayHello((org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest)
request,
-
(io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>)
responseObserver);
- break;
- default:
- throw new AssertionError();
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver
- <Req> invoke(io.grpc.stub.StreamObserver
- <Resp> responseObserver) {
- switch (methodId) {
- default:
- throw new AssertionError();
- }
- }
- }
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GreeterGrpc.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GreeterGrpc.java
deleted file mode 100644
index 887bc31c87..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GreeterGrpc.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.support;
-
-import static io.grpc.MethodDescriptor.generateFullMethodName;
-import static io.grpc.stub.ClientCalls.asyncUnaryCall;
-import static io.grpc.stub.ClientCalls.blockingUnaryCall;
-import static io.grpc.stub.ClientCalls.futureUnaryCall;
-import static io.grpc.stub.ServerCalls.asyncUnaryCall;
-import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
-
-/**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
[email protected](
- value = "by gRPC proto compiler (version 1.34.1)",
- comments = "Source: helloworld.proto")
-public final class GreeterGrpc {
-
- private GreeterGrpc() {
- }
-
- public static final String SERVICE_NAME = "helloworld.Greeter";
-
- // Static method descriptors that strictly reflect the proto.
- private static volatile
io.grpc.MethodDescriptor<org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
- org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
getSayHelloMethod;
-
- @io.grpc.stub.annotations.RpcMethod(
- fullMethodName = SERVICE_NAME + '/' + "SayHello",
- requestType =
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest.class,
- responseType =
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply.class,
- methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
- public static
io.grpc.MethodDescriptor<org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
- org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
getSayHelloMethod() {
-
io.grpc.MethodDescriptor<org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
- getSayHelloMethod;
- if ((getSayHelloMethod =
org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getSayHelloMethod) ==
null) {
- synchronized
(org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.class) {
- if ((getSayHelloMethod =
org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getSayHelloMethod) ==
null) {
-
org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.getSayHelloMethod =
getSayHelloMethod =
-
io.grpc.MethodDescriptor.<org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>newBuilder()
- .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
-
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "SayHello"))
- .setSampledToLocalTracing(true)
-
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest.getDefaultInstance()))
-
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply.getDefaultInstance()))
- .setSchemaDescriptor(new
GreeterMethodDescriptorSupplier("SayHello"))
- .build();
- }
- }
- }
- return getSayHelloMethod;
- }
-
- /**
- * Creates a new async stub that supports all call types for the service
- */
- public static GreeterStub newStub(io.grpc.Channel channel) {
- io.grpc.stub.AbstractStub.StubFactory<GreeterStub> factory =
- new io.grpc.stub.AbstractStub.StubFactory<GreeterStub>() {
- @Override
- public GreeterStub newStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
- return new GreeterStub(channel, callOptions);
- }
- };
- return GreeterStub.newStub(factory, channel);
- }
-
- /**
- * Creates a new blocking-style stub that supports unary and streaming
output calls on the service
- */
- public static GreeterBlockingStub newBlockingStub(
- io.grpc.Channel channel) {
- io.grpc.stub.AbstractStub.StubFactory<GreeterBlockingStub> factory =
- new io.grpc.stub.AbstractStub.StubFactory<GreeterBlockingStub>() {
- @Override
- public GreeterBlockingStub newStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
- return new GreeterBlockingStub(channel, callOptions);
- }
- };
- return GreeterBlockingStub.newStub(factory, channel);
- }
-
- /**
- * Creates a new ListenableFuture-style stub that supports unary calls on
the service
- */
- public static GreeterFutureStub newFutureStub(
- io.grpc.Channel channel) {
- io.grpc.stub.AbstractStub.StubFactory<GreeterFutureStub> factory =
- new io.grpc.stub.AbstractStub.StubFactory<GreeterFutureStub>() {
- @Override
- public GreeterFutureStub newStub(io.grpc.Channel channel,
io.grpc.CallOptions callOptions) {
- return new GreeterFutureStub(channel, callOptions);
- }
- };
- return GreeterFutureStub.newStub(factory, channel);
- }
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
- public static abstract class GreeterImplBase implements
io.grpc.BindableService {
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public void
sayHello(org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request,
-
io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
responseObserver) {
- asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
- }
-
- @Override
- public final io.grpc.ServerServiceDefinition bindService() {
- return
io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
- .addMethod(
- getSayHelloMethod(),
- asyncUnaryCall(
- new MethodHandlers<
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest,
-
org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>(
- this, METHODID_SAY_HELLO)))
- .build();
- }
- }
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
- public static final class GreeterStub extends
io.grpc.stub.AbstractAsyncStub<GreeterStub> {
- private GreeterStub(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- super(channel, callOptions);
- }
-
- @Override
- protected GreeterStub build(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- return new GreeterStub(channel, callOptions);
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public void
sayHello(org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request,
-
io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
responseObserver) {
- asyncUnaryCall(
- getChannel().newCall(getSayHelloMethod(), getCallOptions()),
request, responseObserver);
- }
- }
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
- public static final class GreeterBlockingStub extends
io.grpc.stub.AbstractBlockingStub<GreeterBlockingStub> {
- private GreeterBlockingStub(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- super(channel, callOptions);
- }
-
- @Override
- protected GreeterBlockingStub build(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- return new GreeterBlockingStub(channel, callOptions);
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public org.apache.dubbo.rpc.protocol.grpc.support.HelloReply sayHello(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- return blockingUnaryCall(
- getChannel(), getSayHelloMethod(), getCallOptions(), request);
- }
- }
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
- public static final class GreeterFutureStub extends
io.grpc.stub.AbstractFutureStub<GreeterFutureStub> {
- private GreeterFutureStub(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- super(channel, callOptions);
- }
-
- @Override
- protected GreeterFutureStub build(
- io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
- return new GreeterFutureStub(channel, callOptions);
- }
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public
com.google.common.util.concurrent.ListenableFuture<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>
sayHello(
- org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest request) {
- return futureUnaryCall(
- getChannel().newCall(getSayHelloMethod(), getCallOptions()),
request);
- }
- }
-
- private static final int METHODID_SAY_HELLO = 0;
-
- private static final class MethodHandlers<Req, Resp> implements
- io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
- private final GreeterImplBase serviceImpl;
- private final int methodId;
-
- MethodHandlers(GreeterImplBase serviceImpl, int methodId) {
- this.serviceImpl = serviceImpl;
- this.methodId = methodId;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void invoke(Req request, io.grpc.stub.StreamObserver<Resp>
responseObserver) {
- switch (methodId) {
- case METHODID_SAY_HELLO:
-
serviceImpl.sayHello((org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest)
request,
-
(io.grpc.stub.StreamObserver<org.apache.dubbo.rpc.protocol.grpc.support.HelloReply>)
responseObserver);
- break;
- default:
- throw new AssertionError();
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver<Req> invoke(
- io.grpc.stub.StreamObserver<Resp> responseObserver) {
- switch (methodId) {
- default:
- throw new AssertionError();
- }
- }
- }
-
- private static abstract class GreeterBaseDescriptorSupplier
- implements io.grpc.protobuf.ProtoFileDescriptorSupplier,
io.grpc.protobuf.ProtoServiceDescriptorSupplier {
- GreeterBaseDescriptorSupplier() {
- }
-
- @Override
- public com.google.protobuf.Descriptors.FileDescriptor
getFileDescriptor() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.getDescriptor();
- }
-
- @Override
- public com.google.protobuf.Descriptors.ServiceDescriptor
getServiceDescriptor() {
- return getFileDescriptor().findServiceByName("Greeter");
- }
- }
-
- private static final class GreeterFileDescriptorSupplier
- extends GreeterBaseDescriptorSupplier {
- GreeterFileDescriptorSupplier() {
- }
- }
-
- private static final class GreeterMethodDescriptorSupplier
- extends GreeterBaseDescriptorSupplier
- implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
- private final String methodName;
-
- GreeterMethodDescriptorSupplier(String methodName) {
- this.methodName = methodName;
- }
-
- @Override
- public com.google.protobuf.Descriptors.MethodDescriptor
getMethodDescriptor() {
- return getServiceDescriptor().findMethodByName(methodName);
- }
- }
-
- private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
-
- public static io.grpc.ServiceDescriptor getServiceDescriptor() {
- io.grpc.ServiceDescriptor result = serviceDescriptor;
- if (result == null) {
- synchronized
(org.apache.dubbo.rpc.protocol.grpc.support.GreeterGrpc.class) {
- result = serviceDescriptor;
- if (result == null) {
- serviceDescriptor = result =
io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
- .setSchemaDescriptor(new
GreeterFileDescriptorSupplier())
- .addMethod(getSayHelloMethod())
- .build();
- }
- }
- }
- return result;
- }
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GrpcGreeterImpl.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GrpcGreeterImpl.java
deleted file mode 100644
index af14ca632f..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/GrpcGreeterImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.rpc.protocol.grpc.support;
-
-import io.grpc.stub.StreamObserver;
-
-public class GrpcGreeterImpl extends DubboGreeterGrpc.GreeterImplBase {
-
- @Override
- public void sayHello(HelloRequest request, StreamObserver<HelloReply>
responseObserver) {
- System.out.println("Executing thread is " +
Thread.currentThread().getName());
- HelloReply reply = HelloReply.newBuilder().setMessage("Hello " +
request.getName()).build();
- responseObserver.onNext(reply);
- responseObserver.onCompleted();
- }
-
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReply.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReply.java
deleted file mode 100644
index 8be68f6407..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReply.java
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * 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.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-
-package org.apache.dubbo.rpc.protocol.grpc.support;
-
-/**
- * <pre>
- * The response message containing the greetings
- * </pre>
- * <p>
- * Protobuf type {@code helloworld.HelloReply}
- */
-public final class HelloReply extends
- com.google.protobuf.GeneratedMessageV3 implements
- // @@protoc_insertion_point(message_implements:helloworld.HelloReply)
- HelloReplyOrBuilder {
- private static final long serialVersionUID = 0L;
-
- // Use HelloReply.newBuilder() to construct.
- private HelloReply(com.google.protobuf.GeneratedMessageV3.Builder<?>
builder) {
- super(builder);
- }
-
- private HelloReply() {
- message_ = "";
- }
-
- @Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
-
- private HelloReply(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- this();
- if (extensionRegistry == null) {
- throw new NullPointerException();
- }
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- case 10: {
- String s = input.readStringRequireUtf8();
-
- message_ = s;
- break;
- }
- default: {
- if (!parseUnknownField(
- input, unknownFields, extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e).setUnfinishedMessage(this);
- } finally {
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
-
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return
HelloWorldProto.internal_static_helloworld_HelloReply_descriptor;
- }
-
- @Override
- protected FieldAccessorTable
- internalGetFieldAccessorTable() {
- return
HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- HelloReply.class, Builder.class);
- }
-
- public static final int MESSAGE_FIELD_NUMBER = 1;
- private volatile Object message_;
-
- /**
- * <code>string message = 1;</code>
- */
- public String getMessage() {
- Object ref = message_;
- if (ref instanceof String) {
- return (String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- String s = bs.toStringUtf8();
- message_ = s;
- return s;
- }
- }
-
- /**
- * <code>string message = 1;</code>
- */
- public com.google.protobuf.ByteString
- getMessageBytes() {
- Object ref = message_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (String) ref);
- message_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- private byte memoizedIsInitialized = -1;
-
- @Override
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) {
- return true;
- }
- if (isInitialized == 0) {
- return false;
- }
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- @Override
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- if (!getMessageBytes().isEmpty()) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 1,
message_);
- }
- unknownFields.writeTo(output);
- }
-
- @Override
- public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) {
- return size;
- }
-
- size = 0;
- if (!getMessageBytes().isEmpty()) {
- size +=
com.google.protobuf.GeneratedMessageV3.computeStringSize(1, message_);
- }
- size += unknownFields.getSerializedSize();
- memoizedSize = size;
- return size;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof HelloReply)) {
- return super.equals(obj);
- }
- HelloReply other = (HelloReply) obj;
-
- if (!getMessage()
- .equals(other.getMessage())) {
- return false;
- }
- if (!unknownFields.equals(other.unknownFields)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- if (memoizedHashCode != 0) {
- return memoizedHashCode;
- }
- int hash = 41;
- hash = (19 * hash) + getDescriptor().hashCode();
- hash = (37 * hash) + MESSAGE_FIELD_NUMBER;
- hash = (53 * hash) + getMessage().hashCode();
- hash = (29 * hash) + unknownFields.hashCode();
- memoizedHashCode = hash;
- return hash;
- }
-
- public static HelloReply parseFrom(
- java.nio.ByteBuffer data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloReply parseFrom(
- java.nio.ByteBuffer data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloReply parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloReply parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloReply parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloReply parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloReply parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
-
- public static HelloReply parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static HelloReply parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input);
- }
-
- public static HelloReply parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static HelloReply parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
-
- public static HelloReply parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- @Override
- public Builder newBuilderForType() {
- return newBuilder();
- }
-
- public static Builder newBuilder() {
- return DEFAULT_INSTANCE.toBuilder();
- }
-
- public static Builder newBuilder(HelloReply prototype) {
- return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
- }
-
- @Override
- public Builder toBuilder() {
- return this == DEFAULT_INSTANCE
- ? new Builder() : new Builder().mergeFrom(this);
- }
-
- @Override
- protected Builder newBuilderForType(
- BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
-
- /**
- * <pre>
- * The response message containing the greetings
- * </pre>
- * <p>
- * Protobuf type {@code helloworld.HelloReply}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:helloworld.HelloReply)
- HelloReplyOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return
HelloWorldProto.internal_static_helloworld_HelloReply_descriptor;
- }
-
- @Override
- protected FieldAccessorTable
- internalGetFieldAccessorTable() {
- return
HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- HelloReply.class, Builder.class);
- }
-
- // Construct using org.apache.dubbo.demo.hello.HelloReply.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
-
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessageV3
- .alwaysUseFieldBuilders) {
- }
- }
-
- @Override
- public Builder clear() {
- super.clear();
- message_ = "";
-
- return this;
- }
-
- @Override
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return
HelloWorldProto.internal_static_helloworld_HelloReply_descriptor;
- }
-
- @Override
- public HelloReply getDefaultInstanceForType() {
- return HelloReply.getDefaultInstance();
- }
-
- @Override
- public HelloReply build() {
- HelloReply result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- @Override
- public HelloReply buildPartial() {
- HelloReply result = new HelloReply(this);
- result.message_ = message_;
- onBuilt();
- return result;
- }
-
- @Override
- public Builder clone() {
- return super.clone();
- }
-
- @Override
- public Builder setField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return super.setField(field, value);
- }
-
- @Override
- public Builder clearField(
- com.google.protobuf.Descriptors.FieldDescriptor field) {
- return super.clearField(field);
- }
-
- @Override
- public Builder clearOneof(
- com.google.protobuf.Descriptors.OneofDescriptor oneof) {
- return super.clearOneof(oneof);
- }
-
- @Override
- public Builder setRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- int index, Object value) {
- return super.setRepeatedField(field, index, value);
- }
-
- @Override
- public Builder addRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return super.addRepeatedField(field, value);
- }
-
- @Override
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof HelloReply) {
- return mergeFrom((HelloReply) other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(HelloReply other) {
- if (other == HelloReply.getDefaultInstance()) {
- return this;
- }
- if (!other.getMessage().isEmpty()) {
- message_ = other.message_;
- onChanged();
- }
- this.mergeUnknownFields(other.unknownFields);
- onChanged();
- return this;
- }
-
- @Override
- public final boolean isInitialized() {
- return true;
- }
-
- @Override
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- HelloReply parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input,
extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (HelloReply) e.getUnfinishedMessage();
- throw e.unwrapIOException();
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
-
- private Object message_ = "";
-
- /**
- * <code>string message = 1;</code>
- */
- public String getMessage() {
- Object ref = message_;
- if (!(ref instanceof String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- String s = bs.toStringUtf8();
- message_ = s;
- return s;
- } else {
- return (String) ref;
- }
- }
-
- /**
- * <code>string message = 1;</code>
- */
- public com.google.protobuf.ByteString
- getMessageBytes() {
- Object ref = message_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (String) ref);
- message_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- /**
- * <code>string message = 1;</code>
- */
- public Builder setMessage(
- String value) {
- if (value == null) {
- throw new NullPointerException();
- }
-
- message_ = value;
- onChanged();
- return this;
- }
-
- /**
- * <code>string message = 1;</code>
- */
- public Builder clearMessage() {
-
- message_ = getDefaultInstance().getMessage();
- onChanged();
- return this;
- }
-
- /**
- * <code>string message = 1;</code>
- */
- public Builder setMessageBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- checkByteStringIsUtf8(value);
-
- message_ = value;
- onChanged();
- return this;
- }
-
- @Override
- public final Builder setUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.setUnknownFields(unknownFields);
- }
-
- @Override
- public final Builder mergeUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.mergeUnknownFields(unknownFields);
- }
-
-
- // @@protoc_insertion_point(builder_scope:helloworld.HelloReply)
- }
-
- // @@protoc_insertion_point(class_scope:helloworld.HelloReply)
- private static final HelloReply DEFAULT_INSTANCE;
-
- static {
- DEFAULT_INSTANCE = new HelloReply();
- }
-
- public static HelloReply getDefaultInstance() {
- return DEFAULT_INSTANCE;
- }
-
- private static final com.google.protobuf.Parser<HelloReply>
- PARSER = new com.google.protobuf.AbstractParser<HelloReply>() {
- @Override
- public HelloReply parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new HelloReply(input, extensionRegistry);
- }
- };
-
- public static com.google.protobuf.Parser<HelloReply> parser() {
- return PARSER;
- }
-
- @Override
- public com.google.protobuf.Parser<HelloReply> getParserForType() {
- return PARSER;
- }
-
- @Override
- public HelloReply getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
-}
-
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReplyOrBuilder.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReplyOrBuilder.java
deleted file mode 100644
index 5100483636..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloReplyOrBuilder.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-
-package org.apache.dubbo.rpc.protocol.grpc.support;
-
-public interface HelloReplyOrBuilder extends
- // @@protoc_insertion_point(interface_extends:helloworld.HelloReply)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>string message = 1;</code>
- */
- String getMessage();
-
- /**
- * <code>string message = 1;</code>
- */
- com.google.protobuf.ByteString
- getMessageBytes();
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequest.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequest.java
deleted file mode 100644
index c97674ae14..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequest.java
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * 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.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-
-package org.apache.dubbo.rpc.protocol.grpc.support;
-
-/**
- * <pre>
- * The request message containing the user's name.
- * </pre>
- * <p>
- * Protobuf type {@code helloworld.HelloRequest}
- */
-public final class HelloRequest extends
- com.google.protobuf.GeneratedMessageV3 implements
- // @@protoc_insertion_point(message_implements:helloworld.HelloRequest)
- HelloRequestOrBuilder {
- private static final long serialVersionUID = 0L;
-
- // Use HelloRequest.newBuilder() to construct.
- private HelloRequest(com.google.protobuf.GeneratedMessageV3.Builder<?>
builder) {
- super(builder);
- }
-
- private HelloRequest() {
- name_ = "";
- }
-
- @Override
- public final com.google.protobuf.UnknownFieldSet
- getUnknownFields() {
- return this.unknownFields;
- }
-
- private HelloRequest(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- this();
- if (extensionRegistry == null) {
- throw new NullPointerException();
- }
- int mutable_bitField0_ = 0;
- com.google.protobuf.UnknownFieldSet.Builder unknownFields =
- com.google.protobuf.UnknownFieldSet.newBuilder();
- try {
- boolean done = false;
- while (!done) {
- int tag = input.readTag();
- switch (tag) {
- case 0:
- done = true;
- break;
- case 10: {
- String s = input.readStringRequireUtf8();
-
- name_ = s;
- break;
- }
- default: {
- if (!parseUnknownField(
- input, unknownFields, extensionRegistry, tag)) {
- done = true;
- }
- break;
- }
- }
- }
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- throw e.setUnfinishedMessage(this);
- } catch (java.io.IOException e) {
- throw new com.google.protobuf.InvalidProtocolBufferException(
- e).setUnfinishedMessage(this);
- } finally {
- this.unknownFields = unknownFields.build();
- makeExtensionsImmutable();
- }
- }
-
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor;
- }
-
- @Override
- protected FieldAccessorTable
- internalGetFieldAccessorTable() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- HelloRequest.class, Builder.class);
- }
-
- public static final int NAME_FIELD_NUMBER = 1;
- private volatile Object name_;
-
- /**
- * <code>string name = 1;</code>
- */
- public String getName() {
- Object ref = name_;
- if (ref instanceof String) {
- return (String) ref;
- } else {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- String s = bs.toStringUtf8();
- name_ = s;
- return s;
- }
- }
-
- /**
- * <code>string name = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNameBytes() {
- Object ref = name_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- private byte memoizedIsInitialized = -1;
-
- @Override
- public final boolean isInitialized() {
- byte isInitialized = memoizedIsInitialized;
- if (isInitialized == 1) {
- return true;
- }
- if (isInitialized == 0) {
- return false;
- }
-
- memoizedIsInitialized = 1;
- return true;
- }
-
- @Override
- public void writeTo(com.google.protobuf.CodedOutputStream output)
- throws java.io.IOException {
- if (!getNameBytes().isEmpty()) {
- com.google.protobuf.GeneratedMessageV3.writeString(output, 1,
name_);
- }
- unknownFields.writeTo(output);
- }
-
- @Override
- public int getSerializedSize() {
- int size = memoizedSize;
- if (size != -1) {
- return size;
- }
-
- size = 0;
- if (!getNameBytes().isEmpty()) {
- size +=
com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
- }
- size += unknownFields.getSerializedSize();
- memoizedSize = size;
- return size;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof HelloRequest)) {
- return super.equals(obj);
- }
- HelloRequest other = (HelloRequest) obj;
-
- if (!getName()
- .equals(other.getName())) {
- return false;
- }
- if (!unknownFields.equals(other.unknownFields)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- if (memoizedHashCode != 0) {
- return memoizedHashCode;
- }
- int hash = 41;
- hash = (19 * hash) + getDescriptor().hashCode();
- hash = (37 * hash) + NAME_FIELD_NUMBER;
- hash = (53 * hash) + getName().hashCode();
- hash = (29 * hash) + unknownFields.hashCode();
- memoizedHashCode = hash;
- return hash;
- }
-
- public static HelloRequest parseFrom(
- java.nio.ByteBuffer data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloRequest parseFrom(
- java.nio.ByteBuffer data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloRequest parseFrom(
- com.google.protobuf.ByteString data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloRequest parseFrom(
- com.google.protobuf.ByteString data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloRequest parseFrom(byte[] data)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data);
- }
-
- public static HelloRequest parseFrom(
- byte[] data,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return PARSER.parseFrom(data, extensionRegistry);
- }
-
- public static HelloRequest parseFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
-
- public static HelloRequest parseFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static HelloRequest parseDelimitedFrom(java.io.InputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input);
- }
-
- public static HelloRequest parseDelimitedFrom(
- java.io.InputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
- }
-
- public static HelloRequest parseFrom(
- com.google.protobuf.CodedInputStream input)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input);
- }
-
- public static HelloRequest parseFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- return com.google.protobuf.GeneratedMessageV3
- .parseWithIOException(PARSER, input, extensionRegistry);
- }
-
- @Override
- public Builder newBuilderForType() {
- return newBuilder();
- }
-
- public static Builder newBuilder() {
- return DEFAULT_INSTANCE.toBuilder();
- }
-
- public static Builder newBuilder(HelloRequest prototype) {
- return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
- }
-
- @Override
- public Builder toBuilder() {
- return this == DEFAULT_INSTANCE
- ? new Builder() : new Builder().mergeFrom(this);
- }
-
- @Override
- protected Builder newBuilderForType(
- BuilderParent parent) {
- Builder builder = new Builder(parent);
- return builder;
- }
-
- /**
- * <pre>
- * The request message containing the user's name.
- * </pre>
- * <p>
- * Protobuf type {@code helloworld.HelloRequest}
- */
- public static final class Builder extends
- com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
- // @@protoc_insertion_point(builder_implements:helloworld.HelloRequest)
- HelloRequestOrBuilder {
- public static final com.google.protobuf.Descriptors.Descriptor
- getDescriptor() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor;
- }
-
- @Override
- protected FieldAccessorTable
- internalGetFieldAccessorTable() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable
- .ensureFieldAccessorsInitialized(
- HelloRequest.class, Builder.class);
- }
-
- // Construct using
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest.newBuilder()
- private Builder() {
- maybeForceBuilderInitialization();
- }
-
- private Builder(
- BuilderParent parent) {
- super(parent);
- maybeForceBuilderInitialization();
- }
-
- private void maybeForceBuilderInitialization() {
- if (com.google.protobuf.GeneratedMessageV3
- .alwaysUseFieldBuilders) {
- }
- }
-
- @Override
- public Builder clear() {
- super.clear();
- name_ = "";
-
- return this;
- }
-
- @Override
- public com.google.protobuf.Descriptors.Descriptor
- getDescriptorForType() {
- return
org.apache.dubbo.rpc.protocol.grpc.support.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor;
- }
-
- @Override
- public HelloRequest getDefaultInstanceForType() {
- return HelloRequest.getDefaultInstance();
- }
-
- @Override
- public HelloRequest build() {
- HelloRequest result = buildPartial();
- if (!result.isInitialized()) {
- throw newUninitializedMessageException(result);
- }
- return result;
- }
-
- @Override
- public HelloRequest buildPartial() {
- HelloRequest result = new HelloRequest(this);
- result.name_ = name_;
- onBuilt();
- return result;
- }
-
- @Override
- public Builder clone() {
- return super.clone();
- }
-
- @Override
- public Builder setField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return super.setField(field, value);
- }
-
- @Override
- public Builder clearField(
- com.google.protobuf.Descriptors.FieldDescriptor field) {
- return super.clearField(field);
- }
-
- @Override
- public Builder clearOneof(
- com.google.protobuf.Descriptors.OneofDescriptor oneof) {
- return super.clearOneof(oneof);
- }
-
- @Override
- public Builder setRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- int index, Object value) {
- return super.setRepeatedField(field, index, value);
- }
-
- @Override
- public Builder addRepeatedField(
- com.google.protobuf.Descriptors.FieldDescriptor field,
- Object value) {
- return super.addRepeatedField(field, value);
- }
-
- @Override
- public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof HelloRequest) {
- return mergeFrom((HelloRequest) other);
- } else {
- super.mergeFrom(other);
- return this;
- }
- }
-
- public Builder mergeFrom(HelloRequest other) {
- if (other == HelloRequest.getDefaultInstance()) {
- return this;
- }
- if (!other.getName().isEmpty()) {
- name_ = other.name_;
- onChanged();
- }
- this.mergeUnknownFields(other.unknownFields);
- onChanged();
- return this;
- }
-
- @Override
- public final boolean isInitialized() {
- return true;
- }
-
- @Override
- public Builder mergeFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws java.io.IOException {
- HelloRequest parsedMessage = null;
- try {
- parsedMessage = PARSER.parsePartialFrom(input,
extensionRegistry);
- } catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (HelloRequest) e.getUnfinishedMessage();
- throw e.unwrapIOException();
- } finally {
- if (parsedMessage != null) {
- mergeFrom(parsedMessage);
- }
- }
- return this;
- }
-
- private Object name_ = "";
-
- /**
- * <code>string name = 1;</code>
- */
- public String getName() {
- Object ref = name_;
- if (!(ref instanceof String)) {
- com.google.protobuf.ByteString bs =
- (com.google.protobuf.ByteString) ref;
- String s = bs.toStringUtf8();
- name_ = s;
- return s;
- } else {
- return (String) ref;
- }
- }
-
- /**
- * <code>string name = 1;</code>
- */
- public com.google.protobuf.ByteString
- getNameBytes() {
- Object ref = name_;
- if (ref instanceof String) {
- com.google.protobuf.ByteString b =
- com.google.protobuf.ByteString.copyFromUtf8(
- (String) ref);
- name_ = b;
- return b;
- } else {
- return (com.google.protobuf.ByteString) ref;
- }
- }
-
- /**
- * <code>string name = 1;</code>
- */
- public Builder setName(
- String value) {
- if (value == null) {
- throw new NullPointerException();
- }
-
- name_ = value;
- onChanged();
- return this;
- }
-
- /**
- * <code>string name = 1;</code>
- */
- public Builder clearName() {
-
- name_ = getDefaultInstance().getName();
- onChanged();
- return this;
- }
-
- /**
- * <code>string name = 1;</code>
- */
- public Builder setNameBytes(
- com.google.protobuf.ByteString value) {
- if (value == null) {
- throw new NullPointerException();
- }
- checkByteStringIsUtf8(value);
-
- name_ = value;
- onChanged();
- return this;
- }
-
- @Override
- public final Builder setUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.setUnknownFields(unknownFields);
- }
-
- @Override
- public final Builder mergeUnknownFields(
- final com.google.protobuf.UnknownFieldSet unknownFields) {
- return super.mergeUnknownFields(unknownFields);
- }
-
-
- // @@protoc_insertion_point(builder_scope:helloworld.HelloRequest)
- }
-
- // @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
- private static final HelloRequest DEFAULT_INSTANCE;
-
- static {
- DEFAULT_INSTANCE = new HelloRequest();
- }
-
- public static HelloRequest getDefaultInstance() {
- return DEFAULT_INSTANCE;
- }
-
- private static final com.google.protobuf.Parser<HelloRequest>
- PARSER = new com.google.protobuf.AbstractParser<HelloRequest>() {
- @Override
- public HelloRequest parsePartialFrom(
- com.google.protobuf.CodedInputStream input,
- com.google.protobuf.ExtensionRegistryLite extensionRegistry)
- throws com.google.protobuf.InvalidProtocolBufferException {
- return new HelloRequest(input, extensionRegistry);
- }
- };
-
- public static com.google.protobuf.Parser<HelloRequest> parser() {
- return PARSER;
- }
-
- @Override
- public com.google.protobuf.Parser<HelloRequest> getParserForType() {
- return PARSER;
- }
-
- @Override
- public HelloRequest getDefaultInstanceForType() {
- return DEFAULT_INSTANCE;
- }
-
-}
-
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequestOrBuilder.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequestOrBuilder.java
deleted file mode 100644
index 318e674111..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloRequestOrBuilder.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-
-package org.apache.dubbo.rpc.protocol.grpc.support;
-
-public interface HelloRequestOrBuilder extends
- // @@protoc_insertion_point(interface_extends:helloworld.HelloRequest)
- com.google.protobuf.MessageOrBuilder {
-
- /**
- * <code>string name = 1;</code>
- */
- String getName();
-
- /**
- * <code>string name = 1;</code>
- */
- com.google.protobuf.ByteString
- getNameBytes();
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloWorldProto.java
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloWorldProto.java
deleted file mode 100644
index 6254ebb5b9..0000000000
---
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/support/HelloWorldProto.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.
- */
-
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-
-package org.apache.dubbo.rpc.protocol.grpc.support;
-
-public final class HelloWorldProto {
- private HelloWorldProto() {
- }
-
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistryLite registry) {
- }
-
- public static void registerAllExtensions(
- com.google.protobuf.ExtensionRegistry registry) {
- registerAllExtensions(
- (com.google.protobuf.ExtensionRegistryLite) registry);
- }
-
- static final com.google.protobuf.Descriptors.Descriptor
- internal_static_helloworld_HelloRequest_descriptor;
- static final
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internal_static_helloworld_HelloRequest_fieldAccessorTable;
- static final com.google.protobuf.Descriptors.Descriptor
- internal_static_helloworld_HelloReply_descriptor;
- static final
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
- internal_static_helloworld_HelloReply_fieldAccessorTable;
-
- public static com.google.protobuf.Descriptors.FileDescriptor
- getDescriptor() {
- return descriptor;
- }
-
- private static com.google.protobuf.Descriptors.FileDescriptor
- descriptor;
-
- static {
- String[] descriptorData = {
- "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" +
- "equest\022\014\n\004name\030\001
\001(\t\"\035\n\nHelloReply\022\017\n\007me" +
- "ssage\030\001 \001(\tB6\n\033org.apache.dubbo.demo.hel" +
- "loB\017HelloWorldProtoP\001\242\002\003HLWb\006proto3"
- };
-
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner
assigner =
- new
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
- public com.google.protobuf.ExtensionRegistry assignDescriptors(
- com.google.protobuf.Descriptors.FileDescriptor root) {
- descriptor = root;
- return null;
- }
- };
- com.google.protobuf.Descriptors.FileDescriptor
- .internalBuildGeneratedFileFrom(descriptorData,
- new com.google.protobuf.Descriptors.FileDescriptor[] {
- }, assigner);
- internal_static_helloworld_HelloRequest_descriptor =
- getDescriptor().getMessageTypes().get(0);
- internal_static_helloworld_HelloRequest_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
- internal_static_helloworld_HelloRequest_descriptor,
- new String[] {"Name",});
- internal_static_helloworld_HelloReply_descriptor =
- getDescriptor().getMessageTypes().get(1);
- internal_static_helloworld_HelloReply_fieldAccessorTable = new
- com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
- internal_static_helloworld_HelloReply_descriptor,
- new String[] {"Message",});
- }
-
- // @@protoc_insertion_point(outer_class_scope)
-}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConfig.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcHttp2Protocol.java
similarity index 82%
rename from
dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConfig.java
rename to
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcHttp2Protocol.java
index 08b2f6a7b2..1b00e5ff09 100644
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcConfig.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcHttp2Protocol.java
@@ -14,8 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.rpc.protocol.grpc;
-public class GrpcConfig {
+package org.apache.dubbo.rpc.protocol.tri;
+import org.apache.dubbo.common.extension.Activate;
+
+@Activate
+public class GrpcHttp2Protocol extends TripleHttp2Protocol {
}
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerInterceptor.java
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcProtocol.java
similarity index 68%
rename from
dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerInterceptor.java
rename to
dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcProtocol.java
index f657d23e8c..38519e4c42 100644
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/interceptors/ServerInterceptor.java
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/GrpcProtocol.java
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.rpc.protocol.grpc.interceptors;
-import org.apache.dubbo.common.extension.ExtensionScope;
-import org.apache.dubbo.common.extension.SPI;
+package org.apache.dubbo.rpc.protocol.tri;
-/**
- * Adapt to the standard Dubbo SPI, so that we can leverage the advantages of
Dubbo ExtensionLoader.
- */
-@SPI(scope = ExtensionScope.FRAMEWORK)
-public interface ServerInterceptor extends io.grpc.ServerInterceptor {
+import org.apache.dubbo.rpc.model.FrameworkModel;
+
+public class GrpcProtocol extends TripleProtocol {
+
+ public GrpcProtocol(FrameworkModel frameworkModel) {
+ super(frameworkModel);
+ }
}
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.api.WireProtocol
b/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.api.WireProtocol
index 2280d84378..ba8d12687b 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.api.WireProtocol
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.remoting.api.WireProtocol
@@ -1 +1,2 @@
-tri=org.apache.dubbo.rpc.protocol.tri.TripleHttp2Protocol
\ No newline at end of file
+tri=org.apache.dubbo.rpc.protocol.tri.TripleHttp2Protocol
+grpc=org.apache.dubbo.rpc.protocol.tri.GrpcHttp2Protocol
\ No newline at end of file
diff --git
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
b/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
index cdcb95fa7c..3cb3ffb116 100644
---
a/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
+++
b/dubbo-rpc/dubbo-rpc-triple/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
@@ -1 +1,2 @@
-tri=org.apache.dubbo.rpc.protocol.tri.TripleProtocol
\ No newline at end of file
+tri=org.apache.dubbo.rpc.protocol.tri.TripleProtocol
+grpc=org.apache.dubbo.rpc.protocol.tri.GrpcProtocol
\ No newline at end of file
diff --git a/dubbo-rpc/pom.xml b/dubbo-rpc/pom.xml
index 091f8e9a7a..752b6c560c 100644
--- a/dubbo-rpc/pom.xml
+++ b/dubbo-rpc/pom.xml
@@ -34,7 +34,6 @@
<module>dubbo-rpc-dubbo</module>
<module>dubbo-rpc-injvm</module>
<module>dubbo-rpc-rest</module>
- <module>dubbo-rpc-grpc</module>
<module>dubbo-rpc-triple</module>
</modules>
diff --git a/dubbo-test/dubbo-dependencies-all/pom.xml
b/dubbo-test/dubbo-dependencies-all/pom.xml
index 9e45c239a7..f97e0a6945 100644
--- a/dubbo-test/dubbo-dependencies-all/pom.xml
+++ b/dubbo-test/dubbo-dependencies-all/pom.xml
@@ -258,10 +258,7 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rest</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-grpc</artifactId>
- </dependency>
+
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-triple</artifactId>