Skip to content

Commit

Permalink
update document and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GentleWang1011 committed Nov 10, 2021
1 parent fac81fd commit 3998680
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 37 deletions.
39 changes: 18 additions & 21 deletions document/docs/config/proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,45 +125,43 @@
```yaml
{
"route_table": {
"default": {
"default": { // 使用此处的default配置就能向对方发送请求,能满足大部分需求。
"default": [
// 此处用于配置serving-proxy默认对外转发地址,
// 切记不能配置成serving-proxy自己的ip端口,会形成回环
{
"ip": "127.0.0.1",
"port": 9999
{ // 此处用于配置serving-proxy默认对外转发地址, 切记不能配置成serving-proxy自己的ip端口,会形成回环
"ip": "192.168.1.1",
"port": 8869
}
]
},
// 向对方发送请求使用上面的default配置就能满足大部分需求。
// 以下是路由中己方部分说明:

// 以下是路由中己方部分的配置说明:
(提示:如果使用zk的话,己方的配置其实是可以省略的,因为路由信息在服务启动的时候全注册到zk了,系统会在zk上拿到想要的信息;
如果部署时候选择的是无zk方案,那么下面的配置不能缺少)

//己方的serving-proxy 在收到grpc unaryCall接口的请求后,会根据请求中的目的partyId尝试匹配。
比如请求中目的partId为10000,则会在路由表中查找是否存在10000的配置
//此处的10000表示目的partId 为10000时的路由,匹配到10000之后,再根据请求中的角色信息role。
比如请求中role 为serving则会继续匹配下面是否有serving的配置
比如请求中目的partId为10000,则会在路由表中查找是否存在10000的配置
//此处的10000表示目的partId 为10000时的路由,匹配到10000之后再根据请求中的角色信息role,
比如请求role为serving,则会继续往下面匹配serving的配置
"10000": {
// 在未找到对应role的路由地址时,会使用default的配置
"default": [
"default": [ //可以给出一个默认值, 在未找到对应role的路由地址时,会使用default的配置
{
"ip": "127.0.0.1",
"port": 8889
"port": 8879
}
],
"serving": [
// 当已经匹配到role为serving,则代表请求为发给serving-server的请求,这时检查是否启用了ZK为注册中心,
如果已启用ZK则优先从ZK中获取目标地址,未找到时使用以下地址
// 当匹配到role为serving,则代表请求为发给serving-server的请求,这时检查是否启用了ZK为注册中心,
如果启用ZK则优先从ZK中获取目标地址,未找到时使用以下地址

{ // 此处配置己端对应serving服务地址列表,ip和port对应serving-server所启动的grpc服务地址
"ip": "127.0.0.1",
"port": 8080
"port": 8000
}
]
}
},
// 此处配置当前路由表规则开启/关闭
"permission": {
"default_allow": true
"default_allow": true // 此处配置当前路由表规则开启/关闭
}
}
```
Expand All @@ -181,9 +179,8 @@
},
......
},
// 此处配置当前路由表规则开启/关闭
"permission": {
"default_allow": true
"default_allow": true // 此处配置当前路由表规则开启/关闭
}
}

Expand Down
4 changes: 2 additions & 2 deletions document/docs/config/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
</tr>
<tr>
<td>proxy</td>
<td>离线路由proxy地址,建议通过zookeeper来获取地址,不建议直接配置</td>
<td>127.0.0.1:8000</td>
<td>proxy服务的地址,建议通过启用zookeeper自动获取地址,当不启用zk时需要直接在此处配置</td>
<td>127.0.0.1:8879</td>
</tr>
<tr>
<td>zk.url</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -40,16 +39,15 @@
import java.util.*;

@Component
public class FateFlowModelLoader extends AbstractModelLoader<Map<String, byte[]>> implements InitializingBean {
public class FateFlowModelLoader extends AbstractModelLoader<Map<String, byte[]>> {
private static final Logger logger = LoggerFactory.getLogger(FateFlowModelLoader.class);
private static final String TRANSFER_URI = "flow/online/transfer";

@Autowired(required = false)
private RouterService routerService;


@Autowired
ZookeeperRegistry zookeeperRegistry;
@Autowired(required = false)
private ZookeeperRegistry zookeeperRegistry;

@Override
protected byte[] serialize(Context context, Map<String, byte[]> data) {
Expand Down Expand Up @@ -140,7 +138,7 @@ public String getResource(Context context,ModelLoaderParam modelLoaderParam) {
String filePath = modelLoaderParam.getFilePath();
if (StringUtils.isNotBlank(filePath)) {
requestUrl = URLDecoder.decode(filePath,"UTF-8");
} else if (routerService != null) {
} else if (routerService != null && zookeeperRegistry != null) {
//serving 2.1.0兼容
String modelParentPathx = "/" + Dict.DEFAULT_FATE_ROOT + "/" + TRANSFER_URI + "/providers";
List<String> children = zookeeperRegistry.getZkClient().getChildren(modelParentPathx);
Expand Down Expand Up @@ -186,11 +184,4 @@ public String getResource(Context context,ModelLoaderParam modelLoaderParam) {
return requestUrl;
}

@Override
public void afterPropertiesSet() throws Exception {
String modelParentPathx = "/" + Dict.DEFAULT_FATE_ROOT + "/" + TRANSFER_URI + "/providers";
String modelParentPath = "/";
List<String> children = zookeeperRegistry.getZkClient().getChildren(modelParentPathx);
// logger.info("children = {}", children);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ port=8000
#redis.maxTotal=100
#redis.maxIdle=100
# external subsystem
#proxy=127.0.0.1:8000
#proxy=127.0.0.1:8879
# adapter
feature.single.adaptor=com.webank.ai.fate.serving.adaptor.dataaccess.MockAdapter
feature.batch.adaptor=com.webank.ai.fate.serving.adaptor.dataaccess.MockBatchAdapter
Expand Down

0 comments on commit 3998680

Please sign in to comment.