MCPcopy Create free account
hub / github.com/TalkingData/owl / processSingleStrategy

Method processSingleStrategy

controller/strategy.go:53–81  ·  view source on GitHub ↗
(strategy *types.Strategy, triggers map[string]*types.Trigger)

Source from the content-addressed store, hash-verified

51}
52
53func (c *Controller) processSingleStrategy(strategy *types.Strategy, triggers map[string]*types.Trigger) {
54 globalHosts := make([]*types.Host, 0)
55 for _, group := range mydb.GetGroupsByStrategyID(strategy.ID) {
56 groupHosts := mydb.GetHostsByGroupID(group.ID)
57 globalHosts = append(globalHosts, groupHosts...)
58 }
59 exHosts := mydb.GetHostsExByStrategyID(strategy.ID)
60 for _, host := range globalHosts {
61 // 过滤静音主机
62 if host.IsMute() {
63 lg.Info("strategy %d:%v host is mute %v:%v:%v, mute_time:%s",
64 strategy.ID, strategy.Name, host.ID, host.IP, host.Hostname, host.MuteTime)
65 continue
66 }
67 // 过滤排除主机
68 if _, ok := exHosts[host.ID]; ok {
69 lg.Info("strategy %d:%v exclude host %v:%v:%v",
70 strategy.ID, strategy.Name, host.ID, host.IP, host.Hostname)
71 continue
72 }
73 // 向 taskCache 添加任务
74 task := types.NewAlarmTask(host, strategy, triggers)
75 if err := c.taskPool.putTask(task); err != nil {
76 lg.Error("put new task into task pool failed %v, maybe you need to increase the task_pool_size", err)
77 continue
78 }
79 c.taskCache.Set(task.ID, task, 10*time.Minute)
80 }
81}

Callers 1

loadStrategiesForeverMethod · 0.95

Calls 6

GetGroupsByStrategyIDMethod · 0.80
GetHostsByGroupIDMethod · 0.80
IsMuteMethod · 0.80
putTaskMethod · 0.80
SetMethod · 0.80

Tested by

no test coverage detected