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
refactoring
chrislu57e7582c3654
diff --git a/weed/shell/commands.go b/weed/shell/commands.goindex e3de42aa92..15e6e06c2c 100644--- a/weed/shell/commands.go+++ b/weed/shell/commands.go@@ -73,7 +73,7 @@ func (ce *CommandEnv) isDirectory(path string) bool {func (ce *CommandEnv) confirmIsLocked(args []string) error {- if ce.locker.IsLocking() {+ if ce.locker.IsLocked() {return nil}ce.locker.SetMessage(fmt.Sprintf("%v", args))@@ -82,6 +82,10 @@ func (ce *CommandEnv) confirmIsLocked(args []string) error {}+func (ce *CommandEnv) isLocked() bool {+ return ce.locker.IsLocked()+}+func (ce *CommandEnv) checkDirectory(path string) error {dir, name := util.FullPath(path).DirAndName()diff --git a/weed/wdclient/exclusive_locks/exclusive_locker.go b/weed/wdclient/exclusive_locks/exclusive_locker.goindex 8274581611..291d4cf992 100644--- a/weed/wdclient/exclusive_locks/exclusive_locker.go+++ b/weed/wdclient/exclusive_locks/exclusive_locker.go@@ -19,7 +19,7 @@ const (type ExclusiveLocker struct {token int64lockTsNs int64- isLocking bool+ isLocked boolmasterClient *wdclient.MasterClientlockName stringmessage string@@ -32,8 +32,8 @@ func NewExclusiveLocker(masterClient *wdclient.MasterClient, lockName string) *E}}-func (l *ExclusiveLocker) IsLocking() bool {- return l.isLocking+func (l *ExclusiveLocker) IsLocked() bool {+ return l.isLocked}func (l *ExclusiveLocker) GetToken() (token int64, lockTsNs int64) {@@ -45,7 +45,7 @@ func (l *ExclusiveLocker) GetToken() (token int64, lockTsNs int64) {}func (l *ExclusiveLocker) RequestLock(clientName string) {- if l.isLocking {+ if l.isLocked {return}@@ -74,14 +74,14 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {}}- l.isLocking = true+ l.isLocked = true// start a goroutine to renew the leasego func() {ctx2, cancel2 := context.WithCancel(context.Background())defer cancel2()- for l.isLocking {+ for l.isLocked {if err := l.masterClient.WithClient(false, func(client master_pb.SeaweedClient) error {resp, err := client.LeaseAdminToken(ctx2, &master_pb.LeaseAdminTokenRequest{PreviousToken: atomic.LoadInt64(&l.token),@@ -98,6 +98,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {return err}); err != nil {glog.Errorf("failed to renew lock: %v", err)+ l.isLocked = falsereturn} else {time.Sleep(RenewInteval)@@ -109,7 +110,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {}func (l *ExclusiveLocker) ReleaseLock() {- l.isLocking = false+ l.isLocked = falsectx, cancel := context.WithCancel(context.Background())defer cancel()