Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
088bc341
Unverified
Commit
088bc341
authored
Oct 11, 2021
by
rjl493456442
Committed by
GitHub
Oct 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les/vflux/server: fix metrics (#22946)
* les/vflux/server: fix metrics * les/vflux/server: fix metrics
parent
53b1420e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
clientpool.go
les/vflux/server/clientpool.go
+4
-2
metrics.go
les/vflux/server/metrics.go
+3
-1
prioritypool.go
les/vflux/server/prioritypool.go
+15
-7
No files found.
les/vflux/server/clientpool.go
View file @
088bc341
...
...
@@ -143,8 +143,10 @@ func NewClientPool(balanceDb ethdb.KeyValueStore, minCap uint64, connectedBias t
if
oldState
.
HasAll
(
cp
.
setup
.
activeFlag
)
&&
oldState
.
HasNone
(
cp
.
setup
.
activeFlag
)
{
clientDeactivatedMeter
.
Mark
(
1
)
}
_
,
connected
:=
cp
.
Active
()
totalConnectedGauge
.
Update
(
int64
(
connected
))
activeCount
,
activeCap
:=
cp
.
Active
()
totalActiveCountGauge
.
Update
(
int64
(
activeCount
))
totalActiveCapacityGauge
.
Update
(
int64
(
activeCap
))
totalInactiveCountGauge
.
Update
(
int64
(
cp
.
Inactive
()))
})
return
cp
}
...
...
les/vflux/server/metrics.go
View file @
088bc341
...
...
@@ -21,7 +21,9 @@ import (
)
var
(
totalConnectedGauge
=
metrics
.
NewRegisteredGauge
(
"vflux/server/totalConnected"
,
nil
)
totalActiveCapacityGauge
=
metrics
.
NewRegisteredGauge
(
"vflux/server/active/capacity"
,
nil
)
totalActiveCountGauge
=
metrics
.
NewRegisteredGauge
(
"vflux/server/active/count"
,
nil
)
totalInactiveCountGauge
=
metrics
.
NewRegisteredGauge
(
"vflux/server/inactive/count"
,
nil
)
clientConnectedMeter
=
metrics
.
NewRegisteredMeter
(
"vflux/server/clientEvent/connected"
,
nil
)
clientActivatedMeter
=
metrics
.
NewRegisteredMeter
(
"vflux/server/clientEvent/activated"
,
nil
)
...
...
les/vflux/server/prioritypool.go
View file @
088bc341
...
...
@@ -128,7 +128,7 @@ func newPriorityPool(ns *nodestate.NodeStateMachine, setup *serverSetup, clock m
}
else
{
ns
.
SetStateSub
(
node
,
nodestate
.
Flags
{},
pp
.
setup
.
activeFlag
.
Or
(
pp
.
setup
.
inactiveFlag
),
0
)
if
n
,
_
:=
pp
.
ns
.
GetField
(
node
,
pp
.
setup
.
queueField
)
.
(
*
ppNodeInfo
);
n
!=
nil
{
pp
.
disconnect
ed
Node
(
n
)
pp
.
disconnectNode
(
n
)
}
ns
.
SetFieldSub
(
node
,
pp
.
setup
.
capacityField
,
nil
)
ns
.
SetFieldSub
(
node
,
pp
.
setup
.
queueField
,
nil
)
...
...
@@ -137,10 +137,10 @@ func newPriorityPool(ns *nodestate.NodeStateMachine, setup *serverSetup, clock m
ns
.
SubscribeState
(
pp
.
setup
.
activeFlag
.
Or
(
pp
.
setup
.
inactiveFlag
),
func
(
node
*
enode
.
Node
,
oldState
,
newState
nodestate
.
Flags
)
{
if
c
,
_
:=
pp
.
ns
.
GetField
(
node
,
pp
.
setup
.
queueField
)
.
(
*
ppNodeInfo
);
c
!=
nil
{
if
oldState
.
IsEmpty
()
{
pp
.
connect
ed
Node
(
c
)
pp
.
connectNode
(
c
)
}
if
newState
.
IsEmpty
()
{
pp
.
disconnect
ed
Node
(
c
)
pp
.
disconnectNode
(
c
)
}
}
})
...
...
@@ -233,6 +233,14 @@ func (pp *priorityPool) Active() (uint64, uint64) {
return
pp
.
activeCount
,
pp
.
activeCap
}
// Inactive returns the number of currently inactive nodes
func
(
pp
*
priorityPool
)
Inactive
()
int
{
pp
.
lock
.
Lock
()
defer
pp
.
lock
.
Unlock
()
return
pp
.
inactiveQueue
.
Size
()
}
// Limits returns the maximum allowed number and total capacity of active nodes
func
(
pp
*
priorityPool
)
Limits
()
(
uint64
,
uint64
)
{
pp
.
lock
.
Lock
()
...
...
@@ -285,9 +293,9 @@ func (pp *priorityPool) inactivePriority(p *ppNodeInfo) int64 {
return
p
.
nodePriority
.
priority
(
pp
.
minCap
)
}
// connect
ed
Node is called when a new node has been added to the pool (inactiveFlag set)
// connectNode is called when a new node has been added to the pool (inactiveFlag set)
// Note: this function should run inside a NodeStateMachine operation
func
(
pp
*
priorityPool
)
connect
ed
Node
(
c
*
ppNodeInfo
)
{
func
(
pp
*
priorityPool
)
connectNode
(
c
*
ppNodeInfo
)
{
pp
.
lock
.
Lock
()
pp
.
activeQueue
.
Refresh
()
if
c
.
connected
{
...
...
@@ -301,10 +309,10 @@ func (pp *priorityPool) connectedNode(c *ppNodeInfo) {
pp
.
updateFlags
(
updates
)
}
// disconnect
ed
Node is called when a node has been removed from the pool (both inactiveFlag
// disconnectNode is called when a node has been removed from the pool (both inactiveFlag
// and activeFlag reset)
// Note: this function should run inside a NodeStateMachine operation
func
(
pp
*
priorityPool
)
disconnect
ed
Node
(
c
*
ppNodeInfo
)
{
func
(
pp
*
priorityPool
)
disconnectNode
(
c
*
ppNodeInfo
)
{
pp
.
lock
.
Lock
()
pp
.
activeQueue
.
Refresh
()
if
!
c
.
connected
{
...
...
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