|
- package strategy
-
- import (
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/collector"
- "gitlink.org.cn/JointCloud/pcm-coordinator/internal/storeLink"
- )
-
- type LoadPriority struct {
- Replicas int32
- Clusters []*CLusterLoad
- }
-
- type CLusterLoad struct {
- ClusterId string
- TaskRunningNum int64
- TaskPredictedNum int64
- }
-
- func NewLoadPriority(replicas int32, resources []*collector.ResourceSpec) *LoadPriority {
- var clusters []*CLusterLoad
-
- for _, resource := range resources {
- if resource.ClusterId == "" {
- continue
- }
- cluster := &CLusterLoad{
- ClusterId: resource.ClusterId,
- }
- for _, res := range resource.Resources {
- r, ok := res.(*collector.Usage)
- if !ok {
- continue
- }
- switch r.Type {
- case storeLink.RUNNINGTASK:
- num, ok := r.Total.Value.(int64)
- if !ok {
- continue
- }
- cluster.TaskRunningNum = num
- }
- }
- clusters = append(clusters, cluster)
- }
- return &LoadPriority{Replicas: replicas, Clusters: clusters}
- }
|