aboutsummaryrefslogtreecommitdiff
path: root/weed/topology/volume_layout.go
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2024-03-22 19:39:11 +0500
committerGitHub <noreply@github.com>2024-03-22 07:39:11 -0700
commitdc9568fc0d418f27bef4f13efca6ee918e559fbd (patch)
tree1ee1f78376965a1f7e6c8eac7a62f5faf2b41da2 /weed/topology/volume_layout.go
parent953f5713490343f3cb4d36eb17bae9e8716068b4 (diff)
downloadseaweedfs-dc9568fc0d418f27bef4f13efca6ee918e559fbd.tar.xz
seaweedfs-dc9568fc0d418f27bef4f13efca6ee918e559fbd.zip
[master] add test for PickForWrite add metrics for volume layout (#5413)
Diffstat (limited to 'weed/topology/volume_layout.go')
-rw-r--r--weed/topology/volume_layout.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index 6b5d0b8da..278978292 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -3,6 +3,7 @@ package topology
import (
"errors"
"fmt"
+ "github.com/seaweedfs/seaweedfs/weed/stats"
"math/rand"
"sync"
"sync/atomic"
@@ -349,18 +350,21 @@ func (vl *VolumeLayout) DoneGrowRequest() {
}
func (vl *VolumeLayout) ShouldGrowVolumes(option *VolumeGrowOption) bool {
- active, crowded := vl.GetActiveVolumeCount(option)
+ total, active, crowded := vl.GetActiveVolumeCount(option)
+ stats.MasterVolumeLayout.WithLabelValues(option.Collection, option.ReplicaPlacement.String(), "total").Set(float64(total))
+ stats.MasterVolumeLayout.WithLabelValues(option.Collection, option.ReplicaPlacement.String(), "active").Set(float64(active))
+ stats.MasterVolumeLayout.WithLabelValues(option.Collection, option.ReplicaPlacement.String(), "crowded").Set(float64(crowded))
//glog.V(0).Infof("active volume: %d, high usage volume: %d\n", active, high)
return active <= crowded
}
-func (vl *VolumeLayout) GetActiveVolumeCount(option *VolumeGrowOption) (active, crowded int) {
+func (vl *VolumeLayout) GetActiveVolumeCount(option *VolumeGrowOption) (total, active, crowded int) {
vl.accessLock.RLock()
defer vl.accessLock.RUnlock()
-
if option.DataCenter == "" {
- return len(vl.writables), len(vl.crowded)
+ return len(vl.writables), len(vl.writables), len(vl.crowded)
}
+ total = len(vl.writables)
for _, v := range vl.writables {
for _, dn := range vl.vid2location[v].list {
if dn.GetDataCenter().Id() == NodeId(option.DataCenter) {