Commit a524e093 authored by duanjinfei's avatar duanjinfei

update controller

parent 4d599023
......@@ -7,8 +7,6 @@ import (
"example.com/m/nm"
"example.com/m/utils"
"io"
"math/rand"
"time"
)
type StateController struct {
......@@ -39,25 +37,21 @@ func (c *StateController) GetRunningTp() {
}
func (c *StateController) GetRunningLineChart() {
rand.Seed(time.Now().UnixNano())
randomNumber := rand.Intn(100)
circularBuffer.Add(int64(randomNumber))
c.ResponseInfo(200, "get running state successful", circularBuffer.GetDataTail())
//info := utils.GetHardwareInfo()
//if info == nil {
// c.ResponseInfo(500, "get running tp failed", "")
// return
//}
//if len(info.Data.Gpus) > 0 {
// var totalUsage int64
// for _, gpu := range info.Data.Gpus {
// totalUsage += gpu.Usage
// }
// avgTemp := totalUsage / int64(len(info.Data.Gpus))
// circularBuffer.Add(avgTemp)
// c.ResponseInfo(200, "get running state successful", circularBuffer.GetDataTail())
//}
//c.ResponseInfo(500, "get running tp failed", "")
info := utils.GetHardwareInfo(conf.GetConfig().HardwareUrl)
if info == nil {
c.ResponseInfo(500, "get running tp failed", "")
return
}
if len(info.Data.Gpus) > 0 {
var totalUsage int64
for _, gpu := range info.Data.Gpus {
totalUsage += int64(gpu.Usage)
}
avgTemp := totalUsage / int64(len(info.Data.Gpus))
circularBuffer.Add(avgTemp)
c.ResponseInfo(200, "get running state successful", circularBuffer.GetDataTail())
}
c.ResponseInfo(500, "get running tp failed", "")
}
func (c *StateController) GetWorkerInfo() {
......
......@@ -198,6 +198,7 @@ type NodeManagerClient struct {
LastHeartTime time.Time
PublicKey string
Endpoint string
Location string
Client nodemanagerV2.NodeManagerServiceClient
Status bool
IsDel bool
......
......@@ -26,7 +26,7 @@ func init() {
CompletedTaskCount: 0,
NmIpAddr: "",
NmDelayTime: 0,
NmLocation: "Hong Kong",
NmLocation: "",
}
}
......
......@@ -168,6 +168,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
nodeManagerClient = &models.NodeManagerClient{
PublicKey: manager.Info.Publickey,
Endpoint: manager.Info.Endpoint,
Location: manager.Info.Location,
Status: true,
IsSelected: isSelect,
LastHeartTime: time.Now(),
......@@ -185,6 +186,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
manager.IsUsed = true
if isSelect {
RunningState.NmIpAddr = nodeManagerClient.Endpoint
RunningState.NmLocation = nodeManagerClient.Location
}
return true
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment