Prune wdclient Functions (#8855)
* chore(weed/wdclient): prune unused functions * chore(weed/wdclient): prune test-only functions and associated tests * chore(weed/wdclient): remove dead cursor field The cursor field and its initialization are no longer used after the removal of getLocationIndex. --------- Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
@@ -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][]Location
|
||||
ecVid2Locations map[uint32][]Location
|
||||
DataCenter string
|
||||
cursor int32
|
||||
cache atomic.Pointer[vidMap]
|
||||
}
|
||||
|
||||
@@ -50,20 +45,9 @@ 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 {
|
||||
if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user