bug #I668R2 zk,etcd中必须配置chain和script2个节点,只配置其中chain会报错
This commit is contained in:
parent
039182cfe5
commit
dba43fcfa9
|
@ -135,12 +135,8 @@ public class ApolloParseHelper {
|
|||
}
|
||||
}));
|
||||
|
||||
// script
|
||||
if (Objects.isNull(scriptConfig)) {
|
||||
// no script config
|
||||
return;
|
||||
}
|
||||
scriptConfig.addChangeListener(changeEvent ->
|
||||
if (StrUtil.isNotBlank(apolloParserConfigVO.getScriptNamespace())){
|
||||
scriptConfig.addChangeListener(changeEvent ->
|
||||
changeEvent.changedKeys().forEach(changeKey -> {
|
||||
ConfigChange configChange = changeEvent.getChange(changeKey);
|
||||
String newValue = configChange.getNewValue();
|
||||
|
@ -165,11 +161,11 @@ public class ApolloParseHelper {
|
|||
nodeSimpleVO = convert(changeKey, null);
|
||||
FlowBus.getNodeMap().remove(nodeSimpleVO.getNodeId());
|
||||
}
|
||||
}));
|
||||
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private NodeSimpleVO convert(String key, String value) {
|
||||
//不需要去理解这串正则,就是一个匹配冒号的
|
||||
//一定得是a:b,或是a:b:c...这种完整类型的字符串的
|
||||
|
|
|
@ -153,23 +153,26 @@ public class EtcdParserHelper {
|
|||
FlowBus.removeChain(chainName);
|
||||
}
|
||||
);
|
||||
this.client.watchChildChange(this.etcdParserVO.getScriptPath(),
|
||||
(updatePath, updateValue) -> {
|
||||
LOG.info("starting reload flow config... update path={} value={}", updatePath, updateValue);
|
||||
String scriptNodeValue = FileNameUtil.getName(updatePath);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
LiteFlowNodeBuilder.createScriptNode().setId(nodeSimpleVO.getNodeId())
|
||||
.setType(NodeTypeEnum.getEnumByCode(nodeSimpleVO.type))
|
||||
.setName(nodeSimpleVO.getName())
|
||||
.setScript(updateValue).build();
|
||||
},
|
||||
(deletePath) -> {
|
||||
LOG.info("starting reload flow config... delete path={}", deletePath);
|
||||
String scriptNodeValue = FileNameUtil.getName(deletePath);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
FlowBus.getNodeMap().remove(nodeSimpleVO.getNodeId());
|
||||
}
|
||||
);
|
||||
|
||||
if (StrUtil.isNotBlank(this.etcdParserVO.getScriptPath())){
|
||||
this.client.watchChildChange(this.etcdParserVO.getScriptPath(),
|
||||
(updatePath, updateValue) -> {
|
||||
LOG.info("starting reload flow config... update path={} value={}", updatePath, updateValue);
|
||||
String scriptNodeValue = FileNameUtil.getName(updatePath);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
LiteFlowNodeBuilder.createScriptNode().setId(nodeSimpleVO.getNodeId())
|
||||
.setType(NodeTypeEnum.getEnumByCode(nodeSimpleVO.type))
|
||||
.setName(nodeSimpleVO.getName())
|
||||
.setScript(updateValue).build();
|
||||
},
|
||||
(deletePath) -> {
|
||||
LOG.info("starting reload flow config... delete path={}", deletePath);
|
||||
String scriptNodeValue = FileNameUtil.getName(deletePath);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
FlowBus.getNodeMap().remove(nodeSimpleVO.getNodeId());
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public NodeSimpleVO convert(String str){
|
||||
|
|
|
@ -153,30 +153,32 @@ public class ZkParserHelper {
|
|||
}
|
||||
});
|
||||
|
||||
//监听script
|
||||
CuratorCache cache2 = CuratorCache.build(client, zkParserVO.getScriptPath());
|
||||
cache2.start();
|
||||
cache2.listenable().addListener((type, oldData, data) -> {
|
||||
String path = data.getPath();
|
||||
String value = new String(data.getData());
|
||||
if (StrUtil.isBlank(value)){
|
||||
return;
|
||||
}
|
||||
if (ListUtil.toList(CuratorCacheListener.Type.NODE_CREATED, CuratorCacheListener.Type.NODE_CHANGED).contains(type)){
|
||||
LOG.info("starting reload flow config... {} path={} value={},", type.name(), path, value);
|
||||
String scriptNodeValue = FileNameUtil.getName(path);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
LiteFlowNodeBuilder.createScriptNode().setId(nodeSimpleVO.getNodeId())
|
||||
.setType(NodeTypeEnum.getEnumByCode(nodeSimpleVO.type))
|
||||
.setName(nodeSimpleVO.getName())
|
||||
.setScript(value).build();
|
||||
} else if (CuratorCacheListener.Type.NODE_DELETED.equals(type)) {
|
||||
LOG.info("starting reload flow config... delete path={}", path);
|
||||
String scriptNodeValue = FileNameUtil.getName(path);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
FlowBus.getNodeMap().remove(nodeSimpleVO.getNodeId());
|
||||
}
|
||||
});
|
||||
if (StrUtil.isNotBlank(zkParserVO.getScriptPath())){
|
||||
//监听script
|
||||
CuratorCache cache2 = CuratorCache.build(client, zkParserVO.getScriptPath());
|
||||
cache2.start();
|
||||
cache2.listenable().addListener((type, oldData, data) -> {
|
||||
String path = data.getPath();
|
||||
String value = new String(data.getData());
|
||||
if (StrUtil.isBlank(value)){
|
||||
return;
|
||||
}
|
||||
if (ListUtil.toList(CuratorCacheListener.Type.NODE_CREATED, CuratorCacheListener.Type.NODE_CHANGED).contains(type)){
|
||||
LOG.info("starting reload flow config... {} path={} value={},", type.name(), path, value);
|
||||
String scriptNodeValue = FileNameUtil.getName(path);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
LiteFlowNodeBuilder.createScriptNode().setId(nodeSimpleVO.getNodeId())
|
||||
.setType(NodeTypeEnum.getEnumByCode(nodeSimpleVO.type))
|
||||
.setName(nodeSimpleVO.getName())
|
||||
.setScript(value).build();
|
||||
} else if (CuratorCacheListener.Type.NODE_DELETED.equals(type)) {
|
||||
LOG.info("starting reload flow config... delete path={}", path);
|
||||
String scriptNodeValue = FileNameUtil.getName(path);
|
||||
NodeSimpleVO nodeSimpleVO = convert(scriptNodeValue);
|
||||
FlowBus.getNodeMap().remove(nodeSimpleVO.getNodeId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public NodeSimpleVO convert(String str){
|
||||
|
|
Loading…
Reference in New Issue