Esempio n. 1
0
//Monitor length of job queue stack
func WI_JobQueueLen(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message interface{}
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	} else {
		success = true
	}
	message = sheepobj.JobLen()
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
Esempio n. 2
0
//Escape the last failed job
func WI_FailEscape(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message string = ""
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	} else {
		success = true
	}
	sheepobj.SetLastFail(nil)
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
Esempio n. 3
0
//sheeps` status
func WI_SheepStatus(r macaron.Render, req *http.Request) {
	var success bool = true
	var message interface{}
	var data []SHEEPSTATUS
	var tmp SHEEPSTATUS
	for shpid, sheepobj := range sheep.SHEEPS {
		rs := sheepobj.RuningStatus()
		tmp.ID = shpid
		tmp.ENABLE = rs["ENABLE"].(bool)
		tmp.STATUS = rs["STATUS"].(int)
		tmp.JOBQLEN = rs["JOBQLEN"].(int)
		tmp.FOQLEN = rs["FOQLEN"].(int)
		tmp.CAPACITY = rs["CAPACITY"].(int)
		data = append(data, tmp)
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message, "data": data})
}
Esempio n. 4
0
//Assign jobs
func WI_JobAssign(r macaron.Render, req *http.Request) {
	REQ += 1
	req.ParseForm()
	var success bool = false
	var message interface{}
	var isbypass bool = false
	bypass := req.Form.Get("bypass")
	key := req.Form.Get("key")
	if bypass == "1" { // check if bypass mode is
		isbypass = true
	}
	isOk, message := sheep.Assign(req.Form.Get("info"), key, isbypass)
	success = isOk
	message_e, isError := message.(error)
	if isError {
		message = message_e.Error()
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
Esempio n. 5
0
func WI_HostEnable(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message string = ""
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	}
	enable := req.Form.Get("enable")
	switch enable {
	case "0":
		sheepobj.Disable()
		success = true
	case "1":
		sheepobj.Enable()
		success = true
	default:
		message = fmt.Sprintf("enable type '%s'is undefined.", enable)
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}