You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/09/06 13:33:01 UTC
[dubbo] 03/04: grpc protocol
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit 50f8a5127bb1eaf08c1c5f9ce7a102898027a55b
Author: ken.lj <ke...@gmail.com>
AuthorDate: Fri Sep 6 21:32:33 2019 +0800
grpc protocol
---
.../dubbo/rpc/protocol/grpc/GrpcProtocol.java | 25 ++++++----------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
index 5d78cf9..73fd804 100644
--- a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
+++ b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocol.java
@@ -54,15 +54,7 @@ public class GrpcProtocol extends AbstractProxyProtocol {
private final Map<String, ManagedChannel> channelMap = new ConcurrentHashMap<>();
- /**
- * 传进来的impl implements DubboInterface, DubboInterface包含特定的3个通用方法就可以了
- * @param impl
- * @param type
- * @param url
- * @param <T>
- * @return
- * @throws RpcException
- */
+
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String key = url.getAddress();
@@ -86,14 +78,6 @@ public class GrpcProtocol extends AbstractProxyProtocol {
return super.export(new GrpcInvoker<>(invoker));
}
- /**
- * 这里返回的impl必须要有所有的方法, Stub BlockingStube FutureStub
- * @param type
- * @param url
- * @param <T>
- * @return
- * @throws RpcException
- */
@Override
protected <T> T doRefer(Class<T> type, URL url) throws RpcException {
Class<?> enclosingClass = type.getEnclosingClass();
@@ -130,7 +114,8 @@ public class GrpcProtocol extends AbstractProxyProtocol {
@Override
public void destroy() {
- // FIXME
+ serverMap.values().forEach(GrpcServer::stop);
+ channelMap.values().forEach(ManagedChannel::shutdown);
}
private class GrpcServer {
@@ -154,6 +139,10 @@ public class GrpcProtocol extends AbstractProxyProtocol {
public DubboHandlerRegistry getRegistry() {
return registry;
}
+
+ public void stop() {
+ this.server.shutdown();
+ }
}
private class GrpcInvoker<T> implements Invoker<T> {