updated startall logics
Former-commit-id: b2d525b2fd4931508007d08404f12743f9f65e8e
This commit is contained in:
parent
1ec58ac8f2
commit
179af7cd4a
|
@ -2,11 +2,12 @@ package inference
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
"strconv"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StartAllByDeployTaskIdLogic struct {
|
type StartAllByDeployTaskIdLogic struct {
|
||||||
|
@ -24,7 +25,23 @@ func NewStartAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *StartAllByDeployTaskIdLogic) StartAllByDeployTaskId(req *types.StartAllByDeployTaskIdReq) (resp *types.StartAllByDeployTaskIdResp, err error) {
|
func (l *StartAllByDeployTaskIdLogic) StartAllByDeployTaskId(req *types.StartAllByDeployTaskIdReq) (resp *types.StartAllByDeployTaskIdResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.StartAllByDeployTaskIdResp{}
|
||||||
|
|
||||||
return
|
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||||
|
|
||||||
|
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ins := range list {
|
||||||
|
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StartInferDeployInstance(l.ctx, ins.InstanceId)
|
||||||
|
if !success {
|
||||||
|
return nil, errors.New(ins.InstanceName + " start failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
go updater.UpdateDeployInstanceStatusBatch(l.svcCtx, list)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package inference
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/scheduler/service/updater"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
@ -24,7 +26,23 @@ func NewStopAllByDeployTaskIdLogic(ctx context.Context, svcCtx *svc.ServiceConte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *StopAllByDeployTaskIdLogic) StopAllByDeployTaskId(req *types.StopAllByDeployTaskIdReq) (resp *types.StopAllByDeployTaskIdResp, err error) {
|
func (l *StopAllByDeployTaskIdLogic) StopAllByDeployTaskId(req *types.StopAllByDeployTaskIdReq) (resp *types.StopAllByDeployTaskIdResp, err error) {
|
||||||
// todo: add your logic here and delete this line
|
resp = &types.StopAllByDeployTaskIdResp{}
|
||||||
|
|
||||||
return
|
id, err := strconv.ParseInt(req.Id, 10, 64)
|
||||||
|
|
||||||
|
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ins := range list {
|
||||||
|
success := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[strconv.FormatInt(ins.AdapterId, 10)][strconv.FormatInt(ins.ClusterId, 10)].StopInferDeployInstance(l.ctx, ins.InstanceId)
|
||||||
|
if !success {
|
||||||
|
return nil, errors.New(ins.InstanceName + " stop failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
go updater.UpdateDeployInstanceStatusBatch(l.svcCtx, list)
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,6 +421,16 @@ func (s *AiStorage) GetInferDeployInstanceById(id int64) (*models.AiInferDeployI
|
||||||
return &deployIns, nil
|
return &deployIns, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AiStorage) GetInstanceListByDeployTaskId(id int64) ([]*models.AiInferDeployInstance, error) {
|
||||||
|
var list []*models.AiInferDeployInstance
|
||||||
|
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance where `deploy_instance_task_id` = ?", id).Scan(&list)
|
||||||
|
if tx.Error != nil {
|
||||||
|
logx.Errorf(tx.Error.Error())
|
||||||
|
return nil, tx.Error
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *AiStorage) GetInferDeployInstanceList() ([]*models.AiInferDeployInstance, error) {
|
func (s *AiStorage) GetInferDeployInstanceList() ([]*models.AiInferDeployInstance, error) {
|
||||||
var list []*models.AiInferDeployInstance
|
var list []*models.AiInferDeployInstance
|
||||||
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance").Scan(&list)
|
tx := s.DbEngin.Raw("select * from ai_infer_deploy_instance").Scan(&list)
|
||||||
|
|
Loading…
Reference in New Issue