mirror of
https://github.com/newnius/YAO-scheduler.git
synced 2025-06-07 14:21:55 +00:00
switch collector from kafka to http
This commit is contained in:
parent
04232a34e5
commit
6c9e802a31
24
src/main.go
24
src/main.go
@ -14,6 +14,28 @@ var scheduler Scheduler
|
|||||||
|
|
||||||
func serverAPI(w http.ResponseWriter, r *http.Request) {
|
func serverAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.URL.Query().Get("action") {
|
switch r.URL.Query().Get("action") {
|
||||||
|
case "agent_report":
|
||||||
|
log.Debug("agent_report")
|
||||||
|
msgAgentReport := MsgAgentReport{Code: 0}
|
||||||
|
var nodeStatus NodeStatus
|
||||||
|
err := json.Unmarshal([]byte(string(r.PostFormValue("data"))), &nodeStatus)
|
||||||
|
if err != nil {
|
||||||
|
msgAgentReport.Code = 1
|
||||||
|
msgAgentReport.Error = err.Error()
|
||||||
|
log.Warn(err)
|
||||||
|
} else {
|
||||||
|
go func() {
|
||||||
|
InstanceOfResourcePool().update(nodeStatus)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
js, err := json.Marshal(msgAgentReport)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(err)
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Write(js)
|
||||||
|
break
|
||||||
|
|
||||||
case "resource_list":
|
case "resource_list":
|
||||||
js, _ := json.Marshal(InstanceOfResourcePool().list())
|
js, _ := json.Marshal(InstanceOfResourcePool().list())
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
@ -363,7 +385,7 @@ func main() {
|
|||||||
|
|
||||||
/* init components */
|
/* init components */
|
||||||
InstanceOfResourcePool().init(config)
|
InstanceOfResourcePool().init(config)
|
||||||
InstanceOfCollector().init(config)
|
//InstanceOfCollector().init(config)
|
||||||
InstanceJobHistoryLogger().init(config)
|
InstanceJobHistoryLogger().init(config)
|
||||||
InstanceOfOptimizer().Init(config)
|
InstanceOfOptimizer().Init(config)
|
||||||
InstanceOfGroupManager().init(config)
|
InstanceOfGroupManager().init(config)
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
type MsgAgentReport struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Error string `json:"error"`
|
||||||
|
}
|
||||||
|
|
||||||
type MsgSubmit struct {
|
type MsgSubmit struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
|
@ -105,6 +105,8 @@ func (optimizer *Optimizer) FeedTime(job Job, stats [][]TaskStatus) {
|
|||||||
|
|
||||||
exceptions := map[string]bool{}
|
exceptions := map[string]bool{}
|
||||||
exceptions["train_dir"] = true
|
exceptions["train_dir"] = true
|
||||||
|
exceptions["data__dir"] = true
|
||||||
|
exceptions["tmp__dir"] = true
|
||||||
exceptions["variable_update"] = true
|
exceptions["variable_update"] = true
|
||||||
exceptions["ps_hosts"] = true
|
exceptions["ps_hosts"] = true
|
||||||
exceptions["worker_hosts"] = true
|
exceptions["worker_hosts"] = true
|
||||||
|
Loading…
Reference in New Issue
Block a user