Add node addresses as debug information #147
2 changed files with 14 additions and 0 deletions
|
@ -2482,8 +2482,12 @@ func (p *Pool) Balance(ctx context.Context, prm PrmBalanceGet) (accounting.Decim
|
||||||
func (p Pool) Statistic() Statistic {
|
func (p Pool) Statistic() Statistic {
|
||||||
stat := Statistic{}
|
stat := Statistic{}
|
||||||
for _, inner := range p.innerPools {
|
for _, inner := range p.innerPools {
|
||||||
|
nodes := make([]string, 0, len(inner.clients))
|
||||||
inner.lock.RLock()
|
inner.lock.RLock()
|
||||||
for _, cl := range inner.clients {
|
for _, cl := range inner.clients {
|
||||||
|
if cl.isHealthy() {
|
||||||
|
nodes = append(nodes, cl.address())
|
||||||
|
}
|
||||||
node := NodeStatistic{
|
node := NodeStatistic{
|
||||||
address: cl.address(),
|
address: cl.address(),
|
||||||
methods: cl.methodsStatus(),
|
methods: cl.methodsStatus(),
|
||||||
|
@ -2494,6 +2498,9 @@ func (p Pool) Statistic() Statistic {
|
||||||
stat.overallErrors += node.overallErrors
|
stat.overallErrors += node.overallErrors
|
||||||
dstepanov-yadro marked this conversation as resolved
Outdated
|
|||||||
}
|
}
|
||||||
inner.lock.RUnlock()
|
inner.lock.RUnlock()
|
||||||
|
if len(stat.currentNodes) == 0 {
|
||||||
|
stat.currentNodes = nodes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stat
|
return stat
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
type Statistic struct {
|
type Statistic struct {
|
||||||
overallErrors uint64
|
overallErrors uint64
|
||||||
nodes []NodeStatistic
|
nodes []NodeStatistic
|
||||||
|
currentNodes []string
|
||||||
dkirillov marked this conversation as resolved
Outdated
dkirillov
commented
We need getter for this field We need getter for this field
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OverallErrors returns sum of errors on all connections. It doesn't decrease.
|
// OverallErrors returns sum of errors on all connections. It doesn't decrease.
|
||||||
|
@ -21,6 +22,12 @@ func (s Statistic) Nodes() []NodeStatistic {
|
||||||
return s.nodes
|
return s.nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CurrentNodes returns list of nodes of inner pool that has at least one healthy node.
|
||||||
dkirillov marked this conversation as resolved
Outdated
dkirillov
commented
Let's mention that these nodes have the same priority and this priority is the highest among inner pool with healthy nodes Let's mention that these nodes have the same priority and this priority is the highest among inner pool with healthy nodes
|
|||||||
|
// These nodes have the same and the highest priority among the other healthy nodes.
|
||||||
|
func (s Statistic) CurrentNodes() []string {
|
||||||
|
return s.currentNodes
|
||||||
|
}
|
||||||
|
|
||||||
// ErrUnknownNode indicate that node with current address is not found in list.
|
// ErrUnknownNode indicate that node with current address is not found in list.
|
||||||
var ErrUnknownNode = errors.New("unknown node")
|
var ErrUnknownNode = errors.New("unknown node")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue
@fyrchik usually says: 'unrelated to commit'. It must be separate commit, as this change doesn't relate to
Add node addresses as debug information