forked from pneymrl2f/nightingale
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
714 B
36 lines
714 B
package cron
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/didi/nightingale/src/modules/transfer/backend"
|
|
|
|
"github.com/toolkits/pkg/container/list"
|
|
)
|
|
|
|
func UpdateJudgeQueue() {
|
|
ticker := time.NewTicker(time.Duration(8) * time.Second)
|
|
for {
|
|
<-ticker.C
|
|
updateJudgeQueue()
|
|
}
|
|
}
|
|
|
|
func updateJudgeQueue() {
|
|
instances := backend.GetJudges()
|
|
if len(instances) == 0 {
|
|
return
|
|
}
|
|
|
|
for _, instance := range instances {
|
|
if !backend.JudgeQueues.Exists(instance) {
|
|
q := list.NewSafeListLimited(backend.DefaultSendQueueMaxSize)
|
|
backend.JudgeQueues.Set(instance, q)
|
|
go backend.Send2JudgeTask(q, instance, backend.Judge.WorkerNum)
|
|
} else {
|
|
backend.JudgeQueues.UpdateTS(instance)
|
|
}
|
|
}
|
|
backend.JudgeQueues.Clean()
|
|
}
|