| @@ -1,65 +0,0 @@ | |||||
| package fifo | |||||
| const ( | |||||
| ADD = "add" | |||||
| UPDATE = "update" | |||||
| DELETE = "delete" | |||||
| RETRY = "retry" | |||||
| ) | |||||
| type Data struct { | |||||
| Event string | |||||
| TaskType string | |||||
| Data interface{} | |||||
| } | |||||
| type IData interface { | |||||
| } | |||||
| type Cloud struct { | |||||
| Id int64 `db:"id"` // id | |||||
| TaskId int64 `db:"task_id"` // 任务id | |||||
| ParticipantId int64 `db:"participant_id"` // 集群静态信息id | |||||
| ApiVersion string `db:"api_version"` //api版本 | |||||
| Name string `db:"name"` // 名称 | |||||
| Namespace string `db:"namespace"` // 命名空间 | |||||
| Kind string `db:"kind"` // 种类 | |||||
| Status string `db:"status"` // 状态 | |||||
| StartTime string `db:"start_time"` // 开始时间 | |||||
| RunningTime int64 `db:"running_time"` // 运行时长 | |||||
| YamlString string `db:"yaml_string"` | |||||
| Result string `db:"result"` // 运行结果 | |||||
| } | |||||
| type Hpc struct { | |||||
| Id int64 `db:"id"` // id | |||||
| TaskId int64 `db:"task_id"` // 任务id | |||||
| ParticipantId int64 `db:"participant_id"` // 集群静态信息id | |||||
| JobId string `db:"job_id"` // 作业id | |||||
| Name string `db:"name"` // 名称 | |||||
| Status string `db:"status"` // 状态 | |||||
| StartTime string `db:"start_time"` // 开始时间 | |||||
| RunningTime int64 `db:"running_time"` // 运行时间 | |||||
| CardCount int64 `db:"card_count"` // 卡数 | |||||
| WorkDir string `db:"work_dir"` | |||||
| WallTime string `db:"wall_time"` | |||||
| Result string `db:"result"` | |||||
| YamlString string `db:"yaml_string"` | |||||
| CmdScript string `db:"cmd_script"` | |||||
| //DerivedEs string `db:"derived_es"` | |||||
| //Cluster string `db:"cluster"` | |||||
| //BlockId string `db:"block_id"` | |||||
| //AllocNodes uint32 `db:"alloc_nodes"` | |||||
| //AllocCpu uint32 `db:"alloc_cpu"` | |||||
| //Version string `db:"version"` | |||||
| //Account string `db:"account"` | |||||
| //ExitCode uint32 `db:"exit_code"` | |||||
| //AssocId uint32 `db:"assoc_id"` | |||||
| AppType string `db:"app_type"` | |||||
| AppName string `db:"app_name"` | |||||
| Queue string `db:"queue"` | |||||
| SubmitType string `db:"submit_type"` | |||||
| NNode string `db:"n_node"` | |||||
| StdOutFile string `db:"std_out_file"` | |||||
| StdErrFile string `db:"std_err_file"` | |||||
| } | |||||
| @@ -1,31 +0,0 @@ | |||||
| package fifo | |||||
| import ( | |||||
| "sync" | |||||
| ) | |||||
| type Queue struct { | |||||
| DataList []*IData | |||||
| mutex sync.Mutex | |||||
| ResourceType string | |||||
| } | |||||
| func (q *Queue) Push(data IData) { | |||||
| q.mutex.Lock() | |||||
| defer q.mutex.Unlock() | |||||
| q.DataList = append(q.DataList, &data) | |||||
| } | |||||
| func (q *Queue) Pop() IData { | |||||
| q.mutex.Lock() | |||||
| defer q.mutex.Unlock() | |||||
| if len(q.DataList) <= 0 { | |||||
| return nil | |||||
| } | |||||
| var data = q.DataList[0] | |||||
| q.DataList = q.DataList[1:] | |||||
| return data | |||||
| } | |||||
| @@ -1,57 +0,0 @@ | |||||
| package fifo | |||||
| import "strings" | |||||
| const ( | |||||
| CLOUD string = "Cloud" | |||||
| AI string = "Ai" | |||||
| HPC string = "Hpc" | |||||
| ) | |||||
| type TaskFIFO struct { | |||||
| Queues []*Queue | |||||
| } | |||||
| // NewChannel 初始化队列 | |||||
| func NewChannel() *TaskFIFO { | |||||
| channel := TaskFIFO{ | |||||
| Queues: []*Queue{ | |||||
| { | |||||
| ResourceType: CLOUD, | |||||
| }, | |||||
| { | |||||
| ResourceType: AI, | |||||
| }, | |||||
| { | |||||
| ResourceType: HPC, | |||||
| }, | |||||
| }, | |||||
| } | |||||
| return &channel | |||||
| } | |||||
| // SelectQueue 根据资源类型查询队列数组 | |||||
| func (c *TaskFIFO) SelectQueue(resourceType string) *Queue { | |||||
| for _, queue := range c.Queues { | |||||
| if strings.EqualFold(queue.ResourceType, resourceType) { | |||||
| return queue | |||||
| } | |||||
| } | |||||
| return nil | |||||
| } | |||||
| func main() { | |||||
| channel := NewChannel() | |||||
| cloudQueue := channel.SelectQueue("cloud") | |||||
| dataList := []IData{ | |||||
| &Data{ | |||||
| TaskType: "cloud", | |||||
| Data: &Cloud{}}, | |||||
| } | |||||
| cloudQueue.Push(&dataList) | |||||
| println(len(dataList)) | |||||
| } | |||||
| @@ -3,7 +3,7 @@ package mqs | |||||
| import ( | import ( | ||||
| "context" | "context" | ||||
| "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" | "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" | ||||
| scheduler2 "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/scheduler" | |||||
| "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/scheduler" | |||||
| ) | ) | ||||
| /* | /* | ||||
| @@ -24,8 +24,8 @@ func NewCloudMq(ctx context.Context, svcCtx *svc.ServiceContext) *CloudMq { | |||||
| func (l *CloudMq) Consume(val string) error { | func (l *CloudMq) Consume(val string) error { | ||||
| // 接受消息, 根据标签筛选过滤 | // 接受消息, 根据标签筛选过滤 | ||||
| cloudScheduler := scheduler2.NewCloudScheduler() | |||||
| schdl, err := scheduler2.NewScheduler(cloudScheduler, val, l.svcCtx.DbEngin) | |||||
| cloudScheduler := scheduler.NewCloudScheduler() | |||||
| schdl, err := scheduler.NewScheduler(cloudScheduler, val, l.svcCtx.DbEngin) | |||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| @@ -1,18 +1,16 @@ | |||||
| description: 0901 | |||||
| strategy: 策略 | |||||
| synergy: 协同状态 | |||||
| name: myapp-0901 | |||||
| description: 1031 | |||||
| name: myapp-1031 | |||||
| tasks: | tasks: | ||||
| - taskType: cloud | - taskType: cloud | ||||
| participantId: 1694303450734530560 | |||||
| participantId: 1713882658292895744 | |||||
| matchLabels: | matchLabels: | ||||
| nudt: hpc | |||||
| metadata: | |||||
| cloud: ali | |||||
| metadata: | |||||
| apiVersion: apps/v1 | apiVersion: apps/v1 | ||||
| kind: Deployment | kind: Deployment | ||||
| metadata: | metadata: | ||||
| name: myapp-0901 | |||||
| namespace: zw | |||||
| name: myapp-1031 | |||||
| namespace: default | |||||
| spec: | spec: | ||||
| replicas: 2 | replicas: 2 | ||||
| selector: | selector: | ||||
| @@ -20,7 +18,7 @@ tasks: | |||||
| app: myapp | app: myapp | ||||
| version: v1 | version: v1 | ||||
| template: | template: | ||||
| metadata: | |||||
| metadata: | |||||
| labels: | labels: | ||||
| app: myapp | app: myapp | ||||
| version: v1 | version: v1 | ||||