|
@@ -1,9 +1,7 @@
|
|
|
package handler
|
|
|
|
|
|
import (
|
|
|
- "dcl_dispatch_server/src/package/domain"
|
|
|
"dcl_dispatch_server/src/package/entity"
|
|
|
- "dcl_dispatch_server/src/package/global"
|
|
|
"dcl_dispatch_server/src/package/infra"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"io"
|
|
@@ -118,49 +116,49 @@ import (
|
|
|
*/
|
|
|
|
|
|
func StartProject(c *gin.Context) {
|
|
|
-
|
|
|
- projectStartParam := new(entity.Project)
|
|
|
- if err := c.ShouldBindJSON(&projectStartParam); err != nil {
|
|
|
-
|
|
|
- bodyBytes, err := io.ReadAll(c.Request.Body)
|
|
|
- if err != nil {
|
|
|
- c.String(500, "Error reading request body")
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- bodyString := string(bodyBytes)
|
|
|
- infra.GlobalLogger.Error("项目启动接收请求参数为:", bodyString)
|
|
|
- infra.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
- c.JSON(http.StatusBadRequest, entity.HttpResult{Status: false, Code: "1003", Message: "请求参数格式错误。"})
|
|
|
+
|
|
|
+ bodyBytes, err := io.ReadAll(c.Request.Body)
|
|
|
+ if err != nil {
|
|
|
+ c.String(500, "Error reading request body")
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- userId := projectStartParam.UserId
|
|
|
- taskReceived := projectStartParam.Tasks
|
|
|
- userParallelism := projectStartParam.Parallelism
|
|
|
- algorithmObjectKey := projectStartParam.AlgorithmObjectKey
|
|
|
+
|
|
|
+ bodyString := string(bodyBytes)
|
|
|
+ infra.GlobalLogger.Info("项目启动接收请求参数为:", bodyString)
|
|
|
|
|
|
-
|
|
|
- for _, task := range taskReceived {
|
|
|
- global.RunTaskMutex.Lock()
|
|
|
-
|
|
|
- if domain.CanRunUser(userId, userParallelism) {
|
|
|
- err := domain.AddWaitingCluster(userId, userParallelism, algorithmObjectKey, task)
|
|
|
- if err != nil {
|
|
|
- infra.GlobalLogger.Errorf("将任务 %v 添加到【集群等待队列】失败,错误信息为:%v", task, err)
|
|
|
- continue
|
|
|
- }
|
|
|
- infra.GlobalLogger.Infof("将任务 %v 添加到【集群等待队列】成功。", task.Info.TaskId)
|
|
|
- } else {
|
|
|
- err := domain.AddWaitingUser(userId, userParallelism, algorithmObjectKey, task)
|
|
|
- if err != nil {
|
|
|
- infra.GlobalLogger.Errorf("将任务 %v 添加到【用户等待队列】失败,错误信息为:%v", task, err)
|
|
|
- continue
|
|
|
- }
|
|
|
- infra.GlobalLogger.Infof("将任务 %v 添加到【用户等待队列】成功。", task.Info.TaskId)
|
|
|
- }
|
|
|
- global.RunTaskMutex.Unlock()
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, entity.HttpResult{Status: true, Code: "2000", Message: "项目启动请求已被成功接收,等待调度处理。"})
|