You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

batch_all_agent_check_cache.go 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package tickevent
  2. import (
  3. "github.com/samber/lo"
  4. "gitlink.org.cn/cloudream/common/pkg/logger"
  5. "gitlink.org.cn/cloudream/db/model"
  6. "gitlink.org.cn/cloudream/scanner/internal/event"
  7. )
  8. const AGENT_CHECK_CACHE_BATCH_SIZE = 2
  9. type BatchAllAgentCheckCache struct {
  10. nodeIDs []int
  11. }
  12. func NewBatchAllAgentCheckCache() *BatchAllAgentCheckCache {
  13. return &BatchAllAgentCheckCache{}
  14. }
  15. func (e *BatchAllAgentCheckCache) Execute(ctx ExecuteContext) {
  16. log := logger.WithType[BatchAllAgentCheckCache]("TickEvent")
  17. log.Debugf("begin")
  18. if e.nodeIDs == nil || len(e.nodeIDs) == 0 {
  19. nodes, err := ctx.Args.DB.Node().GetAllNodes(ctx.Args.DB.SQLCtx())
  20. if err != nil {
  21. log.Warnf("get all nodes failed, err: %s", err.Error())
  22. return
  23. }
  24. e.nodeIDs = lo.Map(nodes, func(node model.Node, index int) int { return node.NodeID })
  25. log.Debugf("new check start, get all nodes")
  26. }
  27. checkedCnt := 0
  28. for ; checkedCnt < len(e.nodeIDs) && checkedCnt < AGENT_CHECK_CACHE_BATCH_SIZE; checkedCnt++ {
  29. // nil代表进行全量检查
  30. ctx.Args.EventExecutor.Post(event.NewAgentCheckCache(e.nodeIDs[checkedCnt], nil))
  31. }
  32. e.nodeIDs = e.nodeIDs[checkedCnt:]
  33. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。