示例#1
0
//暂时没有实现基于enc的此方法
func (this *SafeMonitoredHosts) Init() {
	var hostMap map[int]*model.Host

	if g.Config().ExternalNodes == "" {
		m, err := db.QueryMonitoredHosts()
		if err != nil {
			return
		}
		hostMap = m
	} else {
		m, err := enc.QueryMonitoredHosts()
		if err != nil {
			return
		}
		hostMap = m
	}

	this.Lock()
	defer this.Unlock()
	this.M = hostMap

	debug := g.Config().Debug
	if debug {
		log.Printf("[DEBUG][CACHE] SafeMonitoredHosts.init : %v", this.M)
	}
}
示例#2
0
func (this *SafeMonitoredHosts) Init() {
	m, err := db.QueryMonitoredHosts()
	if err != nil {
		return
	}

	this.Lock()
	defer this.Unlock()
	this.M = m
}