SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Prune wdclient Functions (#8855)
Lars Lehtonen387b146eddda
diff --git a/weed/wdclient/filer_client.go b/weed/wdclient/filer_client.goindex f3fd7e753d..ace4a6a7e9 100644--- a/weed/wdclient/filer_client.go+++ b/weed/wdclient/filer_client.go@@ -503,55 +503,17 @@ func (fc *FilerClient) shouldSkipUnhealthyFilerWithHealth(health *filerHealth) breturn true // Skip this unhealthy filer}-// Deprecated: Use shouldSkipUnhealthyFilerWithHealth instead-// This function is kept for backward compatibility but requires array access-// Note: This function is now thread-safe.-func (fc *FilerClient) shouldSkipUnhealthyFiler(index int32) bool {- fc.filerAddressesMu.RLock()- if index >= int32(len(fc.filerHealth)) {- fc.filerAddressesMu.RUnlock()- return true // Invalid index - skip- }- health := fc.filerHealth[index]- fc.filerAddressesMu.RUnlock()- return fc.shouldSkipUnhealthyFilerWithHealth(health)-}-// recordFilerSuccessWithHealth resets failure tracking for a successful filerfunc (fc *FilerClient) recordFilerSuccessWithHealth(health *filerHealth) {atomic.StoreInt32(&health.failureCount, 0)}-// recordFilerSuccess resets failure tracking for a successful filer-func (fc *FilerClient) recordFilerSuccess(index int32) {- fc.filerAddressesMu.RLock()- if index >= int32(len(fc.filerHealth)) {- fc.filerAddressesMu.RUnlock()- return // Invalid index- }- health := fc.filerHealth[index]- fc.filerAddressesMu.RUnlock()- fc.recordFilerSuccessWithHealth(health)-}-// recordFilerFailureWithHealth increments failure count for an unhealthy filerfunc (fc *FilerClient) recordFilerFailureWithHealth(health *filerHealth) {atomic.AddInt32(&health.failureCount, 1)atomic.StoreInt64(&health.lastFailureTimeNs, time.Now().UnixNano())}-// recordFilerFailure increments failure count for an unhealthy filer-func (fc *FilerClient) recordFilerFailure(index int32) {- fc.filerAddressesMu.RLock()- if index >= int32(len(fc.filerHealth)) {- fc.filerAddressesMu.RUnlock()- return // Invalid index- }- health := fc.filerHealth[index]- fc.filerAddressesMu.RUnlock()- fc.recordFilerFailureWithHealth(health)-}-// LookupVolumeIds queries the filer for volume locations with automatic failover// Tries all configured filer addresses until one succeeds (high availability)// Retries transient gRPC errors (Unavailable, DeadlineExceeded, etc.) with exponential backoffdiff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.goindex 25bac2cfff..e3acaf81a5 100644--- a/weed/wdclient/vid_map.go+++ b/weed/wdclient/vid_map.go@@ -15,10 +15,6 @@ import ("github.com/seaweedfs/seaweedfs/weed/glog")-const (- maxCursorIndex = 4096-)-type HasLookupFileIdFunction interface {GetLookupFileIdFunction() LookupFileIdFunctionType}@@ -41,7 +37,6 @@ type vidMap struct {vid2Locations map[uint32][]LocationecVid2Locations map[uint32][]LocationDataCenter string- cursor int32cache atomic.Pointer[vidMap]}@@ -50,18 +45,7 @@ func newVidMap(dataCenter string) *vidMap {vid2Locations: make(map[uint32][]Location),ecVid2Locations: make(map[uint32][]Location),DataCenter: dataCenter,- cursor: -1,- }-}--func (vc *vidMap) getLocationIndex(length int) (int, error) {- if length <= 0 {- return 0, fmt.Errorf("invalid length: %d", length)- }- if atomic.LoadInt32(&vc.cursor) == maxCursorIndex {- atomic.CompareAndSwapInt32(&vc.cursor, maxCursorIndex, -1)}- return int(atomic.AddInt32(&vc.cursor, 1)) % length, nil}func (vc *vidMap) isSameDataCenter(loc *Location) bool {diff --git a/weed/wdclient/vid_map_test.go b/weed/wdclient/vid_map_test.goindex 7a828fdad4..ec0aa86e91 100644--- a/weed/wdclient/vid_map_test.go+++ b/weed/wdclient/vid_map_test.go@@ -2,7 +2,6 @@ package wdclientimport ("context"- "fmt""strconv""sync""testing"@@ -12,60 +11,6 @@ import ("google.golang.org/grpc")-func TestLocationIndex(t *testing.T) {- vm := &vidMap{}- // test must be failed- mustFailed := func(length int) {- _, err := vm.getLocationIndex(length)- if err == nil {- t.Errorf("length %d must be failed", length)- }- if err.Error() != fmt.Sprintf("invalid length: %d", length) {- t.Errorf("length %d must be failed. error: %v", length, err)- }- }-- mustFailed(-1)- mustFailed(0)-- mustOk := func(length, cursor, expect int) {- if length <= 0 {- t.Fatal("please don't do this")- }- vm.cursor = int32(cursor)- got, err := vm.getLocationIndex(length)- if err != nil {- t.Errorf("length: %d, why? %v\n", length, err)- return- }- if got != expect {- t.Errorf("cursor: %d, length: %d, expect: %d, got: %d\n", cursor, length, expect, got)- return- }- }-- for i := -1; i < 100; i++ {- mustOk(7, i, (i+1)%7)- }-- // when cursor reaches MaxInt64- mustOk(7, maxCursorIndex, 0)-- // test with constructor- vm = newVidMap("")- length := 7- for i := 0; i < 100; i++ {- got, err := vm.getLocationIndex(length)- if err != nil {- t.Errorf("length: %d, why? %v\n", length, err)- return- }- if got != i%length {- t.Errorf("length: %d, i: %d, got: %d\n", length, i, got)- }- }-}-func TestLookupFileId(t *testing.T) {mc := NewMasterClient(grpc.EmptyDialOption{}, "", "", "", "", "", pb.ServerDiscovery{})length := 5@@ -172,19 +117,3 @@ func TestConcurrentGetLocations(t *testing.T) {cancel()wg.Wait()}--func BenchmarkLocationIndex(b *testing.B) {- b.SetParallelism(8)- vm := vidMap{- cursor: maxCursorIndex - 4000,- }- b.ResetTimer()- b.RunParallel(func(pb *testing.PB) {- for pb.Next() {- _, err := vm.getLocationIndex(3)- if err != nil {- b.Error(err)- }- }- })-}