sentinel 集群流控token-server 列表不显示链接状态

brtdzjyr  于 4个月前  发布在  其他
关注(0)|答案(3)|浏览(247)

sentinel-dashboard version: 1.8.1
sentinel-cluster-server-default version: 1.8.1
sentinel-cluster-client-default version: 1.8.1

1: 已经实现配置规则持久到apollo

2:以独立模式部署的token-server,代码如下:

`/**

  • @description: Server namespace set (scope) data source.
  • @author: zhou shuai
  • @param tokenServerNameSpace
  • @Date: 2022/10/25 14:40
    */
    private void initTokenServerNameSpaces(String tokenServerNameSpace) {
    ReadableDataSource<String, Set> namespaceDs = new ApolloDataSource<>(tokenServerNameSpace,
    ApolloConfigUtil.getTokenServerNamespaceSetKey(), defaultRules, source -> JSON.parseObject(source,
    new TypeReference() {
    }));
    log.info("namespaceDs : {}", namespaceDs.getProperty());
    ClusterServerConfigManager.registerNamespaceSetProperty(namespaceDs.getProperty());
    }
/**
 * @description: Server transport configuration data source.
 * @author: zhou shuai
 * @param tokenServerNameSpace
 * @date: 2022/10/25 14:39
 */
private void initServerTransportConfig(String tokenServerNameSpace) {
    ReadableDataSource<String, ServerTransportConfig> serverTransportDs = new ApolloDataSource<>(tokenServerNameSpace,
            ApolloConfigUtil.getTokenServerRuleKey(), defaultRules,
            new TokenServerTransportConfigParser());
    ClusterServerConfigManager.registerServerTransportProperty(serverTransportDs.getProperty());
}

/**
 * @description: 初始化最大qps
 * @author: zhou shuai
 * @param tokenServerNameSpace
 * @date: 2022/10/25 14:40
 */
private void initServerFlowConfig(String tokenServerNameSpace) {
    ClusterServerFlowConfigParser serverFlowConfigParser = new ClusterServerFlowConfigParser();
    ReadableDataSource<String, ServerFlowConfig> serverFlowConfigDs = new ApolloDataSource<>(tokenServerNameSpace,
            ApolloConfigUtil.getTokenServerRuleKey(), defaultRules, s -> {
        ServerFlowConfig config = serverFlowConfigParser.convert(s);
        if (config != null) {
            ClusterServerConfigManager.loadGlobalFlowConfig(config);
        }
        return config;
    });
}

/**
 * 设置为 token server
 */
private void initStateProperty() {
    ClusterStateManager.applyState(ClusterStateManager.CLUSTER_SERVER);
}`

3:apollo相关配置

4:sentinel client 配置
/**

  • 客户端请求超时配置; 默认超时时间20ms
    */
    private void initClientConfigProperty(String tokenServerNameSpace) {
    ReadableDataSource<String, ClusterClientConfig> clientConfigDs = new ApolloDataSource<>(tokenServerNameSpace,
    ApolloConfigUtil.getClusterClientConfig(), defaultRules,
    source -> JSON.parseObject(source, new TypeReference() {
    }));
    ClusterClientConfigManager.registerClientConfigProperty(clientConfigDs.getProperty());
    }
/**
 * 设置 token client 需要链接的token server 的地址
 */
public void initClientServerAssignProperty(String tokenServerNameSpace) {
    ReadableDataSource<String, ClusterClientAssignConfig> clientAssignDs = new ApolloDataSource<>(tokenServerNameSpace,
            ApolloConfigUtil.getTokenServerRuleKey(), defaultRules, new ClusterAssignConfigParser());
    ClusterClientConfigManager.registerServerAssignProperty(clientAssignDs.getProperty());
}

/**
 * 设置业务端状态为集群限流客户端
 */
private void initStateProperty() {
    ClusterStateManager.applyState(ClusterStateManager.CLUSTER_CLIENT);
}

5:我在本地是多实例启动order-server服务,启动参数
-Dcsp.sentinel.log.use.pid=true
-Dserver.port=8763

6:我在order-server集群流控页面添加token-server列表,但是token-server不显示链接状态

7:后来我发现在token-server这个应用下显示了,但是显示的是嵌入模式。但是我想在order-server显示token-server的链接状态。方便问一下是什么原因嘛?还是说独立模式启动就是这样的机制。

nzrxty8p

nzrxty8p1#

有人能回答一下嘛?排查很久没查不出来原因是什么

jvlzgdj9

jvlzgdj92#

@sczyh30 大佬,我能问一下,独立模式运行的token-server,sentinel client链接上token-server了,为什么在token server列表不显示链接状态呢?

cgh8pdjw

cgh8pdjw3#

我也遇到了类似的问题,解决了没?

相关问题