From f455e30f4581d35741c0a9c2d491c0f63aef2e19 Mon Sep 17 00:00:00 2001 From: kaideng Date: Thu, 10 Jun 2021 16:59:13 +0800 Subject: [PATCH 1/3] add ssl --- .../proxy/rpc/services/InferenceService.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java b/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java index c0ede0477..452b422aa 100644 --- a/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java +++ b/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java @@ -25,10 +25,7 @@ import com.webank.ai.fate.serving.common.rpc.core.FateService; import com.webank.ai.fate.serving.common.rpc.core.InboundPackage; import com.webank.ai.fate.serving.common.rpc.core.OutboundPackage; -import com.webank.ai.fate.serving.core.bean.Context; -import com.webank.ai.fate.serving.core.bean.Dict; -import com.webank.ai.fate.serving.core.bean.GrpcConnectionPool; -import com.webank.ai.fate.serving.core.bean.MetaInfo; +import com.webank.ai.fate.serving.core.bean.*; import com.webank.ai.fate.serving.core.exceptions.RemoteRpcException; import com.webank.ai.fate.serving.core.rpc.router.RouterInfo; import com.webank.ai.fate.serving.core.utils.JsonUtil; @@ -66,7 +63,16 @@ public Map doService(Context context, InboundPackage data, OutboundPackage< String resultString = null; ListenableFuture resultFuture; try { - managedChannel = this.grpcConnectionPool.getManagedChannel(routerInfo.getHost(), routerInfo.getPort()); + NettyServerInfo nettyServerInfo = null; + if (routerInfo.isUseSSL()) { + nettyServerInfo = new NettyServerInfo(MetaInfo.PROPERTY_PROXY_GRPC_INTER_NEGOTIATIONTYPE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CLIENT_CERTCHAIN_FILE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CLIENT_PRIVATEKEY_FILE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CA_FILE); + } else { + nettyServerInfo = new NettyServerInfo(); + } + managedChannel = this.grpcConnectionPool.getManagedChannel(routerInfo.getHost(), routerInfo.getPort(),nettyServerInfo); } catch (Exception e) { logger.error("get grpc channel error", e); throw new RemoteRpcException("remote rpc exception"); From cb8d79e54b0f8daea36a770b9549c2d165d94515 Mon Sep 17 00:00:00 2001 From: kaideng Date: Sat, 26 Jun 2021 22:12:09 +0800 Subject: [PATCH 2/3] fix something about grpc cert --- .../serving/core/bean/GrpcConnectionPool.java | 16 +++++++++++++++- .../proxy/rpc/services/InferenceService.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/bean/GrpcConnectionPool.java b/fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/bean/GrpcConnectionPool.java index 3b7741d24..4d66db4c3 100644 --- a/fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/bean/GrpcConnectionPool.java +++ b/fate-serving-core/src/main/java/com/webank/ai/fate/serving/core/bean/GrpcConnectionPool.java @@ -18,6 +18,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.webank.ai.fate.serving.core.rpc.router.RouterInfo; import io.grpc.ConnectivityState; import io.grpc.ManagedChannel; import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts; @@ -130,6 +131,20 @@ private boolean needAddChannel(ChannelResource channelResource) { } } + public ManagedChannel getManagedChannel(RouterInfo routerInfo){ + NettyServerInfo nettyServerInfo = null; + if (routerInfo.isUseSSL()) { + nettyServerInfo = new NettyServerInfo(MetaInfo.PROPERTY_PROXY_GRPC_INTER_NEGOTIATIONTYPE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CLIENT_CERTCHAIN_FILE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CLIENT_PRIVATEKEY_FILE, + MetaInfo.PROPERTY_PROXY_GRPC_INTER_CA_FILE); + } else { + nettyServerInfo = new NettyServerInfo(); + } + String key = new StringBuilder().append(routerInfo.getHost()).append(":").append(routerInfo.getPort()).toString(); + return getAManagedChannel(key,nettyServerInfo); + } + public ManagedChannel getManagedChannel(String key) { return getAManagedChannel(key, new NettyServerInfo()); } @@ -223,7 +238,6 @@ public synchronized ManagedChannel createManagedChannel(String ip, int port, Net } catch (Exception e) { logger.error("create channel error : " ,e); - //e.printStackTrace(); } return null; } diff --git a/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java b/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java index c0ede0477..0ee75bf01 100644 --- a/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java +++ b/fate-serving-proxy/src/main/java/com/webank/ai/fate/serving/proxy/rpc/services/InferenceService.java @@ -66,7 +66,7 @@ public Map doService(Context context, InboundPackage data, OutboundPackage< String resultString = null; ListenableFuture resultFuture; try { - managedChannel = this.grpcConnectionPool.getManagedChannel(routerInfo.getHost(), routerInfo.getPort()); + managedChannel = this.grpcConnectionPool.getManagedChannel(routerInfo); } catch (Exception e) { logger.error("get grpc channel error", e); throw new RemoteRpcException("remote rpc exception"); From 5fbd2db09fd0d8fb93f99dd761eb51752ae07456 Mon Sep 17 00:00:00 2001 From: kaideng Date: Sun, 27 Jun 2021 01:02:01 +0800 Subject: [PATCH 3/3] 2.0.5 --- fate-serving-admin-ui/pom.xml | 2 +- fate-serving-admin/bin/service.sh | 2 +- fate-serving-admin/pom.xml | 10 +++++----- fate-serving-common/pom.xml | 4 ++-- fate-serving-core/pom.xml | 2 +- .../fate/serving/core/bean/GrpcConnectionPool.java | 6 ++---- .../ai/fate/serving/core/bean/NettyServerInfo.java | 5 +++++ fate-serving-extension/pom.xml | 6 +++--- fate-serving-federatedml/pom.xml | 8 ++++---- fate-serving-proxy/bin/service.sh | 2 +- fate-serving-proxy/pom.xml | 4 ++-- .../serving/proxy/rpc/services/UnaryCallService.java | 12 +----------- fate-serving-register/pom.xml | 2 +- fate-serving-sdk/pom.xml | 6 +++--- fate-serving-server/bin/service.sh | 2 +- fate-serving-server/pom.xml | 10 +++++----- pom.xml | 4 ++-- 17 files changed, 40 insertions(+), 47 deletions(-) diff --git a/fate-serving-admin-ui/pom.xml b/fate-serving-admin-ui/pom.xml index 7ecc33c6e..e9af37507 100644 --- a/fate-serving-admin-ui/pom.xml +++ b/fate-serving-admin-ui/pom.xml @@ -21,7 +21,7 @@ fate-serving com.webank.ai.fate - 2.0.4 + 2.0.5 4.0.0 diff --git a/fate-serving-admin/bin/service.sh b/fate-serving-admin/bin/service.sh index db3b3cba0..62c96f9d2 100644 --- a/fate-serving-admin/bin/service.sh +++ b/fate-serving-admin/bin/service.sh @@ -24,7 +24,7 @@ basepath=$(cd `dirname $0`;pwd) configpath=$(cd $basepath/conf;pwd) module=serving-admin main_class=com.webank.ai.fate.serving.admin.Bootstrap -module_version=2.0.4 +module_version=2.0.5 case "$1" in start) diff --git a/fate-serving-admin/pom.xml b/fate-serving-admin/pom.xml index fc9d5460d..c6f0a48b6 100755 --- a/fate-serving-admin/pom.xml +++ b/fate-serving-admin/pom.xml @@ -20,7 +20,7 @@ fate-serving com.webank.ai.fate - 2.0.4 + 2.0.5 fate-serving-admin @@ -36,19 +36,19 @@ com.webank.ai.fate fate-serving-core - 2.0.4 + 2.0.5 com.webank.ai.fate fate-serving-register - 2.0.4 + 2.0.5 com.webank.ai.fate fate-serving-admin-ui - 2.0.4 + 2.0.5