forked from TrueCloudLab/frostfs-sdk-go
[#51] Add current nodes as external statistics
Signed-off-by: Artem Tataurov <a.tataurov@yadro.com>
This commit is contained in:
parent
0382785763
commit
0314b326d3
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
|
||||||
}
|
}
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
// 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