[transfer] fix and trigger generates event twice bug (#266)
* [transfer] fix and trigger generates event twice bug * [monapi] stra excl all leaf nodes under exclNid
This commit is contained in:
parent
16a39410b8
commit
7abec2ccb8
|
@ -232,10 +232,15 @@ func GetLeafNids(nid int64, exclNid []int64) ([]int64, error) {
|
||||||
return ids, nil
|
return ids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exclLeafIds, err := GetExclLeafIds(exclNid)
|
||||||
|
if err != nil {
|
||||||
|
return leafIds, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
idsMap[id] = true
|
idsMap[id] = true
|
||||||
}
|
}
|
||||||
for _, id := range exclNid {
|
for _, id := range exclLeafIds {
|
||||||
delete(idsMap, id)
|
delete(idsMap, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,3 +261,19 @@ func removeDuplicateElement(addrs []string) []string {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetExclLeafIds 获取排除节点下的叶子节点
|
||||||
|
func GetExclLeafIds(exclNid []int64) (leafIds []int64, err error) {
|
||||||
|
for _, nid := range exclNid {
|
||||||
|
node, err := model.NodeGet("id", nid)
|
||||||
|
if err != nil {
|
||||||
|
return leafIds, err
|
||||||
|
}
|
||||||
|
ids, err := node.LeafIds()
|
||||||
|
if err != nil {
|
||||||
|
return leafIds, err
|
||||||
|
}
|
||||||
|
leafIds = append(leafIds, ids...)
|
||||||
|
}
|
||||||
|
return leafIds, nil
|
||||||
|
}
|
||||||
|
|
|
@ -76,8 +76,7 @@ func getStrategy() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, exp := range stra.Exprs {
|
metric := stra.Exprs[0].Metric
|
||||||
metric := exp.Metric
|
|
||||||
for _, endpoint := range stra.Endpoints {
|
for _, endpoint := range stra.Endpoints {
|
||||||
key := str.PK(metric, endpoint) //TODO get straMap key, 此处需要优化
|
key := str.PK(metric, endpoint) //TODO get straMap key, 此处需要优化
|
||||||
k1 := key[0:2] //为了加快查找,增加一层 map,key 为计算出来的 hash 的前 2 位
|
k1 := key[0:2] //为了加快查找,增加一层 map,key 为计算出来的 hash 的前 2 位
|
||||||
|
@ -95,7 +94,6 @@ func getStrategy() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
cache.StraMap.ReInit(straMap)
|
cache.StraMap.ReInit(straMap)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue