1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-12-15 08:16:43 +00:00
This commit is contained in:
2019-04-29 17:05:15 +08:00
parent 549e559a73
commit 00c04333ad
6 changed files with 104 additions and 53 deletions

View File

@@ -15,14 +15,9 @@ var pool *ResourcePool
var allocator *AllocatorFIFO
func serverAPI(w http.ResponseWriter, r *http.Request) {
var nodes []string
for id := range pool.nodes {
nodes = append(nodes, id)
}
switch r.URL.Query().Get("action") {
case "node_gets":
js, _ := json.Marshal(nodes)
case "resource_list":
js, _ := json.Marshal(pool.list())
w.Header().Set("Content-Type", "application/json")
w.Write(js)
break
@@ -85,6 +80,13 @@ func serverAPI(w http.ResponseWriter, r *http.Request) {
w.Write(js)
break
case "pool_status_history":
fmt.Println("pool_status_history")
js, _ := json.Marshal(pool.statusHistory())
w.Header().Set("Content-Type", "application/json")
w.Write(js)
break
default:
http.Error(w, "Not Found", http.StatusNotFound)
break
@@ -94,6 +96,7 @@ func serverAPI(w http.ResponseWriter, r *http.Request) {
func main() {
pool = &ResourcePool{}
pool.nodes = make(map[string]NodeStatus)
pool.start()
allocator = &AllocatorFIFO{}
allocator.start()