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
6eeefaf6
Commit
6eeefaf6
authored
Feb 01, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update monitor nodemanager client
parent
6f6d3c34
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
121 deletions
+150
-121
main.go
main.go
+6
-0
node_manager.go
models/node_manager.go
+2
-1
start.go
nm/start.go
+127
-103
task_msg.go
nm/task_msg.go
+13
-15
validator.go
validator/validator.go
+2
-2
No files found.
main.go
View file @
6eeefaf6
...
...
@@ -4,10 +4,16 @@ import (
"example.com/m/log"
"example.com/m/nm"
"github.com/astaxie/beego"
_
"net/http/pprof"
)
func
main
()
{
log
.
InitLog
(
log
.
LogConfig
{
Path
:
"logs"
,
Level
:
"debug"
,
Save
:
3
})
//go func() {
// log.Println(http.ListenAndServe("localhost:6060", nil))
//}()
//runtime.SetBlockProfileRate(1) // 开启对阻塞操作的跟踪,block
//runtime.SetMutexProfileFraction(1) // 开启对锁调用的跟踪,mutex
nm
.
StartMonitor
()
beego
.
Run
()
}
models/node_manager.go
View file @
6eeefaf6
...
...
@@ -32,7 +32,7 @@ type ModelInfo struct {
ImageName
string
`json:"image_name"`
DiskSize
int64
`json:"disk_size"`
MemorySize
int64
`json:"memory_size"`
IsImageExist
bool
`json:"is_image_delete"`
IsImageExist
bool
}
type
ComputeResult
struct
{
...
...
@@ -48,6 +48,7 @@ type NodeManagerClient struct {
Endpoint
string
Client
nodeManagerV1
.
NodeManagerServiceClient
Status
bool
IsDel
bool
}
func
(
n
*
NodeManagerClient
)
GetLastHeartTime
()
int64
{
...
...
nm/start.go
View file @
6eeefaf6
This diff is collapsed.
Click to expand it.
nm/task_msg.go
View file @
6eeefaf6
...
...
@@ -93,19 +93,6 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
log
.
Errorf
(
"failed to unmarshal task cmd: %s"
,
err
.
Error
())
return
}
var
externalPort
int64
for
{
// 设置种子以确保每次运行时生成不同的随机数序列
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
// 生成一个介于 0 和 100 之间的随机整数
externalPort
=
rand
.
Int63n
(
10001
)
+
10000
fmt
.
Println
(
"t.DockerOp.UsedExternalPort[externalPort]:"
,
t
.
DockerOp
.
UsedExternalPort
[
externalPort
])
if
t
.
DockerOp
.
UsedExternalPort
[
externalPort
]
{
continue
}
break
}
taskCmd
.
DockerCmd
.
HostPort
=
strconv
.
FormatInt
(
externalPort
,
10
)
images
,
err
:=
t
.
DockerOp
.
PsImages
()
if
err
!=
nil
{
...
...
@@ -127,10 +114,8 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
}
log
.
Println
(
image
.
ID
)
}
containers
:=
t
.
DockerOp
.
ListContainer
()
isImageRunExist
:=
false
for
_
,
container
:=
range
containers
{
if
container
.
ImageID
==
imageId
{
taskCmd
.
ApiUrl
=
fmt
.
Sprintf
(
taskCmd
.
ApiUrl
,
container
.
Ports
[
0
]
.
PublicPort
)
...
...
@@ -139,6 +124,19 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
}
}
if
!
isImageRunExist
{
var
externalPort
int64
for
{
// 设置种子以确保每次运行时生成不同的随机数序列
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
// 生成一个介于 0 和 100 之间的随机整数
externalPort
=
rand
.
Int63n
(
10001
)
+
10000
log
.
Info
(
"DockerOp UsedExternalPort :"
,
t
.
DockerOp
.
UsedExternalPort
[
externalPort
])
if
t
.
DockerOp
.
UsedExternalPort
[
externalPort
]
{
continue
}
break
}
taskCmd
.
DockerCmd
.
HostPort
=
strconv
.
FormatInt
(
externalPort
,
10
)
taskCmd
.
ApiUrl
=
fmt
.
Sprintf
(
taskCmd
.
ApiUrl
,
externalPort
)
if
int64
(
len
(
containers
))
==
conf
.
GetConfig
()
.
ContainerNum
{
//todo: 待定,需要根据权重去停止哪个容器
...
...
validator/validator.go
View file @
6eeefaf6
...
...
@@ -21,8 +21,8 @@ type ProofWorker struct {
func
NewProofWorker
()
*
ProofWorker
{
return
&
ProofWorker
{
productProofChan
:
make
(
chan
*
witnessV1
.
Proof
,
0
),
consumeProofChan
:
make
(
chan
[]
*
witnessV1
.
Proof
,
0
),
productProofChan
:
make
(
chan
*
witnessV1
.
Proof
,
100
0
),
consumeProofChan
:
make
(
chan
[]
*
witnessV1
.
Proof
,
100
0
),
isCommitProof
:
make
(
map
[
string
]
bool
,
0
),
}
}
...
...
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