Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
power-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
power-node
Commits
a524e093
Commit
a524e093
authored
May 24, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update controller
parent
4d599023
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
22 deletions
+19
-22
StateController.go
controllers/StateController.go
+15
-21
node_manager.go
models/node_manager.go
+1
-0
api.go
nm/api.go
+1
-1
start.go
nm/start.go
+2
-0
No files found.
controllers/StateController.go
View file @
a524e093
...
@@ -7,8 +7,6 @@ import (
...
@@ -7,8 +7,6 @@ import (
"example.com/m/nm"
"example.com/m/nm"
"example.com/m/utils"
"example.com/m/utils"
"io"
"io"
"math/rand"
"time"
)
)
type
StateController
struct
{
type
StateController
struct
{
...
@@ -39,25 +37,21 @@ func (c *StateController) GetRunningTp() {
...
@@ -39,25 +37,21 @@ func (c *StateController) GetRunningTp() {
}
}
func
(
c
*
StateController
)
GetRunningLineChart
()
{
func
(
c
*
StateController
)
GetRunningLineChart
()
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
info
:=
utils
.
GetHardwareInfo
(
conf
.
GetConfig
()
.
HardwareUrl
)
randomNumber
:=
rand
.
Intn
(
100
)
if
info
==
nil
{
circularBuffer
.
Add
(
int64
(
randomNumber
))
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
(
200
,
"get running state successful"
,
circularBuffer
.
GetDataTail
())
//info := utils.GetHardwareInfo()
}
//if info == nil {
c
.
ResponseInfo
(
500
,
"get running tp failed"
,
""
)
// 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", "")
}
}
func
(
c
*
StateController
)
GetWorkerInfo
()
{
func
(
c
*
StateController
)
GetWorkerInfo
()
{
...
...
models/node_manager.go
View file @
a524e093
...
@@ -198,6 +198,7 @@ type NodeManagerClient struct {
...
@@ -198,6 +198,7 @@ type NodeManagerClient struct {
LastHeartTime
time
.
Time
LastHeartTime
time
.
Time
PublicKey
string
PublicKey
string
Endpoint
string
Endpoint
string
Location
string
Client
nodemanagerV2
.
NodeManagerServiceClient
Client
nodemanagerV2
.
NodeManagerServiceClient
Status
bool
Status
bool
IsDel
bool
IsDel
bool
...
...
nm/api.go
View file @
a524e093
...
@@ -26,7 +26,7 @@ func init() {
...
@@ -26,7 +26,7 @@ func init() {
CompletedTaskCount
:
0
,
CompletedTaskCount
:
0
,
NmIpAddr
:
""
,
NmIpAddr
:
""
,
NmDelayTime
:
0
,
NmDelayTime
:
0
,
NmLocation
:
"
Hong Kong
"
,
NmLocation
:
""
,
}
}
}
}
...
...
nm/start.go
View file @
a524e093
...
@@ -168,6 +168,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
...
@@ -168,6 +168,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
nodeManagerClient
=
&
models
.
NodeManagerClient
{
nodeManagerClient
=
&
models
.
NodeManagerClient
{
PublicKey
:
manager
.
Info
.
Publickey
,
PublicKey
:
manager
.
Info
.
Publickey
,
Endpoint
:
manager
.
Info
.
Endpoint
,
Endpoint
:
manager
.
Info
.
Endpoint
,
Location
:
manager
.
Info
.
Location
,
Status
:
true
,
Status
:
true
,
IsSelected
:
isSelect
,
IsSelected
:
isSelect
,
LastHeartTime
:
time
.
Now
(),
LastHeartTime
:
time
.
Now
(),
...
@@ -185,6 +186,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
...
@@ -185,6 +186,7 @@ func inputNodeManagerChan(manager *NodeManager, nodeManagerClient *models.NodeMa
manager
.
IsUsed
=
true
manager
.
IsUsed
=
true
if
isSelect
{
if
isSelect
{
RunningState
.
NmIpAddr
=
nodeManagerClient
.
Endpoint
RunningState
.
NmIpAddr
=
nodeManagerClient
.
Endpoint
RunningState
.
NmLocation
=
nodeManagerClient
.
Location
}
}
return
true
return
true
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment