mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-06 10:00:25 +08:00
指标数据队列增加最大数量限制,防止过载
This commit is contained in:
@@ -19,6 +19,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MaxQueueSize = 10240
|
||||||
|
|
||||||
// Task 单个指标任务
|
// Task 单个指标任务
|
||||||
// 数据库存储:
|
// 数据库存储:
|
||||||
// data/
|
// data/
|
||||||
@@ -225,6 +227,8 @@ func (this *Task) Add(obj MetricInterface) {
|
|||||||
oldStat.Value += v
|
oldStat.Value += v
|
||||||
oldStat.Hash = hash
|
oldStat.Hash = hash
|
||||||
} else {
|
} else {
|
||||||
|
// 防止过载
|
||||||
|
if len(this.statsMap) < MaxQueueSize {
|
||||||
this.statsMap[hash] = &Stat{
|
this.statsMap[hash] = &Stat{
|
||||||
ServerId: obj.MetricServerId(),
|
ServerId: obj.MetricServerId(),
|
||||||
Keys: keys,
|
Keys: keys,
|
||||||
@@ -233,6 +237,7 @@ func (this *Task) Add(obj MetricInterface) {
|
|||||||
Hash: hash,
|
Hash: hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.statsLocker.Unlock()
|
this.statsLocker.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user