Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改agent 缓存的lastUpdate 更新策略 #469

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions modules/hbs/cache/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package cache
// 提供http接口查询机器信息,排查重名机器的时候比较有用

import (
"github.com/open-falcon/falcon-plus/common/model"
"github.com/open-falcon/falcon-plus/modules/hbs/db"
"sync"
"time"

"github.com/open-falcon/falcon-plus/common/model"
"github.com/open-falcon/falcon-plus/modules/hbs/db"
)

type SafeAgents struct {
Expand All @@ -48,10 +49,12 @@ func (this *SafeAgents) Put(req *model.AgentReportRequest) {
agentInfo.ReportRequest.PluginVersion != req.PluginVersion {

db.UpdateAgent(val)
this.Lock()
this.M[req.Hostname] = val
this.Unlock()
}

// 更新hbs 时间
this.Lock()
this.M[req.Hostname] = val
this.Unlock()
}

func (this *SafeAgents) Get(hostname string) (*model.AgentUpdateInfo, bool) {
Expand Down