增加各服务的配置文件
This commit is contained in:
parent
96c41e3625
commit
a98c7bc2bb
|
@ -1,23 +1,89 @@
|
|||
package services
|
||||
|
||||
import "gitlink.org.cn/cloudream/common/models"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlink.org.cn/cloudream/common/models"
|
||||
"gitlink.org.cn/cloudream/common/pkgs/logger"
|
||||
)
|
||||
|
||||
type JobSetService struct {
|
||||
*Service
|
||||
}
|
||||
|
||||
var jobSetInfos = map[string]*models.JobSetInfo{}
|
||||
var jobSetIDValue int64
|
||||
|
||||
func (svc *Service) JobSetSvc() *JobSetService {
|
||||
return &JobSetService{Service: svc}
|
||||
}
|
||||
|
||||
// 提交任务集
|
||||
func (svc *JobSetService) Submit(info models.JobSetInfo) (string, error) {
|
||||
// TODO
|
||||
return "testID", nil
|
||||
// TODO 临时逻辑
|
||||
|
||||
jobSetID := fmt.Sprintf("%d", jobSetIDValue)
|
||||
|
||||
logger.Debugf("create job set: %s", jobSetID)
|
||||
|
||||
jobSetIDValue++
|
||||
|
||||
jobSetInfos[jobSetID] = &info
|
||||
|
||||
return jobSetID, nil
|
||||
}
|
||||
|
||||
// 任务集中某个文件上传完成
|
||||
func (svc *JobSetService) SetLocalFile(jobSetID string, localPath string, packageID int64) error {
|
||||
// TODO
|
||||
// TODO 临时逻辑
|
||||
|
||||
info, ok := jobSetInfos[jobSetID]
|
||||
if !ok {
|
||||
return fmt.Errorf("job set not found for %s", jobSetID)
|
||||
}
|
||||
|
||||
needUpload := false
|
||||
for i := 0; i < len(info.Jobs); i++ {
|
||||
switch rjob := info.Jobs[i].(type) {
|
||||
case models.NormalJobInfo:
|
||||
localFileInfo, ok := rjob.Files.Dataset.(models.LocalFileInfo)
|
||||
if ok && localFileInfo.LocalPath != "" {
|
||||
needUpload = true
|
||||
|
||||
if localFileInfo.LocalPath == localPath {
|
||||
localFileInfo.LocalPath = ""
|
||||
rjob.Files.Dataset = localFileInfo
|
||||
}
|
||||
}
|
||||
|
||||
localFileInfo, ok = rjob.Files.Code.(models.LocalFileInfo)
|
||||
if ok && localFileInfo.LocalPath != "" {
|
||||
needUpload = true
|
||||
|
||||
if localFileInfo.LocalPath == localPath {
|
||||
localFileInfo.LocalPath = ""
|
||||
rjob.Files.Code = localFileInfo
|
||||
}
|
||||
}
|
||||
|
||||
localFileInfo, ok = rjob.Files.Image.(models.LocalFileInfo)
|
||||
if ok && localFileInfo.LocalPath != "" {
|
||||
needUpload = true
|
||||
|
||||
if localFileInfo.LocalPath == localPath {
|
||||
localFileInfo.LocalPath = ""
|
||||
rjob.Files.Image = localFileInfo
|
||||
}
|
||||
}
|
||||
info.Jobs[i] = rjob
|
||||
}
|
||||
}
|
||||
|
||||
if needUpload {
|
||||
logger.Debugf("need upload more files.")
|
||||
} else {
|
||||
logger.Debugf("all files is uploaded.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
type Config struct {
|
||||
Logger log.Config `json:"logger"`
|
||||
RabbitMQ mymq.Config `json:"rabbitMQ`
|
||||
RabbitMQ mymq.Config `json:"rabbitMQ"`
|
||||
CloudreamStorage cldstg.Config `json:"cloudreamStorage"`
|
||||
UnifyOps uniops.Config `json:"unifyOps"`
|
||||
// PCM cldstg.Config `json:"pcm"`
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"logger": {
|
||||
"output": "file",
|
||||
"outputFileName": "client",
|
||||
"outputDirectory": "log",
|
||||
"output": "stdout",
|
||||
"level": "debug"
|
||||
},
|
||||
"rabbitMQ": {
|
||||
|
@ -12,6 +10,6 @@
|
|||
"vhost": "/"
|
||||
},
|
||||
"cloudreamStorage": {
|
||||
"url": "http://127.0.0.1:7890"
|
||||
"url": "http://localhost:7890"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"logger": {
|
||||
"output": "file",
|
||||
"outputFileName": "collector",
|
||||
"outputDirectory": "log",
|
||||
"level": "debug"
|
||||
},
|
||||
"rabbitMQ": {
|
||||
"address": "127.0.0.1:5672",
|
||||
"account": "cloudream",
|
||||
"password": "123456",
|
||||
"vhost": "/"
|
||||
},
|
||||
"cloudreamStorage": {
|
||||
"url": "http://localhost:7890"
|
||||
},
|
||||
"unifyOps": {
|
||||
"url": "http://localhost:7890"
|
||||
}
|
||||
}
|
|
@ -12,6 +12,6 @@
|
|||
"vhost": "/"
|
||||
},
|
||||
"cloudreamStorage": {
|
||||
"url": "http://127.0.0.1:7890"
|
||||
"url": "http://localhost:7890"
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ type Config struct {
|
|||
var cfg Config
|
||||
|
||||
func Init() error {
|
||||
return c.DefaultLoad("dcontroller", &cfg)
|
||||
return c.DefaultLoad("executor", &cfg)
|
||||
}
|
||||
|
||||
func Cfg() *Config {
|
||||
|
|
Loading…
Reference in New Issue