Sfoglia il codice sorgente

dashboard: Fix NoNodeException problem of FlowRuleZookeeperProvider example (#1352)

master
WongTheo GitHub 4 anni fa
parent
commit
8f0cb2d24a
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. +5
    -0
      sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java

+ 5
- 0
sentinel-dashboard/src/test/java/com/alibaba/csp/sentinel/dashboard/rule/zookeeper/FlowRuleZookeeperProvider.java Vedi File

@@ -19,6 +19,7 @@ import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity;
import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider;
import com.alibaba.csp.sentinel.datasource.Converter;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.data.Stat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@@ -36,6 +37,10 @@ public class FlowRuleZookeeperProvider implements DynamicRuleProvider<List<FlowR
@Override
public List<FlowRuleEntity> getRules(String appName) throws Exception {
String zkPath = ZookeeperConfigUtil.getPath(appName);
Stat stat = zkClient.checkExists().forPath(zkPath);
if(stat == null){
return new ArrayList<>(0);
}
byte[] bytes = zkClient.getData().forPath(zkPath);
if (null == bytes || bytes.length == 0) {
return new ArrayList<>();


Loading…
Annulla
Salva