From accba3070a4a82756835e00696cea0da9c7ff596 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 7 Sep 2024 11:54:12 -0700 Subject: [PATCH] refactor --- weed/server/master_grpc_server_volume.go | 4 ++-- weed/topology/volume_growth.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index eb0d43705..ec0dcf8a1 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "math/rand/v2" - "reflect" "strings" "sync" "time" @@ -92,7 +91,8 @@ func (ms *MasterServer) ProcessGrowRequest() { // filter out identical requests being processed found := false filter.Range(func(k, v interface{}) bool { - if reflect.DeepEqual(k, req) { + existingReq := k.(*topology.VolumeGrowRequest) + if existingReq.Equals(req) { found = true } return !found diff --git a/weed/topology/volume_growth.go b/weed/topology/volume_growth.go index 70f0d9cd4..44462aa87 100644 --- a/weed/topology/volume_growth.go +++ b/weed/topology/volume_growth.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "math/rand/v2" + "reflect" "sync" "time" @@ -29,6 +30,11 @@ type VolumeGrowRequest struct { Option *VolumeGrowOption Count uint32 Force bool + Reason string +} + +func (vg *VolumeGrowRequest) Equals(req *VolumeGrowRequest) bool { + return reflect.DeepEqual(existingReq.Option, req.Option) && vg.Count == req.Count } type volumeGrowthStrategy struct {